| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

TimePoint.h

Go to the documentation of this file.
00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/TimePoint.h,v 1.8 2006/12/10 20:29:17 leggett Exp $
00002 #ifndef GAUDIKERNEL_TIMEPOINT_H
00003 #define GAUDIKERNEL_TIMEPOINT_H
00004 
00005 // Include files
00006 #include "GaudiKernel/ITime.h"
00007 #include "GaudiKernel/StreamBuffer.h"
00008 #include <time.h>
00009 
00010 
00017 class TimePoint: public ITime
00018 {
00019 public:
00021   TimePoint() : m_time( time(0) * (longlong)1.0e+9 ) { }
00022   TimePoint( const ITime::AbsoluteTime& atime ) : m_time( atime ) { }  
00023   TimePoint( const ITime& itime ) : m_time( itime.absoluteTime() ) { }
00025   ~TimePoint(){ }
00026   
00027  public:  
00029   ITime::AbsoluteTime  absoluteTime() const { return m_time; }
00030   
00032   ITime::DimensionedTime seconds() const { return (DimensionedTime) ( absoluteTime() / 1.0e+9 ) ; }      
00033   
00035   ITime::DimensionedTime minutes() const { return seconds() / 60.0 ; }     
00036   
00038   ITime::DimensionedTime hours() const { return minutes() / 60.0 ; }
00039   
00041   ITime::DimensionedTime days() const { return hours  () / 24.0 ; }
00042   
00044   unsigned long msb() const { return (unsigned long)(m_time >> 32);}
00046   unsigned long lsb() const { return (unsigned long)((m_time << 32) >> 32);}
00047 
00049   bool operator==( const ITime& T ) const { return absoluteTime()==T.absoluteTime(); }
00050   bool operator!=( const ITime& T ) const { return absoluteTime()!=T.absoluteTime(); }
00051   bool operator<=( const ITime& T ) const { return absoluteTime()<=T.absoluteTime(); }
00052   bool operator>=( const ITime& T ) const { return absoluteTime()>=T.absoluteTime(); }
00053   bool operator< ( const ITime& T ) const { return absoluteTime()< T.absoluteTime(); }
00054   bool operator> ( const ITime& T ) const { return absoluteTime()> T.absoluteTime(); }
00055   
00057   ITime& operator+=( const ITime& T );
00058 
00060   ITime& operator-=( const ITime& T );
00061   
00063   virtual std::ostream&  printOut( std::ostream& ) const;  
00064     
00065  private:
00066   
00067   ITime::AbsoluteTime  m_time;    
00068   friend StreamBuffer& operator>>(StreamBuffer& s, TimePoint& t);
00069 };
00070 
00071 
00072   static const  TimePoint time_absolutepast((longlong)LONGLONG_MIN);
00073   static const  TimePoint time_absolutefuture((longlong)LONGLONG_MAX);
00074 
00075 inline ITime& TimePoint::operator+=( const ITime& T ) 
00076 { 
00077   m_time +=T.absoluteTime(); 
00078   m_time = ( m_time > time_absolutefuture.absoluteTime() )  ? time_absolutefuture.absoluteTime() : m_time ; 
00079   m_time = ( m_time < time_absolutepast  .absoluteTime() )  ? time_absolutepast  .absoluteTime() : m_time ; 
00080   return *this; 
00081 } 
00082 
00083 
00084 inline ITime& TimePoint::operator-=( const ITime& T ) 
00085 { 
00086   m_time -= T.absoluteTime(); 
00087   m_time  = ( m_time > time_absolutefuture.absoluteTime() )  ? time_absolutefuture.absoluteTime() : m_time ; 
00088   m_time  = ( m_time < time_absolutepast  .absoluteTime() )  ? time_absolutepast  .absoluteTime() : m_time ; 
00089   return *this; 
00090 } 
00091 
00092 inline std::ostream&  TimePoint::printOut( std::ostream& os ) const  {
00093   return os << "Time is " << seconds() << "[s]";
00094 }
00095 
00096 inline MsgStream& operator<<(MsgStream& os, const TimePoint& t)  {
00097   if ( os.isActive() ) t.printOut(os.stream());
00098   return os;
00099 }
00100 
00101 // Output serialization
00102 inline StreamBuffer& operator<<(StreamBuffer& s, const TimePoint& t)  {
00103   return s << t.absoluteTime();
00104 }
00105 // Input serialization
00106 inline StreamBuffer& operator>>(StreamBuffer& s, TimePoint& t)  {
00107   return s >> t.m_time;
00108 }
00109 #endif   //   GAUDIKERNEL_TIMEPOINT_H
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:56:58 2011 for GaudiKernel by doxygen 1.4.7