sipxportlib  Version 3.3
OsTime.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2012 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 #ifndef _OsTime_h_
15 #define _OsTime_h_
16 
17 // SYSTEM INCLUDES
18 
19 // APPLICATION INCLUDES
20 #include "os/OsDefs.h"
21 #include "utl/UtlDefs.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 
32 //:Time or time interval
33 // If necessary, this class will adjust the seconds and microseconds values
34 // that it reports such that 0 <= microseconds < USECS_PER_SEC.
35 
36 
37 class OsTime
38 {
39 /* //////////////////////////// PUBLIC //////////////////////////////////// */
40 public:
41 
43  typedef enum
44  {
47  } TimeQuantity;
48 
49  static const long MSECS_PER_SEC;
50  static const long USECS_PER_MSEC;
51  static const long USECS_PER_SEC;
52 
53 /* ============================ CREATORS ================================== */
54 
55  OsTime();
56  //:Default constructor (creates a zero duration interval)
57 
58  OsTime(const long msecs);
59  //:Constructor specifying time/duration in terms of milliseconds
60 
61  OsTime(TimeQuantity quantity);
62  //:Constructor specifying time/duration in terms of TimeQuantity enum
63 
64  OsTime(const long seconds, const long usecs);
65  //:Constructor specifying time/duration in terms of seconds and microseconds
66 
67  OsTime(const OsTime& rOsTime);
68  //:Copy constructor
69 
70  virtual
71  ~OsTime();
72  //:Destructor
73 
74 /* ============================ MANIPULATORS ============================== */
75 
77  //:Assignment operator
78 
79  OsTime& operator=(const OsTime& rhs);
80  //:Assignment operator
81 
82  OsTime operator+(const OsTime& rhs);
83  //:Addition operator
84 
85  OsTime operator-(const OsTime& rhs);
86  //:Subtraction operator
87 
88  OsTime operator+=(const OsTime& rhs);
89  //:Increment operator
90 
91  OsTime operator-=(const OsTime& rhs);
92  //:Decrement operator
93 
94  bool operator==(const OsTime& rhs) const;
95  //:Test for equality operator
96 
97  bool operator!=(const OsTime& rhs) const;
98  //:Test for inequality operator
99 
100  bool operator>(const OsTime& rhs) const;
101  //:Test for greater than
102 
103  bool operator>=(const OsTime& rhs) const;
104  //:Test for greater than or equal
105 
106  bool operator<(const OsTime& rhs) const;
107  //:Test for less than
108 
109  bool operator<=(const OsTime& rhs) const;
110  //:Test for less than or equal
111 
112 /* ============================ ACCESSORS ================================= */
113 
114  virtual long seconds(void) const
115  {
116  return mSeconds;
117  }
118  //:Return the seconds portion of the time interval
119 
120  virtual long usecs(void) const
121  {
122  return mUsecs;
123  }
124  //:Return the microseconds portion of the time interval
125 
126  virtual long cvtToMsecs(void) const;
127  //:Convert the time interval to milliseconds
128 
129  virtual double getDouble() const;
130  //: Return number of seconds (and microseconds) as a double
131 
132 /* ============================ INQUIRY =================================== */
133 
134  virtual UtlBoolean isInfinite(void) const;
135  //:Return TRUE if the time interval is infinite
136 
137  virtual UtlBoolean isNoWait(void) const;
138  //:Return TRUE if the time interval is zero (no wait)
139 
140 /* //////////////////////////// PROTECTED ///////////////////////////////// */
141 protected:
142 
143 /* //////////////////////////// PRIVATE /////////////////////////////////// */
144 private:
145  long mSeconds;
146  long mUsecs;
147 
148  void init(void);
149  //:Initialize the instance variables for a newly constructed object
150 
151 };
152 
153 /* ============================ INLINE METHODS ============================ */
154 
155 #endif // _OsTime_h_
156 
virtual long usecs(void) const
Definition: OsTime.h:120
virtual double getDouble() const
Definition: OsTime.cpp:276
static const long USECS_PER_MSEC
Definition: OsTime.h:50
virtual UtlBoolean isInfinite(void) const
Definition: OsTime.cpp:284
bool operator<=(const OsTime &rhs) const
Definition: OsTime.cpp:252
static const long USECS_PER_SEC
Definition: OsTime.h:51
bool operator==(const OsTime &rhs) const
Definition: OsTime.cpp:187
OsTime operator+(const OsTime &rhs)
Definition: OsTime.cpp:157
bool operator>=(const OsTime &rhs) const
Definition: OsTime.cpp:218
Definition: OsTime.h:46
virtual long seconds(void) const
Definition: OsTime.h:114
OsTime operator-=(const OsTime &rhs)
Definition: OsTime.cpp:180
virtual UtlBoolean isNoWait(void) const
Definition: OsTime.cpp:293
virtual ~OsTime()
Definition: OsTime.cpp:118
Definition: OsTime.h:45
OsTime()
Definition: OsTime.cpp:39
OsTime & operator=(TimeQuantity rhs)
Definition: OsTime.cpp:126
OsTime operator-(const OsTime &rhs)
Definition: OsTime.cpp:165
TimeQuantity
Time quantity enum for special time values.
Definition: OsTime.h:43
virtual long cvtToMsecs(void) const
Definition: OsTime.cpp:271
bool operator>(const OsTime &rhs) const
Definition: OsTime.cpp:201
Definition: OsTime.h:37
int UtlBoolean
Definition: UtlDefs.h:41
bool operator<(const OsTime &rhs) const
Definition: OsTime.cpp:235
static const long MSECS_PER_SEC
Definition: OsTime.h:49
OsTime operator+=(const OsTime &rhs)
Definition: OsTime.cpp:173
bool operator!=(const OsTime &rhs) const
Definition: OsTime.cpp:194