00001 // ===================================================================== 00024 // ===================================================================== 00025 #ifndef CLDAQ__TSYSTEMCLOCK_HH 00026 #define CLDAQ__TSYSTEMCLOCK_HH 00027 00028 #include "Tglobals.h" 00029 00030 00050 class TSystemClock 00051 { 00052 00053 private: 00054 // elapsed time in second from 1970/1/1/00:00:00 00055 // 現在時刻を聞いたら,必ず theLastRequiredTime = theTime これがUpdate() 00056 // 任意の時刻を尋ねてもこれは起こらない 00057 Tint theAllocatedTime; 00058 Tint theLastUpdateTime; 00059 Tint theTime; 00060 00061 public: 00062 TSystemClock(); 00063 TSystemClock( const TSystemClock& right ); 00064 ~TSystemClock(); 00065 00066 public: 00067 const TSystemClock& operator=( const TSystemClock& right ); 00068 friend Tostream& operator<<( Tostream& tos, const TSystemClock& right ); 00069 00070 public: 00071 Tstring WhatTimeIsItNow(); 00072 Tstring WhatTimeIsIt( Tint second = -1 ); 00073 Tstring WhenAllocated(); 00074 Tstring WhenUpdate(); 00075 Tint GetElapsedTime( const Tstring& unit = Tsec ); 00076 Tint GetElapsedTimeOfLastUpdate( const Tstring& unit = Tsec ); 00077 Tint GetYear( Tint second = -1 ); 00078 Tint GetMonth( Tint second = -1 ); 00079 Tint GetDay( Tint second = -1 ); 00080 Tint GetHour( Tint second = -1 ); 00081 Tint GetMinute( Tint second = -1 ); 00082 Tint GetSecond( Tint second = -1 ); 00083 Tint Update(); 00084 00085 public: 00086 Tint GetAllocatedTime() const; 00087 Tint GetLastUpdateTime() const; 00088 Tint GetTime() const; 00089 00090 }; 00091 00092 inline Tint TSystemClock::GetAllocatedTime() const 00093 { 00094 return theAllocatedTime; 00095 } 00096 00097 inline Tint TSystemClock::GetLastUpdateTime() const 00098 { 00099 return theLastUpdateTime; 00100 } 00101 00102 inline Tint TSystemClock::GetTime() const 00103 { 00104 return theTime; 00105 } 00106 00107 #endif