Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TTime.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   28/11/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTime
0013 #define ROOT_TTime
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TTime                                                                //
0019 //                                                                      //
0020 // Basic time type with millisecond precision.                          //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "Rtypes.h"
0025 
0026 
0027 class TTime {
0028 
0029 private:
0030    Long64_t   fMilliSec;   // time with millisecond precision
0031 
0032 public:
0033    TTime(): fMilliSec(0) { }
0034    TTime(Long64_t msec): fMilliSec(msec) { }
0035    TTime(const TTime &t): fMilliSec(t.fMilliSec) { }
0036    virtual ~TTime() { }
0037 
0038    TTime& operator=(const TTime &t);
0039 
0040    TTime operator+=(const TTime &t);
0041    TTime operator-=(const TTime &t);
0042    TTime operator*=(const TTime &t);
0043    TTime operator/=(const TTime &t);
0044 
0045    friend TTime operator+(const TTime &t1, const TTime &t2);
0046    friend TTime operator-(const TTime &t1, const TTime &t2);
0047    friend TTime operator*(const TTime &t1, const TTime &t2);
0048    friend TTime operator/(const TTime &t1, const TTime &t2);
0049 
0050    friend Bool_t operator== (const TTime &t1, const TTime &t2);
0051    friend Bool_t operator!= (const TTime &t1, const TTime &t2);
0052    friend Bool_t operator<  (const TTime &t1, const TTime &t2);
0053    friend Bool_t operator<= (const TTime &t1, const TTime &t2);
0054    friend Bool_t operator>  (const TTime &t1, const TTime &t2);
0055    friend Bool_t operator>= (const TTime &t1, const TTime &t2);
0056 
0057    operator long() const;
0058    operator unsigned long() const;
0059    operator long long() const;
0060    operator unsigned long long() const;
0061    const char *AsString() const;
0062 
0063    ClassDef(TTime,2)  //Basic time type with milli second precision
0064 };
0065 
0066 inline TTime& TTime::operator= (const TTime &t)
0067    { fMilliSec = t.fMilliSec; return *this; }
0068 inline TTime TTime::operator+=(const TTime &t)
0069    { fMilliSec += t.fMilliSec; return *this; }
0070 inline TTime TTime::operator-=(const TTime &t)
0071    { fMilliSec -= t.fMilliSec; return *this; }
0072 inline TTime TTime::operator*=(const TTime &t)
0073    { fMilliSec *= t.fMilliSec; return *this; }
0074 inline TTime TTime::operator/=(const TTime &t)
0075    { fMilliSec /= t.fMilliSec; return *this; }
0076 inline TTime::operator long long() const
0077    { return fMilliSec; }
0078 inline TTime::operator unsigned long long() const
0079    { return (ULong64_t) fMilliSec; }
0080 
0081 inline TTime operator+(const TTime &t1, const TTime &t2)
0082    { return TTime(t1.fMilliSec + t2.fMilliSec); }
0083 inline TTime operator-(const TTime &t1, const TTime &t2)
0084    { return TTime(t1.fMilliSec - t2.fMilliSec); }
0085 inline TTime operator*(const TTime &t1, const TTime &t2)
0086    { return TTime(t1.fMilliSec * t2.fMilliSec); }
0087 inline TTime operator/(const TTime &t1, const TTime &t2)
0088    { return TTime(t1.fMilliSec / t2.fMilliSec); }
0089 
0090 inline Bool_t operator== (const TTime &t1, const TTime &t2)
0091    { return t1.fMilliSec == t2.fMilliSec; }
0092 inline Bool_t operator!= (const TTime &t1, const TTime &t2)
0093    { return t1.fMilliSec != t2.fMilliSec; }
0094 inline Bool_t operator< (const TTime &t1, const TTime &t2)
0095    { return t1.fMilliSec < t2.fMilliSec; }
0096 inline Bool_t operator<= (const TTime &t1, const TTime &t2)
0097    { return t1.fMilliSec <= t2.fMilliSec; }
0098 inline Bool_t operator> (const TTime &t1, const TTime &t2)
0099    { return t1.fMilliSec > t2.fMilliSec; }
0100 inline Bool_t operator>= (const TTime &t1, const TTime &t2)
0101    { return t1.fMilliSec >= t2.fMilliSec; }
0102 
0103 #endif