source: trunk/MagicSoft/Mars/mbase/MTime.h@ 1149

Last change on this file since 1149 was 1014, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.5 KB
Line 
1#ifndef MARS_MTime
2#define MARS_MTime
3
4/////////////////////////////////////////////////////////////////////////////
5// //
6// MTime //
7// //
8// A generalized MARS time stamp //
9// //
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef MARS_MParContainer
13#include "MParContainer.h"
14#endif
15
16class MTime : public MParContainer
17{
18private:
19 UInt_t fTimeStamp[2]; // type of raw event which should be processed by this task
20 UInt_t fDuration; // time of validity
21
22public:
23
24 MTime(const char *name=NULL, const char *title=NULL)
25 {
26 fName = name ? name : ClassName();
27 fTitle = title;
28
29 SetTime(0, 0);
30 }
31
32 MTime(UInt_t t1, UInt_t t0)
33 {
34 SetTime(t1, t0);
35 }
36
37 MTime(MTime& t)
38 {
39 fTimeStamp[0] = t.fTimeStamp[0];
40 fTimeStamp[1] = t.fTimeStamp[1];
41 fDuration = t.fDuration;
42 }
43
44 void operator=(MTime &t)
45 {
46 fTimeStamp[0] = t.fTimeStamp[0];
47 fTimeStamp[1] = t.fTimeStamp[1];
48 fDuration = t.fDuration;
49 }
50
51 ~MTime() {}
52
53 void Print(Option_t *t=NULL) const;
54
55 void SetTime(UInt_t t1, UInt_t t0)
56 {
57 fTimeStamp[0] = t1;
58 fTimeStamp[1] = t0;
59 }
60
61 void SetDuration(UInt_t t)
62 {
63 fDuration = t;
64 }
65
66 MTime *GetTime()
67 {
68 return this;
69 }
70
71 UInt_t GetTimeLo()
72 {
73 return fTimeStamp[0];
74 }
75 UInt_t GetTimeHi()
76 {
77 return fTimeStamp[1];
78 }
79
80 UInt_t GetDuration()
81 {
82 return fDuration;
83 }
84
85 ClassDef(MTime, 1) //A generalized MARS time stamp
86};
87
88inline Bool_t operator<(MTime &t1, MTime &t2)
89{
90 return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<t2.GetTimeLo());
91}
92
93inline Bool_t operator>(MTime &t1, MTime &t2)
94{
95 return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>t2.GetTimeLo());
96}
97
98inline Bool_t operator<=(MTime &t1, MTime &t2)
99{
100 return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<=t2.GetTimeLo());
101}
102
103inline Bool_t operator>=(MTime &t1, MTime &t2)
104{
105 return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>=t2.GetTimeLo());
106}
107
108inline Bool_t operator==(MTime &t1, MTime &t2)
109{
110 return (t1.GetTimeLo()==t2.GetTimeLo()) && (t1.GetTimeHi()==t2.GetTimeHi());
111}
112
113#endif
Note: See TracBrowser for help on using the repository browser.