timeint.h

Go to the documentation of this file.
00001 /*
00002  * timeint.h
00003  *
00004  * Millisecond resolution time interval class (uses 64 bit integers).
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Revision: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00032  */
00033 
00034 #ifndef _PTIMEINTERVAL
00035 #define _PTIMEINTERVAL
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 
00043 // Difference between two system times
00044 
00055 class PTimeInterval : public PObject
00056 {
00057   PCLASSINFO(PTimeInterval, PObject);
00058 
00059   public:
00073     PTimeInterval(
00074       PInt64 millisecs = 0   
00075     );
00076     PTimeInterval(
00077       long millisecs,       
00078       long seconds,         
00079       long minutes = 0,     
00080       long hours = 0,       
00081       int days = 0          
00082     );
00083     PTimeInterval(
00084       const PString & str   
00085     );
00087 
00096     PObject * Clone() const;
00097 
00105     virtual Comparison Compare(
00106       const PObject & obj   
00107     ) const;
00108 
00112     virtual void PrintOn(
00113       ostream & strm    
00114     ) const;
00115 
00119     virtual void ReadFrom(
00120       istream & strm    
00121     );
00123 
00126     enum Formats {
00127       NormalFormat,
00128       IncludeDays,
00129       SecondsOnly
00130     };
00131 
00132     PString AsString(
00133       int decimals = 3,
00134       Formats format = NormalFormat,
00135       int width = 1
00136     ) const;
00138 
00146     PInt64 GetMilliSeconds() const;
00147 
00153     long GetSeconds() const;
00154 
00160     long GetMinutes() const;
00161 
00167     int GetHours() const;
00168 
00174     int GetDays() const;
00175 
00181     DWORD GetInterval() const;
00182 
00194     virtual void SetInterval(
00195       PInt64 milliseconds = 0,  
00196       long seconds = 0,         
00197       long minutes = 0,         
00198       long hours = 0,           
00199       int days = 0              
00200     );
00202 
00210     PTimeInterval operator-() const;
00211 
00217     PTimeInterval operator+(
00218       const PTimeInterval & interval   
00219     ) const;
00220 
00226     PTimeInterval & operator+=(
00227       const PTimeInterval & interval   
00228     );
00229 
00235     PTimeInterval operator-(
00236       const PTimeInterval & interval   
00237     ) const;
00238 
00244     PTimeInterval & operator-=(
00245       const PTimeInterval & interval   
00246     );
00247 
00253     PTimeInterval operator*(
00254       int factor   
00255     ) const;
00256 
00262     PTimeInterval & operator*=(
00263       int factor   
00264     );
00265 
00271     PTimeInterval operator/(
00272       int factor   
00273     ) const;
00274 
00280     PTimeInterval & operator/=(
00281       int factor   
00282     );
00284 
00294     bool operator==(
00295       const PTimeInterval & interval   
00296     ) const;
00297     bool operator==(
00298       long msecs    
00299     ) const;
00300 
00308     bool operator!=(
00309       const PTimeInterval & interval   
00310     ) const;
00311     bool operator!=(
00312       long msecs    
00313     ) const;
00314 
00322     bool operator> (
00323       const PTimeInterval & interval   
00324     ) const;
00325     bool operator> (
00326       long msecs    
00327     ) const;
00328 
00336     bool operator>=(
00337       const PTimeInterval & interval   
00338     ) const;
00339     bool operator>=(
00340       long msecs    
00341     ) const;
00342 
00350     bool operator< (
00351       const PTimeInterval & interval   
00352     ) const;
00353     bool operator< (
00354       long msecs    
00355     ) const;
00356 
00364     bool operator<=(
00365       const PTimeInterval & interval   
00366     ) const;
00367     bool operator<=(
00368       long msecs    
00369     ) const;
00371 
00372   protected:
00373   // Member variables
00375     PInt64 milliseconds;
00376 
00377 
00378 // Include platform dependent part of class
00379 #ifdef _WIN32
00380 #include "msos/ptlib/timeint.h"
00381 #else
00382 #include "unix/ptlib/timeint.h"
00383 #endif
00384 };
00385 
00386 #endif
00387 
00388 
00389 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Sep 15 01:21:35 2008 for PTLib by  doxygen 1.5.1