Changeset 2617 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 12/07/03 15:00:13 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
r2604 r2617 50 50 51 51 #pragma link C++ class MTime+; 52 #pragma link C++ function operator<<(ostream&, const MTime&); 52 53 53 54 #pragma link C++ class MArgs+; -
trunk/MagicSoft/Mars/mbase/MTime.h
r2612 r2617 22 22 class MTime : public MParContainer 23 23 { 24 friend bool operator==(MTime &t1, MTime &t2);25 friend bool operator!=(MTime &t1, MTime &t2);26 friend bool operator< (MTime &t1, MTime &t2);27 friend bool operator> (MTime &t1, MTime &t2);28 //friend bool operator<=(MTime &t1, MTime &t2);29 //friend bool operator>=(MTime &t1, MTime &t2);30 31 24 private: 32 25 static const UInt_t kHour; // [ms] one hour 33 26 static const UInt_t kDay; // [ms] one day 34 27 35 36 37 28 UInt_t fMjd; // [d] Day in the century (Day of sun rise) 29 TTime fTime; // [ms] Time of Day (-11h<=x<13h) 30 UInt_t fNanoSec; // [ns] NanoSec part of TimeOfDay (<1000000) 38 31 39 40 41 42 43 44 32 ULong_t GetTime24() const 33 { 34 return (Long_t)fTime<0 ? (Long_t)fTime+kDay : (ULong_t)fTime; 35 } 36 void Init(const char *name, const char *title) 37 { 45 38 fName = name ? name : "MTime"; 46 39 fTitle = title ? title : "Generalized time stamp"; 47 40 } 48 41 49 42 public: … … 111 104 } 112 105 106 bool operator<(const MTime &t) const 107 { 108 if (fMjd<t.fMjd) 109 return true; 110 if (fMjd==t.fMjd && fTime<t.fTime) 111 return true; 112 if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec<t.fNanoSec) 113 return true; 114 return false; 115 } 116 bool operator>(const MTime &t) const 117 { 118 if (fMjd>t.fMjd) 119 return true; 120 if (fMjd==t.fMjd && fTime>t.fTime) 121 return true; 122 if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec>t.fNanoSec) 123 return true; 124 return false; 125 } 126 127 bool operator<=(const MTime &t) const 128 { 129 return !operator>(t); 130 } 131 132 bool operator>=(const MTime &t) const 133 { 134 return !operator<(t); 135 } 136 137 bool operator==(const MTime &t) const 138 { 139 return fNanoSec==t.fNanoSec && fTime==t.fTime && fMjd==t.fMjd; 140 } 141 142 bool operator!=(const MTime &t) const 143 { 144 return fNanoSec!=t.fNanoSec || fTime!=t.fTime || fMjd!=t.fMjd; 145 } 146 147 bool operator!() const 148 { 149 return fNanoSec==0 && (ULong_t)fTime==0 && fMjd==0; 150 } 151 113 152 ClassDef(MTime, 3) //A generalized MARS time stamp 114 153 }; 115 154 116 inline bool operator<(MTime &t1, MTime &t2) 117 { 118 if (t1.fMjd<t2.fMjd) 119 return true; 120 if (t1.fMjd==t2.fMjd && t1.fTime<t2.fTime) 121 return true; 122 if (t1.fMjd==t2.fMjd && t1.fTime==t2.fTime && t1.fNanoSec<t2.fNanoSec) 123 return true; 124 return false; 125 } 126 127 inline bool operator>(MTime &t1, MTime &t2) 128 { 129 if (t1.fMjd>t2.fMjd) 130 return true; 131 if (t1.fMjd==t2.fMjd && t1.fTime>t2.fTime) 132 return true; 133 if (t1.fMjd==t2.fMjd && t1.fTime==t2.fTime && t1.fNanoSec>t2.fNanoSec) 134 return true; 135 return false; 136 } 137 138 inline bool operator<=(MTime &t1, MTime &t2) 139 { 140 return !(t1>t2); 141 } 142 143 inline bool operator>=(MTime &t1, MTime &t2) 144 { 145 return !(t1<t2); 146 } 147 148 inline bool operator==(MTime &t1, MTime &t2) 149 { 150 return t1.fNanoSec==t2.fNanoSec && t1.fTime==t2.fTime && t1.fMjd==t2.fMjd; 151 } 152 153 inline bool operator!=(MTime &t1, MTime &t2) 154 { 155 return t1.fNanoSec!=t2.fNanoSec || t1.fTime!=t2.fTime || t1.fMjd!=t2.fMjd; 156 } 157 158 inline ostream &operator<<(ostream &out, MTime &t) 155 inline ostream &operator<<(ostream &out, const MTime &t) 159 156 { 160 157 out << t.GetString();
Note:
See TracChangeset
for help on using the changeset viewer.