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
106