#ifndef VEGA_VGPSTime #define VEGA_VGPSTime //*-- Modified : v0.48 01/06/00 by D. Buskulic (parts borrowed from DMT/John Zweizig) //*-- Modified : v0.42 02/09/99 by D. Buskulic //*-- Author : Damir Buskulic 20/05/99 ////////////////////////////////////////////////////////////////////////// // // // VGPSTime // // // // Time defined by GPS standard // // // ////////////////////////////////////////////////////////////////////////// #include #include #include "Rtypes.h" #include "TObject.h" class VGPSTime : public TObject { private: UInt_t mSec; // seconds UInt_t mNsec; // nano-seconds public : VGPSTime() {} VGPSTime(Int_t secVal, Int_t nsecVal):mSec(secVal),mNsec(nsecVal) {} UInt_t GetSec() {return mSec;} UInt_t GetNsec() {return mNsec;} static const Text_t* ExpressTime(Double_t gpstime, Option_t* fmtopt="GPS", Int_t leapS=0, Int_t local=0); static const Text_t* ExpandFormat(const char* fmtopt); void SetSec(UInt_t s) {mSec = s;} void SetNsec(UInt_t n) {mNsec = n;} void SetTimeD(Double_t time) {mSec = (UInt_t)(floor(time)); mNsec = (UInt_t)((time-mSec)*1e9);} Double_t GetTimeD() {return mSec+mNsec*1e-9;} VGPSTime& operator =(const VGPSTime& gpst); VGPSTime& operator =(double& gpstd); VGPSTime operator +=(double interval); VGPSTime operator -=(double interval); bool operator!(void) const; bool operator==(const VGPSTime& rhs) const; bool operator!=(const VGPSTime& rhs) const; bool operator>=(const VGPSTime& rhs) const; bool operator<=(const VGPSTime& rhs) const; bool operator>(const VGPSTime& rhs) const; bool operator<(const VGPSTime& rhs) const; friend VGPSTime operator +(const VGPSTime& gpst, double interval); friend VGPSTime operator +(double interval, const VGPSTime& gpst); friend VGPSTime operator -(const VGPSTime& gpst, double interval); friend VGPSTime operator -(double interval, const VGPSTime& gpst); ClassDef(VGPSTime,1) // Time as defined by GPS standard }; //========================= Inlines =========================================== //---------------------------------------- Compare to zero inline bool VGPSTime::operator!(void) const { return (!mSec && !mNsec);} //---------------------------------------- Compare (equal, greater, less) inline bool VGPSTime::operator==(const VGPSTime& rhs) const { return (mSec == rhs.mSec && mNsec == rhs.mNsec);} inline bool VGPSTime::operator>(const VGPSTime& rhs) const { return (mSec > rhs.mSec || (mSec == rhs.mSec && mNsec > rhs.mNsec));} inline bool VGPSTime::operator<(const VGPSTime& rhs) const { return (mSec < rhs.mSec || (mSec == rhs.mSec && mNsec < rhs.mNsec));} //---------------------------------------- Compare (derived from above cases) inline bool VGPSTime::operator!=(const VGPSTime& rhs) const { return !operator==(rhs);} inline bool VGPSTime::operator>=(const VGPSTime& rhs) const { return !(operator<(rhs));} inline bool VGPSTime::operator<=(const VGPSTime& rhs) const { return !(operator>(rhs));} #endif