PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
timeint.h
Go to the documentation of this file.
1 /*
2  * timeint.h
3  *
4  * Millisecond resolution time interval class (uses 64 bit integers).
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 32009 $
30  * $Author: rjongbloed $
31  * $Date: 2014-05-31 13:32:03 +1000 (Sat, 31 May 2014) $
32  */
33 
34 #ifndef PTLIB_TIMEINTERVAL_H
35 #define PTLIB_TIMEINTERVAL_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 
43 // Difference between two system times
44 
55 class PTimeInterval : public PObject
56 {
57  PCLASSINFO(PTimeInterval, PObject);
58 
59  public:
74  PInt64 millisecs = 0
75  );
77  PInt64 millisecs,
78  long seconds,
79  long minutes = 0,
80  long hours = 0,
81  int days = 0
82  );
84  const PString & str
85  );
87 
96  PObject * Clone() const;
97 
105  virtual Comparison Compare(
106  const PObject & obj
107  ) const;
108 
112  virtual void PrintOn(
113  ostream & strm
114  ) const;
115 
119  virtual void ReadFrom(
120  istream & strm
121  );
123 
126  enum Formats {
130  };
131 
133  int decimals = 3,
134  Formats format = NormalFormat,
135  int width = 1
136  ) const;
138 
146  virtual PInt64 GetMilliSeconds() const;
147 
150  virtual void SetMilliSeconds(PInt64 msecs);
151 
157  long GetSeconds() const;
158 
164  long GetMinutes() const;
165 
171  int GetHours() const;
172 
178  int GetDays() const;
179 
185  DWORD GetInterval() const;
186 
198  virtual void SetInterval(
199  PInt64 milliseconds = 0,
200  long seconds = 0,
201  long minutes = 0,
202  long hours = 0,
203  int days = 0
204  );
206 
214  PTimeInterval operator-() const;
215 
222  const PTimeInterval & interval
223  ) const;
224 
231  const PTimeInterval & interval
232  );
233 
240  const PTimeInterval & interval
241  ) const;
242 
249  const PTimeInterval & interval
250  );
251 
258  int factor
259  ) const;
260 
267  int factor
268  );
269 
275  int operator/(
276  const PTimeInterval & smaller
277  ) const;
278 
285  int factor
286  ) const;
287 
294  int factor
295  );
297 
307  bool operator==(
308  const PTimeInterval & interval
309  ) const;
310  bool operator==(
311  long msecs
312  ) const;
313 
321  bool operator!=(
322  const PTimeInterval & interval
323  ) const;
324  bool operator!=(
325  long msecs
326  ) const;
327 
335  bool operator> (
336  const PTimeInterval & interval
337  ) const;
338  bool operator> (
339  long msecs
340  ) const;
341 
349  bool operator>=(
350  const PTimeInterval & interval
351  ) const;
352  bool operator>=(
353  long msecs
354  ) const;
355 
363  bool operator< (
364  const PTimeInterval & interval
365  ) const;
366  bool operator< (
367  long msecs
368  ) const;
369 
377  bool operator<=(
378  const PTimeInterval & interval
379  ) const;
380  bool operator<=(
381  long msecs
382  ) const;
384 
385  private:
386  // Member variables
388  PInt64 m_milliseconds;
389 
390 
391 // Include platform dependent part of class
392 #ifdef _WIN32
393 #include "msos/ptlib/timeint.h"
394 #else
395 #include "unix/ptlib/timeint.h"
396 #endif
397 };
398 
399 #endif // PTLIB_TIMEINTERVAL_H
400 
401 
402 // End Of File ///////////////////////////////////////////////////////////////