Logo ROOT   master
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 #include "Rtypes.h"
25 
26 
27 class TTime {
28 
29 private:
30  Long64_t fMilliSec; // time with millisecond precision
31 
32 public:
33  TTime(): fMilliSec(0) { }
34  TTime(Long64_t msec): fMilliSec(msec) { }
35  TTime(const TTime &t): fMilliSec(t.fMilliSec) { }
36  virtual ~TTime() { }
37 
38  TTime& operator=(const TTime &t);
39 
40  TTime operator+=(const TTime &t);
41  TTime operator-=(const TTime &t);
42  TTime operator*=(const TTime &t);
43  TTime operator/=(const TTime &t);
44 
45  friend TTime operator+(const TTime &t1, const TTime &t2);
46  friend TTime operator-(const TTime &t1, const TTime &t2);
47  friend TTime operator*(const TTime &t1, const TTime &t2);
48  friend TTime operator/(const TTime &t1, const TTime &t2);
49 
50  friend Bool_t operator== (const TTime &t1, const TTime &t2);
51  friend Bool_t operator!= (const TTime &t1, const TTime &t2);
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 
57  operator long() const;
58  operator unsigned long() const;
59  operator long long() const;
60  operator unsigned long long() const;
61  const char *AsString() const;
62 
63  ClassDef(TTime,2) //Basic time type with milli second precision
64 };
65 
66 inline TTime& TTime::operator= (const TTime &t)
67  { fMilliSec = t.fMilliSec; return *this; }
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::operator long long() const
77  { return fMilliSec; }
78 inline TTime::operator unsigned long long() const
79  { return (ULong64_t) fMilliSec; }
80 
81 inline TTime operator+(const TTime &t1, const TTime &t2)
82  { return TTime(t1.fMilliSec + t2.fMilliSec); }
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 
90 inline Bool_t operator== (const TTime &t1, const TTime &t2)
91  { return t1.fMilliSec == t2.fMilliSec; }
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 
103 #endif
friend TTime operator*(const TTime &t1, const TTime &t2)
Definition: TTime.h:85
friend TTime operator/(const TTime &t1, const TTime &t2)
Definition: TTime.h:87
TTime()
Definition: TTime.h:33
Bool_t operator<=(const TTime &t1, const TTime &t2)
Definition: TTime.h:96
long long Long64_t
Definition: RtypesCore.h:69
Long64_t fMilliSec
Definition: TTime.h:30
friend Bool_t operator==(const TTime &t1, const TTime &t2)
Definition: TTime.h:90
TTime operator/(const TTime &t1, const TTime &t2)
Definition: TTime.h:87
bool Bool_t
Definition: RtypesCore.h:59
Basic time type with millisecond precision.
Definition: TTime.h:27
friend Bool_t operator<=(const TTime &t1, const TTime &t2)
Definition: TTime.h:96
#define ClassDef(name, id)
Definition: Rtypes.h:326
Bool_t operator==(const TTime &t1, const TTime &t2)
Definition: TTime.h:90
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
Bool_t operator>(const TTime &t1, const TTime &t2)
Definition: TTime.h:98
friend Bool_t operator<(const TTime &t1, const TTime &t2)
Definition: TTime.h:94
TTime operator*=(const TTime &t)
Definition: TTime.h:72
friend Bool_t operator!=(const TTime &t1, const TTime &t2)
Definition: TTime.h:92
friend TTime operator+(const TTime &t1, const TTime &t2)
Definition: TTime.h:81
friend Bool_t operator>(const TTime &t1, const TTime &t2)
Definition: TTime.h:98
TTime operator+(const TTime &t1, const TTime &t2)
Definition: TTime.h:81
TTime operator*(const TTime &t1, const TTime &t2)
Definition: TTime.h:85
TTime(const TTime &t)
Definition: TTime.h:35
Bool_t operator!=(const TTime &t1, const TTime &t2)
Definition: TTime.h:92
Bool_t operator>=(const TTime &t1, const TTime &t2)
Definition: TTime.h:100
const char * AsString() const
Return the time as a string.
Definition: TTime.cxx:28
TTime & operator=(const TTime &t)
Definition: TTime.h:66
auto * t1
Definition: textangle.C:20
unsigned long long ULong64_t
Definition: RtypesCore.h:70
TTime operator+=(const TTime &t)
Definition: TTime.h:68
TTime operator-=(const TTime &t)
Definition: TTime.h:70
friend TTime operator-(const TTime &t1, const TTime &t2)
Definition: TTime.h:83
TTime(Long64_t msec)
Definition: TTime.h:34
Bool_t operator<(const TTime &t1, const TTime &t2)
Definition: TTime.h:94
TTime operator/=(const TTime &t)
Definition: TTime.h:74
virtual ~TTime()
Definition: TTime.h:36