![]() |
|
|
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/BdbConditions.cc
Go to the documentation of this file.00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: BdbConditions.cc,v 1.52 2001/11/08 00:02:26 gapon Exp $ 00004 // 00005 // Description: 00006 // Class BdbConditions implementation file. This class represents the 00007 // BaBar database application conditions database domain. 00008 // 00009 // Environment: 00010 // Software developed for the BaBar Detector at the SLAC B-Factory. 00011 // 00012 // Author List: 00013 // David R. Quarrie Original Author 00014 // Igor A. Gaponenko Modified to support *DBFS* interface 00015 // 00016 // History: 00017 // 00018 //-------------------------------------------------------------------------- 00019 00020 //----------------------- 00021 // This Class's Header -- 00022 //----------------------- 00023 00024 #include "BdbCond/BdbConditions.hh" 00025 00026 //------------- 00027 // C Headers -- 00028 //------------- 00029 00030 extern "C" { 00031 #include <assert.h> 00032 #include <netdb.h> 00033 #include <stddef.h> 00034 #include <stdlib.h> 00035 #include <sys/param.h> 00036 #include <sys/stat.h> 00037 #include <unistd.h> 00038 } 00039 00040 //--------------- 00041 // C++ Headers -- 00042 //--------------- 00043 00044 #include <iostream.h> 00045 00046 //------------------------------- 00047 // Collaborating Class Headers -- 00048 //------------------------------- 00049 00050 #include "ErrLogger/ErrLog.hh" 00051 #include "BdbApplication/BdbDebug.hh" 00052 #include "BdbAccess/BdbAuth.hh" 00053 #include "BdbAccess/BdbDbTreeSingleton.hh" 00054 #include "BdbAccess/BdbSingleBootInhibitFactory.hh" 00055 #include "BdbApplication/BdbRWMultiInhibitPolicy.hh" 00056 #include "BdbApplication/BdbCondFSNamesStr.hh" 00057 #ifndef BDBCONDSINGLETON_HH 00058 #include "BdbApplication/BdbCondSingleton.hh" 00059 #endif 00060 #include "BdbTrees/BdbDbRegistrator.hh" 00061 00062 //----------------------------------------------------------------------- 00063 // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- 00064 //----------------------------------------------------------------------- 00065 00066 static const char rcsid[] = "$Id: BdbConditions.cc,v 1.52 2001/11/08 00:02:26 gapon Exp $"; 00067 00068 // ------------------------------------ 00069 // -- Static Data Member Definitions -- 00070 // ------------------------------------ 00071 00072 BdbConditions* 00073 BdbConditions::_instance = NULL; 00074 00075 // ---------------------------------------- 00076 // -- Static Function Member Definitions -- 00077 // ---------------------------------------- 00078 00079 //--------- 00080 // Public - 00081 //--------- 00082 00083 BdbConditions* 00084 BdbConditions::instance( ) 00085 { 00086 if ( NULL == _instance ) 00087 { 00088 _instance = new BdbConditions( ); 00089 static BdbDbRegistrator registrator ; 00090 BdbDbTreeSingleton::instance()->setRegistrator(®istrator) ; 00091 if ( ! _instance->hasInhibitPolicy( ) ) { 00092 _instance->setInhibitPolicy( new BdbRWMultiInhibitPolicy( new BdbSingleBootInhibitFactory() ) ) ; 00093 } 00094 } 00095 return _instance; 00096 } 00097 00098 // ---------------------------------------- 00099 // -- Public Function Member Definitions -- 00100 // ---------------------------------------- 00101 00102 //-------------- 00103 // Destructor -- 00104 //-------------- 00105 00106 BdbConditions::~BdbConditions( ) 00107 {} 00108 00109 //------------- 00110 // Selectors -- 00111 //------------- 00112 00113 BdbTime 00114 BdbConditions::getTime( ) const 00115 { 00116 return _theTime; 00117 } 00118 00119 //------------- 00120 // Modifiers -- 00121 //------------- 00122 00123 void 00124 BdbConditions::setTime( const BdbTime & theTime ) 00125 { 00126 _theTime = theTime; 00127 } 00128 00129 void 00130 BdbConditions::setVerbose( d_Boolean flag ) 00131 { 00132 // BdbApplicationOrDomain::activeInstance( )->setVerbose( flag ); 00133 } 00134 00135 //-------------- 00136 // Operations -- 00137 //-------------- 00138 00139 // ------------------------------------------- 00140 // -- Protected Function Member Definitions -- 00141 // ------------------------------------------- 00142 00143 //--------------- 00144 // Constructor -- 00145 //--------------- 00146 BdbConditions::BdbConditions( ) 00147 : BdbDomain( BdbDomain::Conditions ) 00148 { 00149 BdbCondSingleton::instance( )->setDomain( this ); 00150 00151 setStrategyObj(new BdbCondFSNamesStr) ; 00152 00153 /******************************************************* 00154 *** this piece of code is replaced in order to fix **** 00155 *** a BdbInterval versioning problem, which appears *** 00156 *** with the ooInsensitive index mode transactions. *** 00157 ******************************************************* 00158 * 00159 * // Set index mode to not be immediately sensitive to updates 00160 * setIndexMode( oocInsensitive ); 00161 */ 00162 00163 // Set index mode to _be_ immediately sensitive to updates 00164 setIndexMode( oocSensitive ); 00165 00166 BdbStatus status = setInitialAuthLevel( BdbDomain::System ); 00167 } 00168 00169 00170 /* 00171 BdbConditions::BdbConditions( ) 00172 : BdbDomain( BdbDomain::Conditions ), 00173 _isLocked( d_False ) 00174 { 00175 BdbCondSingleton::instance( )->setDomain( this ); 00176 00177 // Set index mode to not be immediately sensitive to updates 00178 setIndexMode( oocInsensitive ); 00179 BdbStatus status = setInitialAuthLevel( BdbDomain::System ); 00180 } 00181 */ 00182 00183 bool 00184 BdbConditions::isAuthorized( BdbDomain::AuthLevels theAuthLevel, 00185 const char* const theAuthName ) 00186 { 00187 assert( isAuthLevelValid( theAuthLevel ) ); 00188 BdbAuth* theAuth = BdbAuth::instance( ); 00189 activate() ; 00190 bool result( theAuth->isAuthorized( domain(), 00191 theAuthLevel, 00192 theAuthName ) ); 00193 deactivate() ; 00194 return result; 00195 } 00196 00197 d_Boolean 00198 BdbConditions::subsystemDBexist( const char* dbName ) 00199 { 00200 assert( dbName != NULL ); 00201 00202 BdbHandle(BdbFDObj) fdH; 00203 BdbHandle(BdbDBObj) dbH; 00204 00205 fdH = fd( ); 00206 dbH = NULL; 00207 00208 COUT1 << "CONDDBOPEN: (exist only) db=" << dbName << endl; 00209 d_Boolean result = dbH.exist( fdH, dbName, BdbcNoOpen ); 00210 00211 return result; 00212 } 00213 00214 ///////////////// 00215 // End Of File // 00216 /////////////////
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002