timeStamp.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: timeStamp.h,v 1.24 2005/12/23 17:01:41 amoll Exp $
00005 //
00006 
00007 #ifndef BALL_CONCEPT_TIMESTAMP_H
00008 #define BALL_CONCEPT_TIMESTAMP_H
00009 
00010 #ifndef BALL_CONFIG_CONFIG_H
00011 # include <BALL/CONFIG/config.h>
00012 #endif
00013 
00014 #ifndef BALL_COMMON_CREATE_H
00015 # include <BALL/COMMON/create.h>
00016 #endif
00017 
00018 #ifndef BALL_COMMON_DEBUG_H
00019 # include <BALL/COMMON/debug.h>
00020 #endif
00021 
00022 #ifndef BALL_CONCEPT_PERSISTENCEMANAGER_H
00023 # include <BALL/CONCEPT/persistenceManager.h>
00024 #endif
00025 
00026 #include <iostream>
00027 
00028 namespace BALL 
00029 {
00030 
00039   class BALL_EXPORT PreciseTime
00040   {
00041 
00042     public:
00043 
00044     BALL_CREATE(PreciseTime)
00045 
00046     
00049 
00053     PreciseTime()
00054       ;
00055       
00058     PreciseTime(const PreciseTime& time)
00059       ;
00060 
00063     PreciseTime(long secs, long usecs)
00064       ;
00065       
00068     virtual ~PreciseTime()
00069       ;
00070 
00072 
00075 
00078     static const PreciseTime ZERO;
00079 
00081 
00084 
00087     void set(long secs, long usecs) 
00088       ;
00089 
00092     void set(const PreciseTime& time) 
00093       ;
00094 
00097     const PreciseTime& operator = (const PreciseTime& time) 
00098       ;
00099 
00102     virtual void clear() 
00103       ;
00104 
00106 
00109 
00112     bool operator < (const PreciseTime& time) const 
00113       ;
00114 
00117     bool operator > (const PreciseTime& time) const 
00118       ;
00119 
00122     bool operator == (const PreciseTime& time) const 
00123       ;
00124 
00126 
00129 
00132     long getSeconds() const 
00133       ;
00134 
00137     long getMicroSeconds() const 
00138       ;
00139 
00143     static PreciseTime now() 
00144       ;
00145 
00147 
00151 
00158     void write(PersistenceManager& pm) const
00159       ;
00160 
00167     bool read(PersistenceManager& pm)
00168       ;
00169 
00171  
00172     protected:
00173 
00174     long secs_;
00175     long usecs_;
00176 
00177     #ifdef BALL_HAS_WINDOWS_PERFORMANCE_COUNTER
00178       static long ticks_;
00179     #endif
00180   };
00181 
00188   class BALL_EXPORT TimeStamp
00189   {
00190     public:
00191 
00192     BALL_CREATE(TimeStamp)
00193 
00194     
00197 
00200     TimeStamp()
00201       ;
00202 
00205     virtual ~TimeStamp()
00206       ;
00207 
00209 
00212 
00215     bool isNewerThan(const PreciseTime& time) const 
00216       ;
00217     
00220     bool isOlderThan(const PreciseTime& time) const 
00221       ;
00222 
00225     bool isNewerThan(const TimeStamp& stamp) const 
00226       ;
00227     
00230     bool isOlderThan(const TimeStamp& stamp) const 
00231       ;
00232 
00235     bool operator == (const TimeStamp& stamp) const 
00236       ;
00237     
00239 
00242 
00249     virtual void stamp(const PreciseTime& time = PreciseTime::ZERO) 
00250       ;
00251 
00255     const PreciseTime& getTime() const 
00256       ;
00257 
00259 
00262 
00265     const PreciseTime& operator = (const PreciseTime& time) 
00266       ;
00267 
00270     virtual void clear() 
00271       ;
00272 
00274 
00277 
00284     void write(PersistenceManager& pm) const
00285       ;
00286 
00293     bool read(PersistenceManager& pm)
00294       ;
00295 
00297 
00298     protected:
00299 
00302     PreciseTime time_;
00303   };
00304 
00308 
00311   BALL_EXPORT
00312   std::ostream& operator << (std::ostream& os, const PreciseTime& time)
00313     ;
00314 
00317   BALL_EXPORT
00318   std::ostream& operator << (std::ostream& os, const TimeStamp& stamp)
00319     ;
00320 
00322 
00323 
00324 # ifndef BALL_NO_INLINE_FUNCTIONS
00325 #   include <BALL/CONCEPT/timeStamp.iC>
00326 # endif
00327 
00328 } // namespace BALL
00329 
00330 #endif // BALL_CONCEPT_TIMESTAMP_H