00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BaBar/BaBar.hh"
00010
00011 #include "CdbBase/CdbEnvironment.hh"
00012 #include "CdbBase/CdbEnvironmentImpl.hh"
00013 #include "CdbBase/CdbStateId.hh"
00014 #include "CdbBase/CdbView.hh"
00015
00016 #include "ErrLogger/ErrLog.hh"
00017
00018 #include <assert.h>
00019
00020 namespace {
00021
00022 int& debugMode( )
00023 {
00024 static int mode = 0;
00025 return mode;
00026 }
00027 };
00028
00029 int
00030 CdbEnvironment::setDebugMode( int newMode )
00031 {
00032 int oldMode = debugMode( );
00033 {
00034 debugMode( ) = newMode;
00035 }
00036 return oldMode;
00037 }
00038
00039 int
00040 CdbEnvironment::getDebugMode( )
00041 {
00042 return debugMode( );
00043 }
00044
00045 CdbStateId
00046 CdbEnvironment::defaultStateId( const BdbTime& theValidityTime )
00047 {
00048
00049
00050 CdbViewPtr vPtr;
00051
00052 if( CdbStatus::Success != CdbView::instance( vPtr )) {
00053 ErrMsg(error) << "Failed to locate the default view. Generating invalid state identifier." << endmsg;
00054 return CdbStateId( );
00055 }
00056 return vPtr->currentStateId( theValidityTime );
00057 }
00058
00059 BdbTime
00060 CdbEnvironment::getTruncateTime( )
00061 {
00062 return impl( )->getTruncateTime( );
00063 }
00064
00065 BdbTime
00066 CdbEnvironment::setTruncateTime( const BdbTime& theNewTruncateTime )
00067 {
00068 return impl( )->setTruncateTime( theNewTruncateTime );
00069 }
00070
00071 std::string
00072 CdbEnvironment::defaultTechnology( )
00073 {
00074 std::string technology;
00075 CdbStatus result = impl( )->getDefaultTechnology( technology );
00076
00077 assert( CdbStatus::Success == result );
00078
00079 return technology;
00080 }
00081
00082 std::string
00083 CdbEnvironment::defaultImplementation( const char* theTechnologyName )
00084 {
00085 std::string implementation;
00086 CdbStatus result = impl( )->getDefaultImplementation( implementation,
00087 theTechnologyName );
00088
00089 assert( CdbStatus::Success == result );
00090
00091 return implementation;
00092 }
00093
00094 std::string
00095 CdbEnvironment::defaultDatabase( const char* theTechnologyName,
00096 const char* theImplementationName )
00097 {
00098 std::string database;
00099 CdbStatus result = impl( )->getDefaultDatabase( database,
00100 theImplementationName,
00101 theTechnologyName );
00102
00103 assert( CdbStatus::Success == result );
00104
00105 return database;
00106 }
00107
00108 std::string
00109 CdbEnvironment::defaultView( const char* theTechnologyName,
00110 const char* theImplementationName,
00111 const char* theDatabaseName )
00112 {
00113 std::string view;
00114 CdbStatus result = impl( )->getDefaultView( view,
00115 theDatabaseName,
00116 theImplementationName,
00117 theTechnologyName );
00118
00119 assert( CdbStatus::Success == result );
00120
00121 return view;
00122 }
00123
00124 void
00125 CdbEnvironment::setDefault( const char* theTechnologyName,
00126 const char* theImplementationName,
00127 const char* theDatabaseName,
00128 const char* theViewName )
00129 {
00130 CdbStatus result = impl( )->setDefaultPath( theViewName,
00131 theDatabaseName,
00132 theImplementationName,
00133 theTechnologyName );
00134
00135 assert( CdbStatus::Success == result );
00136 }
00137
00138 CdbStatus
00139 CdbEnvironment::getDefaultTechnology( std::string& theTechnologyName )
00140 {
00141 return impl( )->getDefaultTechnology( theTechnologyName );
00142 }
00143
00144 CdbStatus
00145 CdbEnvironment::getDefaultImplementation( std::string& theImplementationName,
00146 const char* theTechnologyName )
00147 {
00148 return impl( )->getDefaultImplementation( theImplementationName,
00149 theTechnologyName );
00150 }
00151
00152 CdbStatus
00153 CdbEnvironment::getDefaultDatabase( std::string& theDatabaseName,
00154 const char* theImplementationName,
00155 const char* theTechnologyName )
00156 {
00157 return impl( )->getDefaultDatabase( theDatabaseName,
00158 theImplementationName,
00159 theTechnologyName );
00160 }
00161
00162 CdbStatus
00163 CdbEnvironment::getDefaultView( std::string& theViewName,
00164 const char* theDatabaseName,
00165 const char* theImplementationName,
00166 const char* theTechnologyName )
00167 {
00168 return impl( )->getDefaultView( theViewName,
00169 theDatabaseName,
00170 theImplementationName,
00171 theTechnologyName );
00172 }
00173
00174 CdbStatus
00175 CdbEnvironment::getDefaultPath( std::string& theViewName,
00176 std::string& theDatabaseName,
00177 std::string& theImplementationName,
00178 std::string& theTechnologyName )
00179 {
00180 return impl( )->getDefaultPath( theViewName,
00181 theDatabaseName,
00182 theImplementationName,
00183 theTechnologyName );
00184 }
00185
00186 CdbStatus
00187 CdbEnvironment::setDefaultTechnology( const char* theTechnologyName )
00188 {
00189 return impl( )->setDefaultTechnology( theTechnologyName );
00190 }
00191
00192 CdbStatus
00193 CdbEnvironment::setDefaultImplementation( const char* theImplementationName,
00194 const char* theTechnologyName )
00195 {
00196 return impl( )->setDefaultImplementation( theImplementationName,
00197 theTechnologyName );
00198 }
00199
00200 CdbStatus
00201 CdbEnvironment::setDefaultDatabase( const char* theDatabaseName,
00202 const char* theImplementationName,
00203 const char* theTechnologyName )
00204 {
00205 return impl( )->setDefaultDatabase( theDatabaseName,
00206 theImplementationName,
00207 theTechnologyName );
00208 }
00209
00210 CdbStatus
00211 CdbEnvironment::setDefaultView( const char* theViewName,
00212 const char* theDatabaseName,
00213 const char* theImplementationName,
00214 const char* theTechnologyName )
00215 {
00216 return impl( )->setDefaultView( theViewName,
00217 theDatabaseName,
00218 theImplementationName,
00219 theTechnologyName );
00220 }
00221
00222 CdbStatus
00223 CdbEnvironment::setDefaultPath( const char* theViewName,
00224 const char* theDatabaseName,
00225 const char* theImplementationName,
00226 const char* theTechnologyName )
00227 {
00228 return impl( )->setDefaultPath( theViewName,
00229 theDatabaseName,
00230 theImplementationName,
00231 theTechnologyName );
00232 }
00233
00234
00235 CdbAnyTypeDict<std::string>&
00236 CdbEnvironment::extra( )
00237 {
00238 return impl( )->extra( );
00239 }
00240
00241 CdbStatus
00242 CdbEnvironment::set( CdbPtr& thePtr )
00243 {
00244 return impl( )->set( thePtr );
00245 }
00246
00247 CdbStatus
00248 CdbEnvironment::get( CdbPtr& thePtr,
00249 const char* theTechnologyName,
00250 const char* theImplementationName )
00251 {
00252 return impl( )->get( thePtr,
00253 theTechnologyName,
00254 theImplementationName );
00255 }
00256
00257 CdbEnvironmentImpl*
00258 CdbEnvironment::impl( )
00259 {
00260 static CdbEnvironmentImpl currentImpl;
00261 return ¤tImpl;
00262 }
00263
00264
00265
00266