00001 #ifndef CDBROOREADONLY_VIEW_R_RDL 00002 #define CDBROOREADONLY_VIEW_R_RDL 00003 00004 // File and Version Information: 00005 // $Id: CdbRooRoViewR.rdl,v 1.3 2004/12/08 17:36:47 gapon Exp $ 00006 00007 #include "CdbBase/CdbItr.hh" 00008 00009 #include "CdbRooReadonly/CdbRooRoTimeR.hh" 00010 00011 #include <string> 00012 #include <iostream> 00013 00014 class CdbRooRoConfigCollectionR; 00015 class CdbRooRoFolderR; 00016 class CdbRooRoConditionAtFolderR; 00017 class CdbRooRoIdR; 00018 00019 /// A persistent incarnation for the concept of "view" 00020 /** 00021 * See details below. 00022 */ 00023 class CdbRooRoViewR { 00024 00025 public: 00026 00027 /// Default constructor 00028 /** 00029 * It's required by ROOT I/O 00030 */ 00031 CdbRooRoViewR( ); 00032 00033 /// Normal constructor 00034 /** 00035 * WARNING: Inappropriate values of the parameters will cause the crash 00036 * of the constructor to avoid creating disformed persistent 00037 * data structures. 00038 */ 00039 CdbRooRoViewR( const std::string& theName, 00040 UShort_t theId, 00041 const std::string& theDescription, 00042 const BdbTime& theCreationTime, 00043 const BdbTime& theMinValidityTime = BdbTime::minusInfinity, 00044 const BdbTime& theMaxValidityTime = BdbTime::plusInfinity, 00045 CdbRooRoConfigCollectionR* theDefaultConfigPtr = 0 00046 ); 00047 00048 /// Copy constructor 00049 /** 00050 * Need a non-trivial constructor because we have we have a cyclic graph of View, Folder 00051 * and ConditionAtFolder objects. 00052 */ 00053 CdbRooRoViewR( const CdbRooRoViewR& theOther ); 00054 00055 /// Destructor 00056 00057 virtual ~CdbRooRoViewR( ); 00058 00059 /// Assignment operator 00060 /** 00061 * Need a non-trivial constructor because we have we have a cyclic graph of View, Folder 00062 * and ConditionAtFolder objects. 00063 */ 00064 CdbRooRoViewR& operator=( const CdbRooRoViewR& theOther ); 00065 00066 // Accessors 00067 00068 const std::string& name( ) const { return _name; } 00069 00070 UShort_t id( ) const { return _id; } 00071 00072 const std::string& description( ) const { return _description; } 00073 00074 BdbTime created ( ) const { return _created.getBdbTime( ); } 00075 BdbTime minValidity( ) const { return _minValidityTime.getBdbTime( ); } 00076 BdbTime maxValidity( ) const { return _maxValidityTime.getBdbTime( ); } 00077 00078 const CdbRooRoConfigCollectionR* defaultConfig( ) const { return ( _useDefaultConfigPtr ? _defaultConfigPtr : 0 ); } 00079 CdbRooRoConfigCollectionR* defaultConfig( ) { return ( _useDefaultConfigPtr ? _defaultConfigPtr : 0 ); } 00080 00081 const CdbRooRoFolderR* rootFolder( ) const { return ( _useRootFolderPtr ? _rootFolderPtr : 0 ); } 00082 CdbRooRoFolderR* rootFolder( ) { return ( _useRootFolderPtr ? _rootFolderPtr : 0 ); } 00083 00084 /// Check if this view is "frozen" from any further modifications 00085 /** 00086 * If a view is in "frozen" state then it can't be modified (adding/removing 00087 * folders or conditions or any other relevant operations). A view gets into 00088 * this state immediatelly upon its creation. 00089 * 00090 * A view in the "frozen" is available to clients. 00091 */ 00092 bool isFrozen( ) const { return _isFrozen; } 00093 00094 /// "Freeze" the view 00095 /** 00096 * Once a view is frozen then there is no way to revert it back. 00097 * 00098 * @see CdbRooRoViewR::isFrozen() 00099 */ 00100 void freeze( ) { _isFrozen = true; } 00101 00102 /// "Un-freeze" the view 00103 /** 00104 * Once a view is frozen then generally there is no way to revert it back. However we 00105 * still need to do this sometimes. 00106 * 00107 * @see CdbRooRoViewR::isFrozen() 00108 */ 00109 void warm( ) { _isFrozen = false; } 00110 00111 /// Set/override default configuration at a level of a view 00112 /** 00113 * The passed pointer can be 0. The previously stored configuration 00114 * object (if any) will be destroyed. 00115 * 00116 * NOTE: This operation requires the view to be available for modifications 00117 * (not being frozen). 00118 */ 00119 CdbStatus setDefaultConfig( CdbRooRoConfigCollectionR* theConfigPtr /**< a configuration object */ 00120 ); 00121 00122 /// Set/override configuration at a level of specified condition 00123 /** 00124 * The passed pointer can be 0. The previously stored configuration 00125 * object (if any) will be destroyed unless an optional 'dontDestroyConfigObject' 00126 * flag is set to true. 00127 * 00128 * If there is no such folder then CdbStatus::NotFound will be returned. 00129 * Other status values are as usual. 00130 * 00131 * NOTE: This operation requires the view to be available for modifications 00132 * (not being frozen). 00133 */ 00134 CdbStatus setConfig( const std::string& thePathName, /**< the full path name of the condition to be modified */ 00135 CdbRooRoConfigCollectionR* theConfigPtr, /**< a configuration object */ 00136 bool dontDestroyConfigObject = false /**< an optional flag */ 00137 ); 00138 00139 /// Create new folder 00140 /** 00141 * This operation requires the full path to a "host" folder where the specified one will 00142 * be placed into. The "host" folder must already be existing at a time when this method 00143 * is called. 00144 * 00145 * If the specified "host" folder is not found then CdbStatus::NotFound will be returned. 00146 * The usual error status will be returned in other cases. 00147 */ 00148 CdbStatus createFolder( const std::string& thePathName, /**< the path name to a "host" folder */ 00149 const std::string& theNewFolderName, /**< the folder name at the "host" folder */ 00150 const std::string& theDescription, /**< the description of the folder */ 00151 const BdbTime& theCreationTime /**< the time when the folder is supposed to be created */ 00152 ); 00153 00154 /// Create new folder (RECURSIVE) 00155 /** 00156 * This operation creates the specified folder path, including intermediate subdirectories 00157 * if they still do not exist. 00158 * 00159 * NOTE: The specified "description" and "creation" timestamp will be assigned to all 00160 * newely created folders. 00161 */ 00162 CdbStatus createFolder( const std::string& theFullPathName, /**< the full path name of the folder to be created */ 00163 const std::string& theDescription, /**< the description of the folder */ 00164 const BdbTime& theCreationTime /**< the time when the folder is supposed to be created */ 00165 ); 00166 00167 /// Create new condition 00168 /** 00169 * This operation requires the full path to a "host" folder where the specified condition will 00170 * be placed into. The "host" folder must already be existing at a time when this method 00171 * is called. 00172 * 00173 * If the specified "host" folder is not found then CdbStatus::NotFound will be returned. 00174 * The usual error status will be returned in other cases. 00175 */ 00176 CdbStatus createCondition( const std::string& thePathName, /**< the path name to a "host" folder */ 00177 const std::string& theNewConditionName, /**< the condition name at the "host" folder */ 00178 const std::string& theDescription, /**< the description of the condition */ 00179 const BdbTime& theCreationTime, /**< the time when the condition is supposed to be created */ 00180 const CdbRooRoIdR& theId, /**< the "extended" identifier of the "physical" condition */ 00181 CdbRooRoConfigCollectionR* theConfigPtr = 0 /**< an optional configuration object */ 00182 ); 00183 00184 /// Remove the folder 00185 /** 00186 * This operation requires the absolute path to the folder. The "root" folder 00187 * can never be deleted. 00188 * 00189 * If the "forceFlag" is set FALSE then only an empty folder with no other subfolders 00190 * or conditions in it can be removed. Otherwise both the folder itself and its contents 00191 * will be exterminated. 00192 * 00193 * NOTE: This operation does not affect 'physical conditions'. 00194 * 00195 * If there is no such folder then CdbStatus::NotFound will be returned. 00196 * Other status values are as usual. 00197 */ 00198 CdbStatus removeFolder( const std::string& thePathName, /**< the full path name of the folder to be removed */ 00199 bool forceFlag = false /**< force removal if the folder is not empty */ 00200 ); 00201 00202 /// Remove the condition 00203 /** 00204 * This operation requires the absolute path to the condition. 00205 * 00206 * If there is no such condition then CdbStatus::NotFound will be returned. 00207 * Other status values are as usual. 00208 */ 00209 CdbStatus removeCondition( const std::string& thePathName /**< the full path name of the condition to be removed */ 00210 ); 00211 00212 /// Find the folder 00213 /** 00214 * This operation requires the full path to the required folder. Upon successfull 00215 * completion it will return CdbStatus::Success. If the folder is not found 00216 * CdbStatus::NotFound will be returned. The error status will be returned in other cases. 00217 */ 00218 CdbStatus findFolder( const std::string& thePathName, /**< the full path name to the folder */ 00219 CdbRooRoFolderR*& thePtr /**< the pointer to the found folder to be set up */ 00220 ); 00221 00222 /// Find the condition 00223 /** 00224 * This operation requires the full path to the required condition. Upon successfull 00225 * completion it will return CdbStatus::Success. If the condition is not found 00226 * CdbStatus::NotFound will be returned. The error status will be returned in other cases. 00227 */ 00228 CdbStatus findCondition( const std::string& thePathName, /**< the full path name to the condition */ 00229 CdbRooRoConditionAtFolderR*& thePtr /**< the poinjter to the found condition to be set up */ 00230 ); 00231 00232 /// Set up an iterator of folder names 00233 /** 00234 * This method will always return CdbStatus::Success and the only name returned 00235 * by the iterator would be the root folder's name. 00236 */ 00237 CdbStatus folderIterator( CdbItr< const char* >& theItr /**< the value of the iterator be set up */ 00238 ) const; 00239 00240 /// Dump the contents of the object 00241 /** 00242 */ 00243 void dump( std::ostream& o ) const; 00244 00245 private: 00246 00247 // Data members 00248 00249 std::string _name; 00250 00251 UShort_t _id; 00252 00253 std::string _description; 00254 00255 CdbRooRoTimeR _created; 00256 00257 CdbRooRoTimeR _minValidityTime; 00258 CdbRooRoTimeR _maxValidityTime; 00259 00260 Bool_t _useDefaultConfigPtr; // to work-around a bug in the ROOT I/O streamers 00261 CdbRooRoConfigCollectionR* _defaultConfigPtr; //-> 00262 00263 Bool_t _useRootFolderPtr; // to work-around a bug in the ROOT I/O streamers 00264 CdbRooRoFolderR* _rootFolderPtr; //-> 00265 00266 Bool_t _isFrozen; 00267 00268 ClassDef(CdbRooRoViewR,1) 00269 }; 00270 00271 #endif /* CDBROOREADONLY_VIEW_R_RDL */
1.3-rc3