Logo ROOT   6.07/09
Reference Guide
TTime.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 28/11/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTime
13 #define ROOT_TTime
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TTime //
19 // //
20 // Basic time type with millisecond precision. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_Rtypes
25 #include "Rtypes.h"
26 #endif
27 
28 
29 class TTime {
30 
31 private:
32  Long64_t fMilliSec; // time with millisecond precision
33 
34 public:
35  TTime(): fMilliSec(0) { }
36  TTime(Long64_t msec): fMilliSec(msec) { }
37  TTime(const TTime &t): fMilliSec(t.fMilliSec) { }
38  virtual ~TTime() { }
39 
40  TTime& operator=(const TTime &t);
41 
42  TTime operator+=(const TTime &t);
43  TTime operator-=(const TTime &t);
44  TTime operator*=(const TTime &t);
45  TTime operator/=(const TTime &t);
46 
47  friend TTime operator+(const TTime &t1, const TTime &t2);
48  friend TTime operator-(const TTime &t1, const TTime &t2);
49  friend TTime operator*(const TTime &t1, const TTime &t2);
50  friend TTime operator/(const TTime &t1, const TTime &t2);
51 
52  friend Bool_t operator== (const TTime &t1, const TTime &t2);
53  friend Bool_t operator!= (const TTime &t1, const TTime &t2);
54  friend Bool_t operator< (const TTime &t1, const TTime &t2);
55  friend Bool_t operator<= (const TTime &t1, const TTime &t2);
56  friend Bool_t operator> (const TTime &t1, const TTime &t2);
57  friend Bool_t operator>= (const TTime &t1, const TTime &t2);
58 
59  operator long() const;
60  operator unsigned long() const;
61  operator long long() const;
62  operator unsigned long long() const;
63  const char *AsString() const;
64 
65  ClassDef(TTime,2) //Basic time type with milli second precision
66 };
67 
68 inline TTime& TTime::operator= (const TTime &t)
69  { fMilliSec = t.fMilliSec; return *this; }
70 inline TTime TTime::operator+=(const TTime &t)
71  { fMilliSec += t.fMilliSec; return *this; }
72 inline TTime TTime::operator-=(const TTime &t)
73  { fMilliSec -= t.fMilliSec; return *this; }
74 inline TTime TTime::operator*=(const TTime &t)
75  { fMilliSec *= t.fMilliSec; return *this; }
76 inline TTime TTime::operator/=(const TTime &t)
77  { fMilliSec /= t.fMilliSec; return *this; }
78 inline TTime::operator long long() const
79  { return fMilliSec; }
80 inline TTime::operator unsigned long long() const
81  { return (ULong64_t) fMilliSec; }
82 
83 inline TTime operator+(const TTime &t1, const TTime &t2)
84  { return TTime(t1.fMilliSec + t2.fMilliSec); }
85 inline TTime operator-(const TTime &t1, const TTime &t2)
86  { return TTime(t1.fMilliSec - t2.fMilliSec); }
87 inline TTime operator*(const TTime &t1, const TTime &t2)
88  { return TTime(t1.fMilliSec * t2.fMilliSec); }
89 inline TTime operator/(const TTime &t1, const TTime &t2)
90  { return TTime(t1.fMilliSec / t2.fMilliSec); }
91 
92 inline Bool_t operator== (const TTime &t1, const TTime &t2)
93  { return t1.fMilliSec == t2.fMilliSec; }
94 inline Bool_t operator!= (const TTime &t1, const TTime &t2)
95  { return t1.fMilliSec != t2.fMilliSec; }
96 inline Bool_t operator< (const TTime &t1, const TTime &t2)
97  { return t1.fMilliSec < t2.fMilliSec; }
98 inline Bool_t operator<= (const TTime &t1, const TTime &t2)
99  { return t1.fMilliSec <= t2.fMilliSec; }
100 inline Bool_t operator> (const TTime &t1, const TTime &t2)
101  { return t1.fMilliSec > t2.fMilliSec; }
102 inline Bool_t operator>= (const TTime &t1, const TTime &t2)
103  { return t1.fMilliSec >= t2.fMilliSec; }
104 
105 #endif
friend TTime operator*(const TTime &t1, const TTime &t2)
Definition: TTime.h:87
friend TTime operator/(const TTime &t1, const TTime &t2)
Definition: TTime.h:89
TTime()
Definition: TTime.h:35
long long Long64_t
Definition: RtypesCore.h:69
Long64_t fMilliSec
Definition: TTime.h:32
friend Bool_t operator==(const TTime &t1, const TTime &t2)
Definition: TTime.h:92
bool Bool_t
Definition: RtypesCore.h:59
Basic time type with millisecond precision.
Definition: TTime.h:29
TLatex * t1
Definition: textangle.C:20
friend Bool_t operator<=(const TTime &t1, const TTime &t2)
Definition: TTime.h:98
#define ClassDef(name, id)
Definition: Rtypes.h:254
friend Bool_t operator>=(const TTime &t1, const TTime &t2)
Definition: TTime.h:102
friend Bool_t operator<(const TTime &t1, const TTime &t2)
Definition: TTime.h:96
TTime operator*=(const TTime &t)
Definition: TTime.h:74
friend Bool_t operator!=(const TTime &t1, const TTime &t2)
Definition: TTime.h:94
const char * AsString() const
Return the time as a string.
Definition: TTime.cxx:28
friend TTime operator+(const TTime &t1, const TTime &t2)
Definition: TTime.h:83
friend Bool_t operator>(const TTime &t1, const TTime &t2)
Definition: TTime.h:100
TTime(const TTime &t)
Definition: TTime.h:37
TTime & operator=(const TTime &t)
Definition: TTime.h:68
unsigned long long ULong64_t
Definition: RtypesCore.h:70
TTime operator+=(const TTime &t)
Definition: TTime.h:70
TTime operator-=(const TTime &t)
Definition: TTime.h:72
friend TTime operator-(const TTime &t1, const TTime &t2)
Definition: TTime.h:85
TTime(Long64_t msec)
Definition: TTime.h:36
TTime operator/=(const TTime &t)
Definition: TTime.h:76
virtual ~TTime()
Definition: TTime.h:38