00001 // File and Version Information: 00002 // $Id: CdbBdbSIncrementCollectionP.cc,v 1.5 2004/08/06 05:54:24 bartoldu Exp $ 00003 00004 /// The implementation file for the CdbBdbSIncrementCollection class 00005 /** 00006 * @see CdbBdbSIncrementCollection 00007 */ 00008 00009 #include "BaBar/BaBar.hh" 00010 00011 #include "CdbBdbShared/CdbBdbSIncrementCollection.hh" 00012 00013 #include <iostream> 00014 using std::cout; 00015 using std::endl; 00016 00017 CdbBdbSIncrementCollection::CdbBdbSIncrementCollection( ) 00018 { 00019 _increments.resize( 1 ); 00020 _increments[0] = CdbBdbSIncrement( BdbTime::minusInfinity, 00021 BdbTime::plusInfinity ); 00022 } 00023 00024 CdbBdbSIncrementCollection::CdbBdbSIncrementCollection( const CdbBdbSIncrementCollection& theCollection ) 00025 { 00026 _increments = theCollection._increments; 00027 } 00028 00029 CdbBdbSIncrementCollection::~CdbBdbSIncrementCollection( ) 00030 { } 00031 00032 CdbBdbSIncrementCollection& 00033 CdbBdbSIncrementCollection::operator=( const CdbBdbSIncrementCollection& theCollection ) 00034 { 00035 if( this != &theCollection ) { 00036 _increments = theCollection._increments; 00037 } 00038 return *this; 00039 } 00040 00041 d_UShort 00042 CdbBdbSIncrementCollection::numIncrements( ) const 00043 { 00044 return (d_UShort)_increments.size( ); 00045 } 00046 00047 CdbStatus 00048 CdbBdbSIncrementCollection::increment( d_UShort theNumber, 00049 CdbBdbSIncrement& theIncrement ) const 00050 { 00051 if( theNumber >= numIncrements( )) return CdbStatus::NotFound; 00052 theIncrement = _increments[theNumber]; 00053 return CdbStatus::Success; 00054 } 00055 00056 CdbStatus 00057 CdbBdbSIncrementCollection::createIncrement( const BdbTime& theSplitTime ) 00058 { 00059 const char* errorStr = "CdbBdbSIncrementCollection::createIncrement() - ERROR."; 00060 00061 CdbStatus result = CdbStatus::Error; 00062 do { 00063 00064 // Verify parameters 00065 00066 if(( BdbTime::minusInfinity == theSplitTime ) || ( BdbTime::plusInfinity == theSplitTime )) { 00067 cout << errorStr << endl 00068 << " Illegal value of the split time passed to the procedure." << endl 00069 << " Thsi time should not be neither -Infinity nor +Infinity." << endl 00070 << " PASSED SPLIT TIME: " << theSplitTime << endl; 00071 break; 00072 } 00073 00074 d_ULong last = numIncrements( ) - 1; 00075 if( last >= 65535 ) { 00076 cout << errorStr << endl 00077 << " Internal overflow of the total number of incerements." << endl 00078 << " The biggest increment should not exceed 65535." << endl; 00079 break; 00080 } 00081 00082 if( theSplitTime <= _increments[last].begin ) { 00083 cout << errorStr << endl 00084 << " Illegal value of the split time passed to the procedure." << endl 00085 << " This time should not be less or equal to the begin time of" << endl 00086 << " the most recently known increment in the collection." << endl 00087 << " PASSED SPLIT TIME: " << theSplitTime << endl 00088 << " BEGIN TIME: " << _increments[last].begin << endl; 00089 break; 00090 } 00091 00092 // Proceed with the creation 00093 00094 _increments.resize( 1 + _increments.size( )); 00095 00096 _increments[last].end = theSplitTime; 00097 _increments[last+1] = CdbBdbSIncrement( theSplitTime, 00098 BdbTime::plusInfinity ); 00099 00100 // Done 00101 00102 result = CdbStatus::Success; 00103 00104 } while( false ); 00105 00106 return result; 00107 } 00108 00109 ///////////////// 00110 // End Of File // 00111 /////////////////
1.3-rc3