00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BaBar/BaBar.hh"
00010
00011 #include "CdbBdbShared/CdbBdbSPartitionBaseP.hh"
00012
00013 #include <assert.h>
00014 #include <iostream>
00015 using std::cout;
00016 using std::endl;
00017 using std::ostream;
00018
00019 CdbBdbSPartitionBaseP::CdbBdbSPartitionBaseP( d_UShort theId,
00020 const char* theDescription,
00021 const BdbTime& theCreationTime,
00022 const CdbBdbSCell& theCell ) :
00023 CdbBdbSCollectionElementP( "<none>",
00024 theId ),
00025 _description(theDescription),
00026 _created(theCreationTime),
00027 _cell(theCell)
00028 {
00029 assert( 0 != theDescription );
00030 assert(( BdbTime::minusInfinity != theCreationTime ) && ( BdbTime::plusInfinity != theCreationTime ));
00031 }
00032
00033 CdbBdbSPartitionBaseP::~CdbBdbSPartitionBaseP( )
00034 { }
00035
00036 bool
00037 CdbBdbSPartitionBaseP::isClosed( ) const
00038 {
00039 return BdbTime::plusInfinity != _cell.endInsertion;
00040 }
00041 ooString(32)
00042 CdbBdbSPartitionBaseP::description( ) const
00043 {
00044 return _description;
00045 }
00046
00047 BdbTime
00048 CdbBdbSPartitionBaseP::created( ) const
00049 {
00050 return _created;
00051 }
00052
00053 CdbBdbSCell
00054 CdbBdbSPartitionBaseP::cell( ) const
00055 {
00056 return _cell;
00057 }
00058
00059 CdbStatus
00060 CdbBdbSPartitionBaseP::closeCell( const BdbTime& theTime )
00061 {
00062 const char* errorStr = "CdbBdbSPartitionBaseP::closeCell( ) - ERROR.";
00063
00064 ooUpdate( );
00065
00066 CdbStatus result = CdbStatus::Error;
00067 do {
00068
00069
00070
00071 if(( BdbTime::minusInfinity == theTime ) ||
00072 ( BdbTime::plusInfinity == theTime )) {
00073 cout << errorStr << endl
00074 << " Invalid partition closure time passsed to the procedure." << endl
00075 << " This time can't be neither -Infinity nor the -Infinity." << endl;
00076 break;
00077 }
00078 if( BdbTime::plusInfinity != _cell.endInsertion ) {
00079 cout << errorStr << endl
00080 << " This is an attempt to close a partition, which is already closed." << endl;
00081 break;
00082 }
00083 if( theTime <= _cell.beginInsertion ) {
00084 cout << errorStr << endl
00085 << " The passed partition closure time is less or equal to the begin time" << endl
00086 << " of the current partition." << endl
00087 << " PASSED TIEME: " << theTime << endl
00088 << " BEGIN INSERTION TIME: " << _cell.beginInsertion;
00089 break;
00090 }
00091
00092
00093
00094 _cell.close( theTime );
00095
00096 result = CdbStatus::Success;
00097
00098 } while( false );
00099
00100 return result;
00101 }
00102
00103 void
00104 CdbBdbSPartitionBaseP::dump( ostream& o ) const
00105 {
00106 o << " ID: " << id( ) << endl
00107 << " DESCRIPTION: " << _description.head( ) << endl
00108 << " CREATED: " << _created << endl
00109 << " IS CLOSED: " << ( isClosed( ) ? "Yes" : "No" ) << endl
00110 << " VALIDITY.BEGIN: " << _cell.beginValidity << endl
00111 << " END: " << _cell.endValidity << endl
00112 << "INSERTION.BEGIN: " << _cell.beginInsertion << endl
00113 << " INSERTION.END: " << _cell.endInsertion << endl;
00114 }
00115
00116
00117
00118