00001 #ifndef BDBDURATION_HH 00002 #define BDBDURATION_HH 00003 00004 //----------------------------------------------------------------------------- 00005 // 00006 // File and Version Information: 00007 // $Id: BdbDuration.hh,v 1.4 2004/08/06 05:48:02 bartoldu Exp $ 00008 // 00009 // Description: 00010 // Class BdbDuration. 00011 // This is a time duration class. 00012 // Note that a time duration is positive definite, thus 00013 // d = abs( d1 - d2 ), 00014 // and 00015 // d = abs( t1 - t2 ). 00016 // 00017 // Environment: 00018 // Software developed for the BaBar Detector at the SLAC B-Factory. 00019 // 00020 // Author List: 00021 // J. Ohnemus Original Author 00022 // 00023 // Copyright Information: 00024 // Copyright (C) 1994, 1995 Lawrence Berkeley Laboratory 00025 // 00026 //----------------------------------------------------------------------------- 00027 00028 //----------------- 00029 // BaBar Headers -- 00030 //----------------- 00031 #include "BaBar/BaBarODMGTypes.h" 00032 00033 //------------- 00034 // C Headers -- 00035 //------------- 00036 extern "C" { 00037 } 00038 00039 //--------------- 00040 // C++ Headers -- 00041 //--------------- 00042 #include <iostream> 00043 00044 //---------------------- 00045 // Base Class Headers -- 00046 //---------------------- 00047 00048 //------------------------------- 00049 // Collaborating Class Headers -- 00050 //------------------------------- 00051 #include "BdbTime/BdbTimeConst.hh" 00052 00053 //------------------------------------ 00054 // Collaborating Class Declarations -- 00055 //------------------------------------ 00056 00057 // --------------------- 00058 // -- Class Interface -- 00059 // --------------------- 00060 00061 class BdbDuration { 00062 00063 //-------------------- 00064 // Instance Members -- 00065 //-------------------- 00066 00067 public: 00068 00069 // Constructors 00070 BdbDuration( ); // default 00071 00072 BdbDuration( const BdbDuration & d ); // copy 00073 00074 BdbDuration( d_ULong sec, d_ULong nsec = 0 ); 00075 00076 00077 // Destructor 00078 ~BdbDuration( ) { } 00079 00080 00081 // Operators 00082 BdbDuration operator - ( const BdbDuration & d1 ) const; 00083 00084 BdbDuration operator + ( const BdbDuration & d1 ) const; 00085 00086 BdbDuration & operator = ( const BdbDuration & d1 ); 00087 00088 BdbDuration & operator += ( const BdbDuration & d1 ); 00089 00090 bool operator == ( const BdbDuration & d ) const 00091 { 00092 return ( _sec == d._sec && _nsec == d._nsec ); 00093 } 00094 00095 bool operator != ( const BdbDuration & d ) const 00096 { 00097 return !( *this == d ); 00098 } 00099 00100 bool operator < ( const BdbDuration & d ) const 00101 { 00102 return ( _sec < d._sec ) || ( _sec == d._sec && _nsec < d._nsec ); 00103 } 00104 00105 bool operator <= ( const BdbDuration & d ) const 00106 { 00107 return ( _sec < d._sec ) || ( _sec == d._sec && _nsec <= d._nsec ); 00108 } 00109 00110 bool operator > ( const BdbDuration & d ) const 00111 { 00112 return !( *this <= d ); 00113 } 00114 00115 bool operator >= ( const BdbDuration & d ) const 00116 { 00117 return !( *this < d ); 00118 } 00119 00120 // Selectors 00121 d_ULong getSec ( ) const { return _sec; } 00122 d_ULong getNsec( ) const { return _nsec; } 00123 00124 // Friends 00125 friend std::ostream & operator << ( std::ostream & os, const BdbDuration & d ); 00126 00127 private: 00128 00129 // Data members 00130 d_ULong _sec; // number of seconds 00131 d_ULong _nsec; // number of nano seconds 00132 00133 }; 00134 00135 #endif
1.3-rc3