TTime.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TTime.h 34556 2010-07-22 15:10:17Z rdm $
00002 // Author: Fons Rademakers   28/11/96
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TTime
00013 #define ROOT_TTime
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TTime                                                                //
00019 //                                                                      //
00020 // Basic time type with millisecond precision.                          //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_Rtypes
00025 #include "Rtypes.h"
00026 #endif
00027 
00028 
00029 class TTime {
00030 
00031 private:
00032    Long64_t   fMilliSec;   // time with millisecond precision
00033 
00034 public:
00035    TTime(): fMilliSec(0) { }
00036    TTime(Long64_t msec): fMilliSec(msec) { }
00037    TTime(const TTime &t): fMilliSec(t.fMilliSec) { }
00038    virtual ~TTime() { }
00039 
00040    TTime& operator=(const TTime &t);
00041 
00042    TTime operator+=(const TTime &t);
00043    TTime operator-=(const TTime &t);
00044    TTime operator*=(const TTime &t);
00045    TTime operator/=(const TTime &t);
00046 
00047    friend TTime operator+(const TTime &t1, const TTime &t2);
00048    friend TTime operator-(const TTime &t1, const TTime &t2);
00049    friend TTime operator*(const TTime &t1, const TTime &t2);
00050    friend TTime operator/(const TTime &t1, const TTime &t2);
00051 
00052    friend Bool_t operator== (const TTime &t1, const TTime &t2);
00053    friend Bool_t operator!= (const TTime &t1, const TTime &t2);
00054    friend Bool_t operator<  (const TTime &t1, const TTime &t2);
00055    friend Bool_t operator<= (const TTime &t1, const TTime &t2);
00056    friend Bool_t operator>  (const TTime &t1, const TTime &t2);
00057    friend Bool_t operator>= (const TTime &t1, const TTime &t2);
00058 
00059    operator long() const;
00060    operator unsigned long() const;
00061    operator long long() const;
00062    operator unsigned long long() const;
00063    const char *AsString() const;
00064 
00065    ClassDef(TTime,2)  //Basic time type with milli second precision
00066 };
00067 
00068 inline TTime& TTime::operator= (const TTime &t)
00069    { fMilliSec = t.fMilliSec; return *this; }
00070 inline TTime TTime::operator+=(const TTime &t)
00071    { fMilliSec += t.fMilliSec; return *this; }
00072 inline TTime TTime::operator-=(const TTime &t)
00073    { fMilliSec -= t.fMilliSec; return *this; }
00074 inline TTime TTime::operator*=(const TTime &t)
00075    { fMilliSec *= t.fMilliSec; return *this; }
00076 inline TTime TTime::operator/=(const TTime &t)
00077    { fMilliSec /= t.fMilliSec; return *this; }
00078 inline TTime::operator long long() const
00079    { return fMilliSec; }
00080 inline TTime::operator unsigned long long() const
00081    { return (ULong64_t) fMilliSec; }
00082 
00083 inline TTime operator+(const TTime &t1, const TTime &t2)
00084    { return TTime(t1.fMilliSec + t2.fMilliSec); }
00085 inline TTime operator-(const TTime &t1, const TTime &t2)
00086    { return TTime(t1.fMilliSec - t2.fMilliSec); }
00087 inline TTime operator*(const TTime &t1, const TTime &t2)
00088    { return TTime(t1.fMilliSec * t2.fMilliSec); }
00089 inline TTime operator/(const TTime &t1, const TTime &t2)
00090    { return TTime(t1.fMilliSec / t2.fMilliSec); }
00091 
00092 inline Bool_t operator== (const TTime &t1, const TTime &t2)
00093    { return t1.fMilliSec == t2.fMilliSec; }
00094 inline Bool_t operator!= (const TTime &t1, const TTime &t2)
00095    { return t1.fMilliSec != t2.fMilliSec; }
00096 inline Bool_t operator< (const TTime &t1, const TTime &t2)
00097    { return t1.fMilliSec < t2.fMilliSec; }
00098 inline Bool_t operator<= (const TTime &t1, const TTime &t2)
00099    { return t1.fMilliSec <= t2.fMilliSec; }
00100 inline Bool_t operator> (const TTime &t1, const TTime &t2)
00101    { return t1.fMilliSec > t2.fMilliSec; }
00102 inline Bool_t operator>= (const TTime &t1, const TTime &t2)
00103    { return t1.fMilliSec >= t2.fMilliSec; }
00104 
00105 #endif

Generated on Tue Jul 5 14:10:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1