00001 #ifndef CDB_VIEW_HH 00002 #define CDB_VIEW_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbView.hh,v 1.14 2003/08/13 23:34:13 gapon Exp $ 00006 00007 #include "CdbBase/CdbId.hh" 00008 00009 #include "CdbBase/CdbStateControl.hh" 00010 #include "CdbBase/CdbHistoryProvider.hh" 00011 #include "CdbBase/CdbFolderLocator.hh" 00012 #include "CdbBase/CdbCloneable.hh" 00013 00014 #include "CdbBase/CdbCPtrBase.hh" 00015 #include "CdbBase/CdbViewPtrFwd.hh" 00016 #include "CdbBase/CdbDatabasePtrFwd.hh" 00017 00018 #include "CdbBase/CdbRevisionPolicy.hh" 00019 #include "CdbBase/CdbConfigElement.hh" 00020 #include "CdbBase/CdbItr.hh" 00021 00022 #include <string> 00023 00024 class CdbStateId; 00025 00026 /// The transient representation for the persistent view. 00027 /** 00028 * Note, that this is an abstract class specifying the interface to the view. 00029 * It also maintains the general status of the view object as it's seen to its 00030 * clients through the API. 00031 * 00032 * This class also includes the CdbStateControl, CdbFolderLocator 00033 * CdbHistoryProvider and CdbCloneable interfaces. 00034 * 00035 * @see CdbStateControl 00036 * @see CdbFolderLocator 00037 * @see CdbHistoryProvider 00038 * @see CdbCloneable 00039 * @see CdbRevisionPolicy 00040 */ 00041 class CdbView : public CdbStateControl, 00042 public CdbHistoryProvider, 00043 public CdbFolderLocator, 00044 protected CdbCloneable< CdbView > { 00045 00046 friend class CdbCPtrBase< CdbView >; 00047 00048 private: 00049 00050 /// The default constructor (NOT IMPLEMENTED) 00051 /** 00052 * Is disabled... 00053 */ 00054 CdbView( ); 00055 00056 protected: 00057 00058 /// The normally used constructor will set the internal parameters 00059 /// of an object. 00060 /** 00061 * Initialize the context of the view with specified set of parameters. This 00062 * will also validate the internal state of the object. 00063 * 00064 * Both pointers should not point to 0 objects. 00065 * 00066 * @see CdbDatabase 00067 * @see CdbDatabasePtr 00068 */ 00069 CdbView( const CdbDatabasePtr& theDatabasePtr, /**< the smart pointer providing a back link to the parent object */ 00070 const char* theName, /**< the name of the view */ 00071 const CdbId& theId /**< the extended identifier of this view */ 00072 ); 00073 00074 /// The copy constructor 00075 /** 00076 * Details... 00077 */ 00078 CdbView( const CdbView& theView ); 00079 00080 /// The destructor. 00081 /** 00082 * Is only available for the derived classes and friends to prevent accidental 00083 * deletion of objects. 00084 */ 00085 virtual ~CdbView( ); 00086 00087 /// The assignment operator 00088 /** 00089 * Details... 00090 */ 00091 CdbView& operator=( const CdbView& theView ); 00092 00093 public: 00094 00095 /// Static locator for a view object 00096 /** 00097 * Locates specified view object and returns a smart pointer to the transient 00098 * object of the current class. This "shortcut" allows to avoid the complicated 00099 * multi-staged process of the object location, which is useless when 00100 * the intermediate objects are not needed. 00101 * 00102 * The last parameter (a pointer to the top-level Cdb singleton) is optional. If 0 is 00103 * passed then a default instance is used. 00104 * 00105 * Note, that if specified object is not found then a smart pointer is initialized 00106 * to point to 0. 00107 * 00108 * @see Cdb 00109 * @see CdbViewPtr 00110 * @see CdbStatus 00111 * 00112 * @return a completion status 00113 */ 00114 static CdbStatus instance( CdbViewPtr& theViewPtr, /**< the smart pointer to be initialized */ 00115 const char* theViewName = 0, /**< the view name */ 00116 const char* theDatabaseName = 0, /**< the database name */ 00117 const char* theImplementationName = 0, /**< the implementation name */ 00118 const char* theTechnologyName = 0 /**< the technology name */ 00119 ); 00120 00121 /// Static locator for a view object 00122 /** 00123 * Unlike the previous method, this one uses extended identifier of a view 00124 * to find the corresponding object. 00125 * 00126 * @see CdbId 00127 */ 00128 static CdbStatus instance( CdbViewPtr& theViewPtr, /**< the smart pointer to be initialized */ 00129 const CdbId& theViewId, /**< the view identifier */ 00130 const char* theDatabaseName = 0, /**< the database name */ 00131 const char* theImplementationName = 0, /**< the implementation name */ 00132 const char* theTechnologyName = 0 /**< the technology name */ 00133 ); 00134 00135 public: 00136 00137 /// Return a smart pointer to the parent object. 00138 /** 00139 * @see CdbDatabase 00140 */ 00141 const CdbDatabasePtr& parent( ) const; 00142 00143 /// Obtain the current name of the view. 00144 /** 00145 * This name is garanteed to be non 0 pointer. 00146 * 00147 * @return a const pointer to the name of the object 00148 */ 00149 const char* name( ) const; 00150 00151 /// Obtain the current identifier of the view. 00152 /** 00153 * It's an extended identifier of the view in the (potentially) distributed 00154 * installation. 00155 * 00156 * @return a const reference to the identifier 00157 */ 00158 const CdbId& id( ) const; 00159 00160 /// Obtain the begin time allowed by the view 00161 /** 00162 * This method is supposed to be implemented by the corresponding subclass. 00163 * 00164 * @return a string with the object's description 00165 */ 00166 virtual BdbTime minValidity( ) const = 0; 00167 00168 /// Obtain the end time allowed by the view 00169 /** 00170 * This method is supposed to be implemented by the corresponding subclass. 00171 * 00172 * @return a string with the object's description 00173 */ 00174 virtual BdbTime maxValidity( ) const = 0; 00175 00176 /// Obtain the creation time of the view 00177 /** 00178 * This method is supposed to be implemented by the corresponding subclass. 00179 * 00180 * @return a string with the object's description 00181 */ 00182 virtual BdbTime created( ) const = 0; 00183 00184 /// Obtain the view description 00185 /** 00186 * This method is supposed to be implemented by the corresponding subclass. 00187 * 00188 * @return a string with the object's description 00189 */ 00190 virtual std::string description( ) const = 0; 00191 00192 /// Check if the view has "default" configuration 00193 /** 00194 * A view may have an optional "default" configuration to be used for conditions not 00195 * having their private configurations. 00196 * 00197 * @return TRUE if there is such configuration 00198 */ 00199 virtual bool hasDefaultConfig( ) const = 0; 00200 00201 /// Get the current status of the view 00202 /** 00203 * The maijor difference of "local" views from others is that their configuration 00204 * can be modified locally (if it's not in "frozen" state and the corresponding 00205 * authorization permits modifications.) 00206 */ 00207 virtual bool isLocal( ) const = 0; 00208 00209 /// Get the current status of the view 00210 /** 00211 * A non-"frozen" view is not stable since its configuration is allowed to be changed 00212 * by the database administration tools. This kind (non-"frozen") views are used 00213 * where the views is being in a transition state. Once it's done the view can be 00214 * turned into the "frozen" state. 00215 */ 00216 virtual bool isFrozen( ) const = 0; 00217 00218 /// Get a "config element" at specified point of validity time from the "default" configuration 00219 /** 00220 * This method is similar to the regular get() method except it will use (if any) 00221 * the so called "default" configuration of the view. 00222 * 00223 * Since "default" configuration is an optional feature of the view then it may 00224 * not exist at a particular view. If this is going to be the case then the method 00225 * will return CdbStatus::NotFound cimpletiuon status. 00226 * 00227 * @see CdbView::hasDefaultConfig() 00228 * @see CdbView::get() 00229 */ 00230 virtual CdbStatus getDefault( const BdbTime& theValidityTime, 00231 CdbConfigElement& theConfigElement 00232 ) const = 0; 00233 00234 /// Set up an iterator of "default config elements" 00235 /** 00236 * @see CdbView::hasDefaultConfig() 00237 * @see CdbView::getDefault() 00238 * @see CdbView::configIterator() 00239 */ 00240 virtual CdbStatus defaultConfigIterator( CdbItr<CdbConfigElement>& theItr 00241 ) const = 0; 00242 00243 /// Get a "config element" for a condition at specified point of validity time 00244 /** 00245 * A full path name (inluding a condition itself) is used to specify 00246 * the corresponding condition. 00247 * 00248 * The method delivers its results through the "config element" 00249 * comprising the found revision policy and its interval of the validity. 00250 * 00251 * Note, that returned policy may prohibit accessing the database for 00252 * specified period of time. 00253 * 00254 * @see CdbConfigElement 00255 * @see CdbRevisionPolicy 00256 * 00257 * @return completion status 00258 */ 00259 virtual CdbStatus get( const char* theName, 00260 const BdbTime& theValidityTime, 00261 CdbConfigElement& theConfigElement 00262 ) const = 0; 00263 00264 /// Set up an iterator of "config elements" for a condition 00265 /** 00266 * The iterator will retirn valid elements for the interval of validity 00267 * covered by the view. 00268 * 00269 * @return completion status 00270 */ 00271 virtual CdbStatus configIterator( const char* theName, 00272 CdbItr<CdbConfigElement>& theItr 00273 ) const = 0; 00274 00275 /// Get current value of the state identifier 00276 /** 00277 * The method delivers a value of the identifier calculated in the scope of 00278 * he view. The only explicit parameter of the method is a point of time in 00279 * the validity dimension, in which the identifier is requested. 00280 * 00281 * The returned identifier will be "invalid" should any problem occures to construct 00282 * (calculate) the identifier. 00283 * 00284 * The method is supposed to be implemented by subclasses. 00285 * 00286 * @see CdbStateId 00287 * 00288 * @return a value of the identifier. 00289 */ 00290 virtual CdbStateId currentStateId( const BdbTime& theValidityTime ) const = 0; 00291 00292 private: 00293 00294 CdbDatabasePtr _myParentPtr; 00295 std::string _myName; 00296 CdbId _myId; 00297 }; 00298 00299 #endif // CDB_VIEW_HH
1.3-rc3