Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TimePoint.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiKernel/GaudiKernel/TimePoint.h,v 1.1.1.1 2001/04/18 18:14:18 tlindner Exp $
00002 #ifndef GAUDIKERNEL_TIMEPOINT_H
00003 #define GAUDIKERNEL_TIMEPOINT_H
00004 
00005 // Include files
00006 #include "GaudiKernel/ITime.h"
00007 #include <time.h>
00008 
00009 
00016 class TimePoint: public ITime
00017 {
00018 public:
00020   TimePoint() : m_time( time(0) * (longlong)1.0e+9 ) { }
00021   TimePoint( const ITime::AbsoluteTime& atime ) : m_time( atime ) { }  
00022   TimePoint( const ITime& itime ) : m_time( itime.absoluteTime() ) { }
00024   ~TimePoint(){ }
00025   
00026  public:  
00028   ITime::AbsoluteTime  absoluteTime() const { return m_time; }
00029   
00031   ITime::DimensionedTime seconds() const { return (DimensionedTime) ( absoluteTime() / 1.0e+9 ) ; }      
00032   
00034   ITime::DimensionedTime minutes() const { return seconds() / 60.0 ; }     
00035   
00037   ITime::DimensionedTime hours() const { return minutes() / 60.0 ; }
00038   
00040   ITime::DimensionedTime days() const { return hours  () / 24.0 ; }
00041   
00043   unsigned long msb() const { return m_time >> 32;}
00045   unsigned long lsb() const { return (m_time << 32) >> 32;}
00046 
00048   bool operator==( const ITime& T ) const { return absoluteTime()==T.absoluteTime(); }
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   
00056   ITime& operator+=( const ITime& T );
00057 
00059   ITime& operator-=( const ITime& T );
00060   
00062   virtual std::ostream&  printOut( std::ostream& ) const;  
00063     
00064  private:
00065   
00066   ITime::AbsoluteTime  m_time;    
00067 };
00068 
00069 
00070   static const  TimePoint time_absolutepast((longlong)LONGLONG_MIN);
00071   static const  TimePoint time_absolutefuture((longlong)LONGLONG_MAX);
00072 
00073 inline ITime& TimePoint::operator+=( const ITime& T ) 
00074 { 
00075   m_time +=T.absoluteTime(); 
00076   m_time = ( m_time > time_absolutefuture.absoluteTime() )  ? time_absolutefuture.absoluteTime() : m_time ; 
00077   m_time = ( m_time < time_absolutepast  .absoluteTime() )  ? time_absolutepast  .absoluteTime() : m_time ; 
00078   return *this; 
00079 } 
00080 
00081 
00082 inline ITime& TimePoint::operator-=( const ITime& T ) 
00083 { 
00084   m_time -= T.absoluteTime(); 
00085   m_time  = ( m_time > time_absolutefuture.absoluteTime() )  ? time_absolutefuture.absoluteTime() : m_time ; 
00086   m_time  = ( m_time < time_absolutepast  .absoluteTime() )  ? time_absolutepast  .absoluteTime() : m_time ; 
00087   return *this; 
00088 } 
00089 
00090 inline std::ostream&  TimePoint::printOut( std::ostream& os ) const
00091 {
00092   return os << "Time is " << seconds() << "[s]";
00093 };
00094 
00095 #endif   //   GAUDIKERNEL_TIMEPOINT_H

Generated at Wed Nov 21 12:22:05 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000