00001 #ifndef CDBBDBSHARED_ORIGIN_P_HH 00002 #define CDBBDBSHARED_ORIGIN_P_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbSOriginP.ddl,v 1.10 2004/08/06 05:54:25 bartoldu Exp $ 00006 00007 #include "BdbUtil/Bdb.hh" 00008 00009 #include "BdbTime/BdbTime.hh" 00010 00011 #include "CdbBdbShared/CdbBdbSCollectionElementP.hh" 00012 00013 #include <iostream> 00014 00015 /// Persistent "origin" class 00016 /** 00017 * Origins represent integral databases of the distributed Condition/DB. 00018 * 00019 * NOTE: Origins themselves are not databases, they are just descriptors 00020 * of these databases. 00021 */ 00022 class CdbBdbSOriginP : public CdbBdbSCollectionElementP { 00023 00024 public: 00025 00026 /// The supported origin types 00027 00028 typedef enum { FIRST = 0, 00029 MASTER = FIRST, 00030 SLAVE, 00031 REPLICA, // We leave this item even though it's an obsolete because removin 00032 // this element would affect existing persistent origins (instances 00033 // of the current class). 00034 TEST, 00035 LAST = TEST 00036 } OriginType; 00037 00038 /// The names of the above defined origin types 00039 00040 static const char* OriginName[]; 00041 00042 /// Predefined (reserved) origin identifiers (total of 256) 00043 00044 enum { FIRST_ID = 0, 00045 MASTER_ID = FIRST_ID, 00046 REPLICA_ID, // We leave this item even though it's an obsolete because removin 00047 // this element would affect existing persistent origins (instances 00048 // of the current class). 00049 TEST_ID, 00050 LAST_ID = 255 00051 }; 00052 00053 private: 00054 00055 /// Default constructor (NOT IMPLEMENTED)) 00056 /** 00057 * Also see comments about the special constructor defined above. 00058 */ 00059 CdbBdbSOriginP( ); 00060 00061 public: 00062 00063 /// Normal constructor 00064 /** 00065 * WARNING: Inappropriate values of the parameters will cause the crash 00066 * of the constructor to avoid creating disformed persistent 00067 * data structures. 00068 */ 00069 CdbBdbSOriginP( const char* theName, /**< the name of the origin */ 00070 d_UShort theId, /**< the identifier of the origin */ 00071 OriginType theType, /**< the type from the above defined enumerated type */ 00072 const BdbTime& theCreationTime, /**< the time when the origin is supposed to be created */ 00073 const char* theDescription, /**< the description of the origin */ 00074 const char* theDbIdRange /**< the name of the range */ 00075 ); 00076 00077 /// Destructor 00078 /** 00079 */ 00080 virtual ~CdbBdbSOriginP( ); 00081 00082 // Accessors 00083 00084 OriginType type ( ) const; 00085 BdbTime created ( ) const; 00086 ooString(32) description( ) const; 00087 ooString(32) dbidrange ( ) const; 00088 00089 /// Convert specified name to the type identifier 00090 /** 00091 * The passed name must look in the same way as the corressponding value 00092 * of the enumerated type. For example MASTER corresponds to string "MASTER". 00093 * This is the case sensitive translation. 00094 * 00095 * Return CdbStatus::Success if specified name is valid. 00096 */ 00097 static CdbStatus name2type( const char* theName, /**< the name of the type */ 00098 OriginType& theType /**< the value to be set up */ 00099 ); 00100 00101 /// Convert specified type identifier into the name 00102 /** 00103 * Will return 0 if specified type does not exist. Will return a pointer 00104 * onto a static string in case of success. 00105 */ 00106 static const char* type2name( OriginType theType /**< the type identifier */ 00107 ); 00108 00109 /// Check if specified identifier is a reserved one 00110 /** 00111 */ 00112 static bool isReservedId( d_UShort theId /**< the identifier of the origin */ 00113 ); 00114 00115 /// Dump the contents of the origin 00116 /** 00117 */ 00118 void dump( std::ostream& o ) const; 00119 00120 private: 00121 00122 // Data members 00123 00124 OriginType _type; 00125 BdbTime _created; 00126 ooString(32) _description; 00127 ooString(32) _dbidrange; 00128 }; 00129 00130 #endif /* CDBBDBSHARED_ORIGIN_P_HH */
1.3-rc3