00001 #ifndef CDBBDBSHARED_PARTITION_P_HH 00002 #define CDBBDBSHARED_PARTITION_P_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbSPartitionP.ddl,v 1.8 2004/08/06 05:54:25 bartoldu Exp $ 00006 00007 #include "CdbBdbShared/CdbBdbSPartitionBaseP.hh" 00008 #include "CdbBdbShared/CdbBdbSPartitionListenerP.hh" 00009 #include "CdbBdbShared/CdbBdbSIncrementCollection.hh" 00010 00011 /// Persistent partition class 00012 /** 00013 * This is an actual implementation of the partition class to be stored 00014 * in the corresponding persistent "PartitionLayout" collection. 00015 */ 00016 class CdbBdbSPartitionP : public CdbBdbSPartitionBaseP { 00017 00018 private: 00019 00020 /// Default constructor (NOT IMPLEMENTED)) 00021 /** 00022 * Also see comments about the special constructor defined above. 00023 */ 00024 CdbBdbSPartitionP( ); 00025 00026 public: 00027 00028 /// Normal constructor 00029 /** 00030 * The partition listener reference is an optional parameter, which is only 00031 * passed when there is a listener. 00032 */ 00033 CdbBdbSPartitionP( d_UShort theId, /**< the identifier of the partition */ 00034 const char* theDescription, /**< the description of the partition */ 00035 const BdbTime& theCreationTime, /**< the time when the partition is supposed to be created */ 00036 const CdbBdbSCell& theCell, /**< the cell (area) occupied by the partition in 2-dimension space */ 00037 d_UShort theOriginId, /**< the owner of this partition */ 00038 const BdbRef(CdbBdbSPartitionListenerP)& theListenerRef /**< this optional listener will be informed about any changes at partition's state */ 00039 ); 00040 00041 /// Destructor 00042 /** 00043 */ 00044 virtual ~CdbBdbSPartitionP( ); 00045 00046 /// Get the owner of the partition 00047 /** 00048 */ 00049 d_UShort originId( ) const; 00050 00051 /// Get the current status of the partition 00052 /** 00053 * One the partition gets created the corresponding database files and containers 00054 * meant to store the actual condition objects and metadata are not created. 00055 * In other words, the partition gets into "non-instantiated" state immediatelly 00056 * upon its creation. At this point the partition is not usable for storinig new 00057 * condition objects into it or fetching them from it. 00058 * To get into "instantiated" state a separate method should be called. 00059 * 00060 * The main reason to separate partition creation from its instantiation 00061 * is that partition always get created at the MASTER database, but some 00062 * of these partitions may be defined to belong to some SLAVE database. 00063 * Therefore, the data structures supporting member conditions have to be 00064 * created at the SLAVE rather than at the MASTER. 00065 * 00066 * @see CdbBdbSPartitionP::instantiate() 00067 */ 00068 bool isInstantiated( ) const; 00069 00070 /// Get the partition modification time 00071 /** 00072 * Partition modification (INSERTION) time is meant to indicate when was the last time 00073 * when any member condition of this partition was most recently updated. 00074 */ 00075 BdbTime modified( ) const; 00076 00077 /// Update the partition modification time 00078 /** 00079 * The current modification specified time must be the same or bigger (newer) than the one 00080 * stored by the partition. 00081 */ 00082 CdbStatus update( const BdbTime& theModificationTime ); 00083 00084 /// Close the partition at specified point of the INSERTION timeline 00085 /** 00086 * The specified time must be strictly greater than the "bottom" insertion time 00087 * of the partition. 00088 * It's also required that partition be instantiated before closing it. 00089 * 00090 * @see CdbBdbSPartitionP::isInstantiated() 00091 */ 00092 CdbStatus close( const BdbTime& theTime ); 00093 00094 /// Instantiate supporting data structures 00095 /** 00096 * This method will only be able to do its job at the target database (the one 00097 * (where the partition belongs to). 00098 * 00099 * An optional "reinstantiateFlag" is only meant to be used in special cases 00100 * to reset existing conditions for an existing and "open" partition as if 00101 * this partition were being created from a scratch. The flag has no effect 00102 * for non-existing partitions. 00103 * 00104 * @see CdbBdbSPartitionP::isInstantiated() 00105 */ 00106 CdbStatus instantiate( bool reinstantiateFlag = false ); 00107 00108 /// Get the total number of "increments" 00109 /** 00110 */ 00111 d_UShort numIncrements( ) const; 00112 00113 /// Get the specified "increment" 00114 /** 00115 * The method will return CdbStatus::NotFound if the index is not 00116 * in a valid range. 00117 */ 00118 CdbStatus increment( d_UShort theNumber, /**< the number of the increment in question */ 00119 CdbBdbSIncrement& theIncrement /**< the value of the increment to be set up */ 00120 ) const; 00121 00122 /// Create new "increment" 00123 /** 00124 * The method if successfull will increase the number of increments by one. 00125 */ 00126 CdbStatus createIncrement( const BdbTime& theSplitTime /**< the split time for a new incrementhe increment */ 00127 ); 00128 00129 /// Dump the contents of the object 00130 /** 00131 */ 00132 virtual void dump( std::ostream& o ) const; 00133 00134 private: 00135 00136 /// Check if the local origin matches this partition's origin 00137 /** 00138 * Certain operations iwth partitions are only available at the database 00139 * of these partitions' origins. 00140 * 00141 * The method will return CdbStatus::Success if there is the origin match. 00142 */ 00143 CdbStatus matchOrigin( ) const; 00144 00145 private: 00146 00147 BdbRef(CdbBdbSPartitionListenerP) _listenerRef; 00148 00149 // This is an embedded class 00150 00151 CdbBdbSIncrementCollection _increments; 00152 00153 // Partition modification time is meant to indicate when was the last time 00154 // when any member condition of this partition was most recently updated. 00155 00156 BdbTime _modified; 00157 00158 // Other data members 00159 00160 d_Boolean _isInstantiated; // the current status of the partition 00161 d_UShort _originId; // the owner of the partition 00162 }; 00163 00164 #endif /* CDBBDBSHARED_PARTITION_P_HH */
1.3-rc3