00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BaBar/BaBar.hh"
00010
00011 #include "CdbBdbShared/CdbBdbSOriginP.hh"
00012
00013 #include <string.h>
00014 #include <assert.h>
00015 using std::endl;
00016 using std::ostream;
00017
00018 const char*
00019 CdbBdbSOriginP::OriginName[] = { "MASTER",
00020 "SLAVE",
00021 "REPLICA",
00022 "TEST" };
00023
00024 CdbBdbSOriginP::CdbBdbSOriginP( const char* theName,
00025 d_UShort theId,
00026 OriginType theType,
00027 const BdbTime& theCreationTime,
00028 const char* theDescription,
00029 const char* theDbIdRange ) :
00030 CdbBdbSCollectionElementP( theName,
00031 theId ),
00032 _type(theType),
00033 _created(theCreationTime),
00034 _description(theDescription),
00035 _dbidrange(theDbIdRange)
00036 {
00037 assert(( theType >= FIRST ) && ( theType <= LAST ));
00038 assert(( BdbTime::minusInfinity != theCreationTime ) && ( BdbTime::plusInfinity != theCreationTime ));
00039
00040
00041
00042 assert( 0 != theDescription );
00043 assert( 0 != theDbIdRange );
00044 }
00045
00046 CdbBdbSOriginP::~CdbBdbSOriginP( )
00047 { }
00048
00049 CdbBdbSOriginP::OriginType
00050 CdbBdbSOriginP::type( ) const
00051 {
00052 return _type;
00053 }
00054
00055 BdbTime
00056 CdbBdbSOriginP::created( ) const
00057 {
00058 return _created;
00059 }
00060
00061 ooString(32)
00062 CdbBdbSOriginP::description( ) const
00063 {
00064 return _description;
00065 }
00066
00067 ooString(32)
00068 CdbBdbSOriginP::dbidrange( ) const
00069 {
00070 return _dbidrange;
00071 }
00072
00073 CdbStatus
00074 CdbBdbSOriginP::name2type( const char* theName,
00075 OriginType& theType )
00076 {
00077 if( 0 == strcmp( OriginName[MASTER], theName )) theType = MASTER;
00078 else if( 0 == strcmp( OriginName[SLAVE], theName )) theType = SLAVE;
00079 else if( 0 == strcmp( OriginName[REPLICA], theName )) theType = REPLICA;
00080 else if( 0 == strcmp( OriginName[TEST], theName )) theType = TEST;
00081 else
00082 return CdbStatus::NotFound;
00083
00084 return CdbStatus::Success;
00085 }
00086
00087 const char*
00088 CdbBdbSOriginP::type2name( OriginType theType )
00089 {
00090 const char* result = 0;
00091 if(( theType >= FIRST ) && ( theType <= LAST )) result = OriginName[theType];
00092 return result;
00093 }
00094
00095 bool
00096 CdbBdbSOriginP::isReservedId( d_UShort theId )
00097 {
00098 return theId <= LAST_ID;
00099 }
00100
00101 void
00102 CdbBdbSOriginP::dump( ostream& o ) const
00103 {
00104 o << " NAME: " << name( ).head( ) << endl
00105 << " ID: " << id( ) << endl
00106 << " TYPE: " << type2name( _type ) << endl
00107 << " CREATED: " << _created << endl
00108 << "DESCRIPTION: " << _description.head( ) << endl
00109 << " DBID RANGE: " << _dbidrange.head( ) << endl;
00110 }
00111
00112
00113
00114