Panda3D

Loading...
Searching...
No Matches
time_general.h
1#ifndef __TIME_GENERAL_H__
2#define __TIME_GENERAL_H__
3
4 Time_Span TimeDifference(const Time_Clock &time1, const Time_Clock &time2);
5 Time_Clock TimeDifference(const Time_Clock &time1, const Time_Span &Time_Span);
6 Time_Clock TimeAddition(const Time_Clock &time1, Time_Span &Time_Span);
7
8 Time_Clock operator+(const Time_Clock &tm, const Time_Span &ts);
9 Time_Clock operator-(const Time_Clock &tm, const Time_Span &ts);
10
11/**
12 *
13 */
14 inline Time_Span TimeDifference(const Time_Clock &time1, const Time_Clock &time2) {
15 timeval ans;
16 TimeDif(time2.GetTval(), time1.GetTval(), ans);
17 return Time_Span(ans);
18}
19
20/**
21 *
22 */
23 inline Time_Clock TimeDifference(const Time_Clock &time1, const Time_Span &Time_Span) {
24 timeval ans;
25 TimeDif(Time_Span.GetTval(), time1.GetTval(), ans);
26 return Time_Clock(ans);
27}
28
29/**
30 *
31 */
32 inline Time_Clock TimeAddition(const Time_Clock &time1, Time_Span &Time_Span)
33{
34 timeval ans;
35 TimeAdd(time1.GetTval(), Time_Span.GetTval(), ans);
36 return Time_Clock(ans);
37}
38
39/**
40 *
41 */
42 inline const Time_Clock &Time_Clock::operator+=(const Time_Span &Time_Span) {
43 _my_time.tv_usec += Time_Span._my_time.tv_usec;
44 _my_time.tv_sec += Time_Span._my_time.tv_sec;
45 NormalizeTime(_my_time);
46 return *this;
47}
48
49/**
50 *
51 */
52 inline Time_Clock operator+(const Time_Clock &tm, const Time_Span &ts) {
53 Time_Clock work(tm);
54 work += ts;
55 return work;
56}
57
58/**
59 *
60 */
61 inline Time_Clock operator-(const Time_Clock &tm, const Time_Span &ts) {
62 return TimeDifference(tm, ts);
63}
64
65/**
66 *
67 */
68 inline const Time_Clock& Time_Clock::operator-=(const Time_Span &Time_Span) {
69 _my_time.tv_usec -= Time_Span._my_time.tv_usec;
70 _my_time.tv_sec -= Time_Span._my_time.tv_sec;
71 NormalizeTime(_my_time);
72 return *this;
73}
74
75/**
76 *
77 */
78 inline Time_Span operator-(const Time_Clock &tm1, const Time_Clock &tm2) {
79 return TimeDifference(tm1, tm2);
80}
81
82#endif //__TIME_GENERAL_H__
Time_Clock
This class is to provide a consistant interface and storage to clock time
Definition time_clock.h:14
Time_Span
Definition time_span.h:7