Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/BdbCond/BdbCache.cc

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File and Version Information:
00004 //      $Id: BdbCache.cc,v 1.19 2002/08/07 21:45:25 gapon Exp $
00005 //
00006 // Description:
00007 //      Class BdbCache
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 //      David Brown                     Rewrite 6/10/97
00015 //
00016 // Copyright Information:
00017 //      Copyright (C) 1994, 1995        Lawrence Berkeley Laboratory
00018 //
00019 //-----------------------------------------------------------------------------
00020 
00021 //-----------------
00022 // BaBar Headers --
00023 //-----------------
00024 #include "BaBar/BaBar.hh"
00025 
00026 //-----------------------
00027 // This Class's Header --
00028 //-----------------------
00029 #include "BdbCond/BdbCache.hh"
00030 
00031 //-------------
00032 // C Headers --
00033 //-------------
00034 extern "C" {
00035 #include <stddef.h>
00036 }
00037 
00038 //---------------
00039 // C++ Headers --
00040 //---------------
00041 #include <iostream.h>
00042 #include <string.h>
00043 #include <string>
00044 using std::string;
00045 
00046 //-------------------------------
00047 // Collaborating Class Headers --
00048 //-------------------------------
00049 #include "BdbCond/BdbObsoleteDatabase.hh"
00050 #include "BdbTime/BdbTime.hh"
00051 
00052 //-----------------------------------------------------------------------
00053 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00054 //-----------------------------------------------------------------------
00055 
00056 static const char rscid[] = "$Id: BdbCache.cc,v 1.19 2002/08/07 21:45:25 gapon Exp $";
00057 
00058 //----------------
00059 // Constructors --
00060 //----------------
00061 
00062 BdbCache::BdbCache( ) :
00063   _database     ( NULL ),
00064   _containerName( '\0' ),
00065   _TLA          ( '\0' ),
00066   _tag          ( NULL ),
00067   _interval     ( NULL ),
00068   _object       ( NULL )
00069 {
00070 }
00071 
00072 BdbCache::BdbCache( const char* theSubsystemName,
00073                     const char* theContainerName,
00074                     d_ULong     theTag ) :
00075   _database     ( new BdbObsoleteDatabase( theSubsystemName ) ),
00076   _containerName( theContainerName ),
00077   _TLA          ( theSubsystemName ),
00078   _tag          ( theTag           ),
00079   _interval     ( NULL             ),
00080   _object       ( NULL             )
00081 {
00082 }
00083 
00084 BdbCache::BdbCache( const BdbCache& theCache )
00085 {
00086   _database      = new BdbObsoleteDatabase( *(theCache._database) );
00087   _containerName = theCache._containerName;
00088   _TLA           = theCache._TLA;
00089   _tag           = theCache._tag;
00090   _interval      = theCache._interval;
00091   _object        = theCache._object;
00092 }
00093 
00094 //--------------
00095 // Destructor --
00096 //--------------
00097 
00098 BdbCache::~BdbCache( )
00099 {
00100   delete _database;
00101 }
00102 
00103 //-----------------------
00104 // Assignment Operator --
00105 //-----------------------
00106 
00107 BdbCache& BdbCache::operator = ( const BdbCache& theCache )
00108 {
00109   if ( this == &theCache )
00110     {
00111       return *this;
00112     }
00113 
00114   delete _database;
00115   _database      = new BdbObsoleteDatabase( *(theCache._database) );
00116   _containerName = theCache._containerName;
00117   _TLA           = theCache._TLA;
00118   _tag           = theCache._tag;
00119   _interval      = theCache._interval;
00120   _object        = theCache._object;
00121   return *this;
00122 }
00123 
00124 
00125 BdbIfdHandle<BdbObject>&
00126 BdbCache::ifdFetch( const BdbTime& theTime )
00127 {
00128   if ( _interval != NULL && _interval->inInterval(theTime) )
00129     {
00130       // Return the cached object
00131 #ifdef BDBDATABASE_DEBUG
00132       cout << "Returning cached object" << endl;
00133 #endif
00134       return _object;
00135     }
00136   else
00137     {
00138       // Search the db for the object
00139 #ifdef BDBDATABASE_DEBUG
00140       cout << "searching db for object" << endl;
00141 #endif
00142       BdbHandle(BdbObject) theObjectH;
00143       _database->findObject( theObjectH, _containerName.c_str(), theTime, _tag );
00144 
00145       BdbHandle(BdbInterval) theIntervalH;
00146       _database->findInterval( theIntervalH, _containerName.c_str(), theTime, _tag );
00147 
00148       _interval = theIntervalH;
00149       _object   = theObjectH;
00150       return _object;
00151     }
00152 }
00153 
00154 BdbHandle(BdbObject)
00155 BdbCache::fetch( const BdbTime& theTime ) 
00156 {
00157   return *( ifdFetch(theTime) );
00158 }
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
00269 
00270 
00271 
00272 
00273 
00274 
00275 
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 
00314 
00315 
00316 
00317 
00318 
00319 
00320 
00321 
00322 
00323 
00324 
00325 
00326 
00327 
00328 
00329 
00330 
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00400 
00401 
00402 
00403 
00404 
00405 
00406 
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 
00425 
00426 
00427 
00428 
00429 
00430 
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 
00448 
00449 
00450 
00451 
00452 
00453 
00454 
00455 
00456 
00457 
00458 

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002