![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BdbCond/BdbCondDatabaseBase.hh
Go to the documentation of this file.00001 //----------------------------------------------------------------------------- 00002 // 00003 // File and Version Information: 00004 // $Id: BdbCondDatabaseBase.hh,v 1.22 2002/06/21 18:46:51 ryd Exp $ 00005 // 00006 // Description: 00007 // Class BdbCondDatabaseBase. 00008 // This is the BaBar database manager class. 00009 // This is a base class from which BdbDatabase is derived. 00010 // 00011 // Environment: 00012 // Software developed for the BaBar Detector at the SLAC B-Factory. 00013 // 00014 // Author List: 00015 // Igor A. Gaponenko Original author 00016 // 00017 // Copyright Information: 00018 // Copyright (C) 1994, 1995 Lawrence Berkeley Laboratory 00019 // 00020 //----------------------------------------------------------------------------- 00021 00022 #ifndef BDBCONDDATABASEBASE_HH 00023 #define BDBCONDDATABASEBASE_HH 00024 00025 // ------------------- 00026 // -- BaBar Headers -- 00027 // ------------------- 00028 00029 #include "BaBar/BaBar.hh" 00030 00031 // ---------------------------- 00032 // -- BaBar Database Headers -- 00033 // ---------------------------- 00034 00035 #include "BdbUtil/Bdb.hh" 00036 00037 // --------------- 00038 // -- C Headers -- 00039 // --------------- 00040 00041 extern "C" { 00042 #include <stddef.h> 00043 } 00044 00045 // --------------------------------- 00046 // -- Collaborating Class Headers -- 00047 // --------------------------------- 00048 00049 #include <string> 00050 #include <vector> 00051 00052 #include "BdbCond/BdbIntervalR.hh" 00053 #include "BdbCond/BdbObject.hh" 00054 #include "BdbCond/BdbCondRegistry.hh" 00055 #include "BdbCond/BdbCondRevision.hh" 00056 #include "BdbCond/BdbCondHistory.hh" 00057 #include "BdbCond/BdbCondContainerLink.hh" 00058 00059 // -------------------------------------- 00060 // -- Collaborating Class Declarations -- 00061 // -------------------------------------- 00062 00063 class BdbCondStoreTime; 00064 00065 // --------------------- 00066 // -- Class Interface -- 00067 // --------------------- 00068 00069 class BdbCondDatabaseBase { 00070 00071 private: 00072 00073 // Static data members. 00074 00075 static std::string _originName; // This parameter is common for all the instances of this 00076 // class working with the currently open federation. 00077 00078 private: 00079 00080 // Static initializer for the current origin name. 00081 00082 static BdbStatus initializeOriginName( ); 00083 00084 public: 00085 00086 /** These accessor functions return requested information from the internal 00087 ** cache of the object. 00088 **/ 00089 00090 inline const char* subsystemTLA( ) const; 00091 inline const char* containerName( ) const; 00092 00093 inline const BdbHandle(BdbDBObj)& intervalDBH ( ) const; 00094 inline const BdbHandle(BdbContObj)& intervalContH ( ) const; 00095 inline const BdbHandle(BdbCondRegistry)& registryH ( ) const; 00096 inline const BdbHandle(BdbCondRevision)& baselineRevisionH ( ) const; 00097 inline const BdbHandle(BdbCondRevision)& reviseAfterStoreRevisionH( ) const; 00098 inline const BdbHandle(BdbCondHistory)& historyH ( ) const; 00099 00100 inline BdbHandle(BdbDBObj) getIntervalDBH ( ) const; 00101 inline BdbHandle(BdbContObj) getIntervalContH ( ) const; 00102 inline BdbHandle(BdbCondRegistry) getRegistryH ( ) const; 00103 inline BdbHandle(BdbCondRevision) getBaselineRevisionH ( ) const; 00104 inline BdbHandle(BdbCondRevision) getReviseAfterStoreRevisionH( ) const; 00105 inline BdbHandle(BdbCondHistory) getHistoryH ( ) const; 00106 00107 inline void getIntervalDBH ( BdbHandle(BdbDBObj)& theIntervalDBH ) const; 00108 inline void getIntervalContH ( BdbHandle(BdbContObj)& theIntervalContH ) const; 00109 inline void getRegistryH ( BdbHandle(BdbCondRegistry)& theRegistryH ) const; 00110 inline void getBaselineRevisionH ( BdbHandle(BdbCondRevision)& theRevisionH ) const; 00111 inline void getReviseAfterStoreRevisionH( BdbHandle(BdbCondRevision)& theRevisionH ) const; 00112 inline void getHistoryH ( BdbHandle(BdbCondHistory)& theHistoryH ) const; 00113 00114 inline bool isLink( ) const; 00115 inline bool isWriteLocked( ) const; 00116 00117 inline BdbCondContainerLink getContainerLink( ) const; 00118 00119 inline BdbHandle(BdbDBObj) getLinkDBH ( ) const; 00120 inline BdbHandle(BdbContObj) getLinkContH( ) const; 00121 00122 inline void getContainerLink( BdbCondContainerLink& theLink ) const; 00123 00124 inline void getLinkDBH ( BdbHandle(BdbDBObj)& theLinkDBH ) const; 00125 inline void getLinkContH( BdbHandle(BdbContObj)& theLinkContH ) const; 00126 00127 /** Check if the current container is served via a container link. 00128 ** 00129 ** The function would work silently even if it does not find a link. 00130 ** 00131 ** The function will always return FALSE for non-linked containers and also 00132 ** if specified container does not exist yet. 00133 ** 00134 ** MAY DESTROY THE CACHE. 00135 **/ 00136 00137 bool isLink( const char* theContainerName ); 00138 00139 /** Check if the current container is available for writing. 00140 ** 00141 ** The function will return TRUE if it's a linked container and if this container 00142 ** is locked for wruting. 00143 ** 00144 ** The function will always return FALSE for non-linked containers and also 00145 ** if specified container does not exist yet. 00146 ** 00147 ** MAY DESTROY THE CACHE. 00148 **/ 00149 00150 bool isWriteLocked( const char* theContainerName ); 00151 00152 /** Locate a registry object for specified container. 00153 ** This object should always exist in a correct interval container. 00154 ** 00155 ** MAY RELOAD THE CACHE. 00156 **/ 00157 00158 BdbStatus findRegistry( BdbHandle(BdbCondRegistry)& theRegistryH, 00159 const char* theContainerName ); 00160 00161 /** Locate a history object (if any) for a particular interval container. 00162 ** This history object may not exist for some interval containers. 00163 ** 00164 ** MAY RELOAD THE CACHE. 00165 **/ 00166 00167 BdbStatus findHistory( BdbHandle(BdbCondHistory)& theHistoryH, 00168 const char* theContainerName ); 00169 00170 /** Obtain the link description if specified interval container is a link container. 00171 ** This function would return the success status even if specified interval 00172 ** container is not the container link. 00173 **/ 00174 00175 BdbStatus findContainerLink( BdbCondContainerLink& theLink, 00176 const char* theContainerName ); 00177 00178 /** Return a list of classes with interval containers in this database. 00179 ** Note that his will NOT clear any existing list members. 00180 ** The listClasses() method will also ignore any [n] suffixes in the end of container names. 00181 ** 00182 ** The input parameters are treated in the following way: 00183 ** 00184 ** useOldIndexes useLinksOnly theOriginName 00185 ** 00186 ** true - containers in old interval database 00187 ** false true - links in new link database 00188 ** false false 0 - containers in new interval database created 00189 ** in current federation. 00190 ** false false != 0 - containers in new interval database created 00191 ** in specified federation. 00192 **/ 00193 00194 BdbStatus listClasses( std::vector<std::string>& theList, 00195 bool useOldIndexes = false, 00196 bool useLinksOnly = true, 00197 const char* theOriginName = 0 ); 00198 00199 BdbStatus listAllClasses( std::vector<std::string>& theList, 00200 bool useOldIndexes = false, 00201 bool useLinksOnly = true, 00202 const char* theOriginName = 0 ); 00203 00204 protected: 00205 00206 /** All the constructors, destructor and assignment operator are protected 00207 ** from a direct use by client's application. 00208 **/ 00209 00210 // Constructors 00211 00212 BdbCondDatabaseBase( ); 00213 BdbCondDatabaseBase( const char* theTLA ); 00214 BdbCondDatabaseBase( const BdbCondDatabaseBase& theDB ); 00215 00216 // Destructor 00217 00218 virtual ~BdbCondDatabaseBase( ); 00219 00220 // Operators 00221 00222 BdbCondDatabaseBase& operator = ( const BdbCondDatabaseBase& theDB ); 00223 00224 /** Locate specified interval conatiner. 00225 ** 00226 ** The optional parameter, if it's set to FALSE, would return a handle 00227 ** to the container link only if found and reset internal cache 00228 ** to invalid state. 00229 ** 00230 ** If the optional parameter is in their default state TRUE) the procedure 00231 ** would locate any (old or new interval container) only and properly set 00232 ** internal cache of the object in case of success. 00233 ** 00234 ** MAY RELOAD THE CACHE. 00235 **/ 00236 00237 BdbStatus findIntervalCont( BdbHandle(BdbContObj)& theIntervalContH, 00238 const char* theContainerName, 00239 bool followLinkFlag = true ); 00240 00241 /** The following method is ment to create and to initialize the contents of 00242 ** aspecifiedcontainer link and corresponding interval container. 00243 ** 00244 ** RELOAD THE CACHE. 00245 **/ 00246 00247 BdbStatus createIntervalCont( const char* theContainerName, 00248 const BdbHandle(BdbObject)& theObjectH, 00249 const BdbTime& theBeginTime, 00250 const BdbTime& theEndTime = BdbTime::plusInfinity, 00251 d_ULong theTag = 0, 00252 const BdbTime& theVersionTime = BdbTime::minusInfinity ); 00253 00254 /** Interface to the container History system. 00255 ** The following methods are ment to write records about differecnt types of activities 00256 ** affecting the contents of an interval container into the Historian. 00257 **/ 00258 00259 void historyCCreate( const char* theCode ); 00260 00261 void historyHCreate( const char* theCode, 00262 const char* theBackupContName ); 00263 00264 void historyStore( const char* theCode, 00265 const BdbHandle(BdbObject)& theObjectH, 00266 const BdbTime& theBeginTime, 00267 const BdbTime& theEndTime, 00268 d_ULong theTag ); 00269 00270 void historyTStore( const char* theCode, 00271 const BdbHandle(BdbObject)& theObjectH, 00272 const BdbTime& theStoreTime, 00273 const BdbTime& theTruncateTime, 00274 d_ULong theTag ); 00275 00276 void historyIRemove( const char* theCode, 00277 const BdbHandle(BdbInterval)& theIntervalH ); 00278 00279 void historyRCreate( const char* theCode, 00280 const std::vector<BdbHandle(BdbInterval)>& theList, 00281 d_ULong theRevisionBaseId, 00282 d_ULong theRevisionId, 00283 const char* theRevisionSite, 00284 const char* theRevisionDescription ); 00285 00286 void historyRUpdate( const char* theCode, 00287 const std::vector<BdbHandle(BdbInterval)>& theList, 00288 d_ULong theRevisionId ); 00289 00290 void historyRDelete( const char* theCode, 00291 d_ULong theRevisionId ); 00292 00293 void historyCCopy( const char* theCode, 00294 d_ULong theLastIndex, 00295 const char* theDetector, 00296 const char* theContainer, 00297 d_ULong theLevel, 00298 d_ULong theRevId, 00299 d_Boolean copyObjects, 00300 d_Boolean copyToLocalDb, 00301 const char* theObjectContainer ); 00302 00303 void historyComment( const char* theCode, 00304 const char* theComment ); 00305 00306 void historyCPoint( const char* theCode, 00307 const BdbTime& theBackupTime, 00308 const char* theBackupContName ); 00309 00310 void historySplit( const char* theCode, 00311 const BdbTime& theSplitTime, 00312 d_ULong theTag ); 00313 00314 void historyStoreVector( const char* theCode, 00315 const std::vector<BdbCondStoreTime>& theVector ); 00316 00317 void historyCMerge( const char* theCode, 00318 const BdbTime& theBeginTime, 00319 const BdbTime& theEndTime, 00320 const char* theMergeMethod = "Direct Structural Merge" ); 00321 00322 void historyCPurge( const char* theCode, 00323 const BdbTime& theBeginTime, 00324 const BdbTime& theEndTime, 00325 d_Boolean keepRevisedIntervals, 00326 d_ULong maxNumOfTopLayers, 00327 d_ULong maxNumOfLayersUnderRevisedInterval ); 00328 00329 void historyNCorrection( const char* theCode, 00330 const BdbTime& theBeginTime, 00331 const BdbTime& theEndTime ); 00332 00333 /** The methods return the "corrected" subsystem and container names if 00334 ** so called USER AREA is being in use for specified container. 00335 ** The corrected subsystem & container names might point out into a container 00336 ** in the different (USER AREA) database. 00337 **/ 00338 00339 std::string correctedContainerName( const char* theOriginalContainerName ); 00340 std::string correctedSubsystemName( const char* theOriginalContainerName ); 00341 00342 /** Build the system name of the link database for specified 00343 ** detector. 00344 ** 00345 ** Specifying the NULL pointer for the origin name would build 00346 ** the "old"-style name for the interval database, which does not 00347 ** contain the origin as their part. 00348 **/ 00349 00350 std::string linkDatabaseName( const char* theDetector ) const; 00351 00352 std::string indexDatabaseName( const char* theDetectorName, 00353 const char* theOriginName = 0 ) const; 00354 00355 std::string buildDatabaseName( bool useOldIndexes, 00356 bool useLinksOnly, 00357 const char* theOriginName ) const; 00358 00359 /** Verify if the current cache is set for specified container. 00360 ** This function provides more strong checcking than just "reasonable" 00361 ** check. 00362 **/ 00363 00364 bool isValidCacheForContainer( const char* theContainerName ) const; 00365 00366 /** Send a signal to a derived class about reset of the cache 00367 ** on this level. It's up to the derived class how to process 00368 ** this signal. 00369 **/ 00370 00371 virtual void resetCacheHandler( ) = 0; 00372 00373 /** Explicitly set the internal cache of the object using specified values. 00374 ** This will also force the cache handler of derived classe(s) to fire. 00375 ** 00376 ** NOTE: This method provides a very fast way to establish the cache 00377 ** of this class's instances. 00378 **/ 00379 00380 void setCache( const char* theContainerName, 00381 const BdbHandle(BdbDBObj)& theIntervalDBH, 00382 const BdbHandle(BdbContObj)& theIntervalContH, 00383 const BdbHandle(BdbCondRegistry)& theRegistryH, 00384 const BdbHandle(BdbCondRevision)& theBaselineRevisionH, 00385 const BdbHandle(BdbCondRevision)& theReviseAfterStoreRevisionH, 00386 const BdbHandle(BdbCondHistory)& theHistoryH, 00387 bool isLink, 00388 bool isWriteLocked, 00389 const BdbCondContainerLink& link, 00390 const BdbHandle(BdbDBObj)& theLinkDBH, 00391 const BdbHandle(BdbContObj)& theLinkContH ); 00392 00393 00394 /** Reset the internal cache of the object. 00395 **/ 00396 00397 void resetCache( ); 00398 00399 private: 00400 00401 /** Check if the cache is valid. 00402 ** 00403 ** NOTE: The cache is considered "valid" if all the data members have 00404 ** reasonable contents. See the code for the definition of 00405 ** "reasonable contents". 00406 **/ 00407 00408 bool isValidCache( ) const; 00409 00410 private: 00411 00412 // Data members 00413 00414 std::string _subsystemTLA; 00415 std::string _containerNameCache; 00416 00417 BdbHandle(BdbDBObj) _intervalDBH; 00418 BdbHandle(BdbContObj) _intervalContH; 00419 00420 BdbHandle(BdbCondRegistry) _registryH; 00421 BdbHandle(BdbCondRevision) _baselineRevisionH; 00422 BdbHandle(BdbCondRevision) _reviseAfterStoreRevisionH; 00423 BdbHandle(BdbCondHistory) _historyH; 00424 00425 bool _isLink; 00426 bool _isWriteLocked; 00427 00428 BdbCondContainerLink _link; 00429 00430 BdbHandle(BdbDBObj) _linkDBH; 00431 BdbHandle(BdbContObj) _linkContH; 00432 }; 00433 00434 // ----------------------------------- 00435 // -- Inline methods implementation -- 00436 // ----------------------------------- 00437 00438 inline const char* 00439 BdbCondDatabaseBase::subsystemTLA( ) const 00440 { return _subsystemTLA.c_str(); } 00441 00442 inline const char* 00443 BdbCondDatabaseBase::containerName( ) const 00444 { return _containerNameCache.c_str(); } 00445 00446 inline const BdbHandle(BdbDBObj)& 00447 BdbCondDatabaseBase::intervalDBH( ) const 00448 { return _intervalDBH; } 00449 00450 inline const BdbHandle(BdbContObj)& 00451 BdbCondDatabaseBase::intervalContH( ) const 00452 { return _intervalContH; } 00453 00454 inline const BdbHandle(BdbCondRegistry)& 00455 BdbCondDatabaseBase::registryH( ) const 00456 { return _registryH; } 00457 00458 inline const BdbHandle(BdbCondRevision)& 00459 BdbCondDatabaseBase::baselineRevisionH( ) const 00460 { return _baselineRevisionH; } 00461 00462 inline const BdbHandle(BdbCondRevision)& 00463 BdbCondDatabaseBase::reviseAfterStoreRevisionH( ) const 00464 { return _reviseAfterStoreRevisionH; } 00465 00466 inline const BdbHandle(BdbCondHistory)& 00467 BdbCondDatabaseBase::historyH( ) const 00468 { return _historyH; } 00469 00470 inline BdbHandle(BdbDBObj) 00471 BdbCondDatabaseBase::getIntervalDBH( ) const 00472 { return _intervalDBH; } 00473 00474 inline BdbHandle(BdbContObj) 00475 BdbCondDatabaseBase::getIntervalContH( ) const 00476 { return _intervalContH; } 00477 00478 inline BdbHandle(BdbCondRegistry) 00479 BdbCondDatabaseBase::getRegistryH( ) const 00480 { return _registryH; } 00481 00482 inline BdbHandle(BdbCondRevision) 00483 BdbCondDatabaseBase::getBaselineRevisionH( ) const 00484 { return _baselineRevisionH; } 00485 00486 inline BdbHandle(BdbCondRevision) 00487 BdbCondDatabaseBase::getReviseAfterStoreRevisionH( ) const 00488 { return _reviseAfterStoreRevisionH; } 00489 00490 inline BdbHandle(BdbCondHistory) 00491 BdbCondDatabaseBase::getHistoryH( ) const 00492 { return _historyH; } 00493 00494 inline void 00495 BdbCondDatabaseBase::getIntervalDBH( BdbHandle(BdbDBObj)& theIntervalDBH ) const 00496 { theIntervalDBH = _intervalDBH; } 00497 00498 inline void 00499 BdbCondDatabaseBase::getIntervalContH( BdbHandle(BdbContObj)& theIntervalContH ) const 00500 { theIntervalContH = _intervalContH; } 00501 00502 inline void 00503 BdbCondDatabaseBase::getRegistryH( BdbHandle(BdbCondRegistry)& theRegistryH ) const 00504 { theRegistryH = _registryH; } 00505 00506 inline void 00507 BdbCondDatabaseBase::getBaselineRevisionH( BdbHandle(BdbCondRevision)& theRevisionH ) const 00508 { theRevisionH = _baselineRevisionH; } 00509 00510 inline void 00511 BdbCondDatabaseBase::getReviseAfterStoreRevisionH( BdbHandle(BdbCondRevision)& theRevisionH ) const 00512 { theRevisionH = _reviseAfterStoreRevisionH; } 00513 00514 inline void 00515 BdbCondDatabaseBase::getHistoryH( BdbHandle(BdbCondHistory)& theHistoryH ) const 00516 { theHistoryH = _historyH; } 00517 00518 inline bool 00519 BdbCondDatabaseBase::isLink( ) const 00520 { return _isLink; } 00521 00522 inline bool 00523 BdbCondDatabaseBase::isWriteLocked( ) const 00524 { return _isWriteLocked; } 00525 00526 inline BdbCondContainerLink 00527 BdbCondDatabaseBase::getContainerLink( ) const 00528 { return _link; } 00529 00530 inline BdbHandle(BdbDBObj) 00531 BdbCondDatabaseBase::getLinkDBH( ) const 00532 { return _linkDBH; } 00533 00534 inline BdbHandle(BdbContObj) 00535 BdbCondDatabaseBase::getLinkContH( ) const 00536 { return _linkContH; } 00537 00538 inline void 00539 BdbCondDatabaseBase::getContainerLink( BdbCondContainerLink& theLink ) const 00540 { theLink = _link; } 00541 00542 inline void 00543 BdbCondDatabaseBase::getLinkDBH( BdbHandle(BdbDBObj)& theLinkDBH ) const 00544 { theLinkDBH = _linkDBH; } 00545 00546 inline void 00547 BdbCondDatabaseBase::getLinkContH( BdbHandle(BdbContObj)& theLinkContH ) const 00548 { theLinkContH = _linkContH; } 00549 00550 #endif /* BDBCONDDATABASEBASE_HH */
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002