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  

/BdbDomainOODB/BdbDomainOODB.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //  $Id: BdbDomainOODB.cc,v 1.9 2002/08/12 18:41:20 becla Exp $
00004 //
00005 // Description:
00006 //  Class BdbDomainOODB implementation file. This class represents an 
00007 //  BaBar database application 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 // This Class's Header --
00021 //-----------------------
00022 #include "BdbDomainOODB/BdbDomainOODB.hh"
00023 
00024 //-------------
00025 // C Headers --
00026 //-------------
00027 extern "C" {
00028 #include <stdlib.h> // abort
00029 #include <strings.h>
00030 }
00031 
00032 //---------------
00033 // C++ Headers --
00034 //---------------
00035 
00036 //-------------------------------
00037 // Collaborating Class Headers --
00038 //-------------------------------
00039 #include "ErrLogger/ErrLog.hh"
00040 
00041 #include "BdbDomainOODB/BdbImplDomainOODB.hh"
00042 #include "BdbUtil/BdbDebug.hh"
00043 
00044 //-----------------------------------------------------------------------
00045 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00046 //-----------------------------------------------------------------------
00047 
00048 static const char rcsid[] = "$Id: BdbDomainOODB.cc,v 1.9 2002/08/12 18:41:20 becla Exp $";
00049 
00050 //----------------------------------
00051 // default implementation classes --
00052 //----------------------------------
00053 
00054 #include "BdbDomainOODB/BdbNoOpenTransFunc.hh"
00055 #include "BdbDomainOODB/BdbCheckPointFunc.hh"
00056 
00057 class BdbNoOpNoOpenTransFunc
00058    : public BdbNoOpenTransFunc
00059 {
00060    protected:
00061       // Modifiers
00062       virtual bool execute() { return( !false ) ; }
00063 } ;
00064 
00065 class BdbNoOpCheckPointFunc
00066    : public BdbCheckPointFunc
00067 {
00068    public:
00069       // Selectors (const)
00070       virtual bool transNotOpen() { return( false ) ; } ;
00071 
00072    protected:
00073       // Modifiers
00074       virtual bool execute() { return( !false ) ; }
00075 } ;
00076 
00077 //      ------------------------------------
00078 //      -- Static Data Member Definitions --
00079 //      ------------------------------------
00080 
00081 BdbDomainOODB* BdbDomainOODB::_ringEntrance( 0 ) ;
00082 d_ULong BdbDomainOODB::_activationCount( 0 ) ;
00083 
00084 //      ----------------------------------------
00085 //      -- Static Function Member Definitions --
00086 //      ----------------------------------------
00087 
00088 BdbDomainOODB*
00089 BdbDomainOODB::activeDomainOODB()
00090 {
00091    if( 0 == _ringEntrance ) {
00092       return 0 ;
00093    }
00094 
00095    return( _ringEntrance->_impl->activeClient() ) ;
00096 }
00097 
00098 BdbNoOpenTransFunc&
00099 BdbDomainOODB::noOpNoOpen()
00100 {
00101    static BdbNoOpNoOpenTransFunc noOp ;
00102    return( noOp ) ;
00103 }
00104 
00105 BdbCheckPointFunc&
00106 BdbDomainOODB::noOpCheckPoint()
00107 {
00108    static BdbNoOpCheckPointFunc noOp ;
00109    return( noOp ) ;
00110 }
00111 
00112 //      ----------------------------------------
00113 //      -- Public Function Member Definitions --
00114 //      ----------------------------------------
00115 
00116 //---------------
00117 // Constructor --
00118 //---------------
00119 
00120 BdbDomainOODB::BdbDomainOODB( BdbImplDomainOODB* implementation )
00121    : _impl( implementation ) ,
00122      _isActive( false ) ,
00123      _next( 0 ) ,
00124      _previous( 0 )
00125 {
00126    if( 0 == _ringEntrance ) {
00127       addToRing( _ringEntrance ) ;
00128       _ringEntrance = this ;
00129    }
00130    else {
00131       if( 0 != _ringEntrance->matchLabel( implementation->label(),
00132                                           _ringEntrance ) ) {
00133          ErrMsg( fatal ) << "Can not run two BdbDomainOODBs with the same"
00134                          << " label!"
00135                          << endmsg ;
00136          ::abort() ;
00137       }
00138       addToRing( _ringEntrance ) ;
00139    }
00140 
00141 
00142    _impl->setClient( *this ) ;
00143 
00144    return ;
00145 }
00146 
00147 //--------------
00148 // Destructor --
00149 //--------------
00150 
00151 BdbDomainOODB::~BdbDomainOODB( ) 
00152 {
00153    if( _ringEntrance == this ) {
00154       if( _next == _previous ) {
00155          _ringEntrance = 0 ;
00156       }
00157       else {
00158          _ringEntrance = _next ;
00159       }
00160    }
00161 
00162    removeFromRing() ;
00163 
00164    delete _impl ;
00165 }
00166 
00167 //-------------
00168 // Selectors --
00169 //-------------
00170 
00171 d_Boolean
00172 BdbDomainOODB::oodbIsInitialized() const
00173 {
00174     return _impl->oodbIsInitialized() ;
00175 }
00176 
00177 const char*
00178 BdbDomainOODB::bootName() const
00179 {
00180     return _impl->bootName();
00181 }
00182 
00183 const char*
00184 BdbDomainOODB::dirName( ) const
00185 {
00186     return _impl->dirName( );
00187 }
00188     
00189 const char*
00190 BdbDomainOODB::hostName( ) const
00191 {
00192     return _impl->hostName( );
00193 }
00194 
00195 d_ULong 
00196 BdbDomainOODB::cacheInitPages( ) const
00197 {
00198     return _impl->cacheInitPages( );
00199 }
00200 
00201 d_ULong 
00202 BdbDomainOODB::cacheMaxPages(  ) const
00203 {
00204     return _impl->cacheMaxPages( );
00205 }
00206 
00207 d_ULong 
00208 BdbDomainOODB::fileDescriptors(  ) const
00209 {
00210     return _impl->fileDescriptors( );
00211 }
00212 
00213 BdbAMSUsage
00214 BdbDomainOODB::amsUsage(  ) const
00215 {
00216     return _impl->amsUsage( );
00217 }
00218 
00219 //-------------
00220 // Modifiers --
00221 //-------------
00222 
00223 void 
00224 BdbDomainOODB::setCacheInitPages( d_ULong thePages )
00225 {
00226     _impl->setCacheInitPages( thePages );
00227 }
00228 
00229 void 
00230 BdbDomainOODB::setCacheMaxPages( d_ULong thePages )
00231 {
00232     _impl->setCacheMaxPages( thePages );
00233 }
00234 
00235 void 
00236 BdbDomainOODB::setFileDescriptors( d_ULong theFiles )
00237 {
00238     _impl->setFileDescriptors( theFiles );
00239 }
00240 
00241 void
00242 BdbDomainOODB::setAMSUsage( BdbAMSUsage amsUsage )
00243 {
00244    _impl->setAMSUsage( amsUsage ) ;
00245 }
00246 
00247 void 
00248 BdbDomainOODB::setStandalone()
00249 {
00250     _impl->setStandalone() ;
00251 }
00252 
00253 void
00254 BdbDomainOODB::ignoreErrors()
00255 {
00256     _impl->setIgnoreErrors( d_True ) ;
00257 }
00258 
00259 void
00260 BdbDomainOODB::noticeErrors()
00261 {
00262     _impl->setIgnoreErrors( d_False ) ;
00263 }
00264 
00265 void
00266 BdbDomainOODB::setBootName( const char* bootName )
00267 {
00268     _impl->setBootName( bootName ) ;
00269 }
00270 
00271 void
00272 BdbDomainOODB::setDefaultBootName( const char* bootName )
00273 {
00274     _impl->setDefaultBootName( bootName ) ;
00275 }
00276 
00277 void
00278 BdbDomainOODB::holdCurrentTrans()
00279 {
00280     _impl->holdCurrentTrans() ;
00281 }
00282 
00283 void
00284 BdbDomainOODB::dropCurrentTrans()
00285 {
00286     _impl->dropCurrentTrans() ;
00287 }
00288 
00289 void
00290 BdbDomainOODB::setCurrentTrans( const BdbTransToken& token )
00291 {
00292     _impl->setCurrentTrans( token ) ;
00293 }
00294 
00295 BdbTransToken
00296 BdbDomainOODB::newCurrentTrans()
00297 {
00298     return( _impl->newCurrentTrans() ) ;
00299 }
00300 
00301 /* phase 3.3 extension to allow creation of output transaction 
00302          associated with a different federation
00303 */
00304 BdbTransToken
00305 BdbDomainOODB::newCurrentTrans(const char *newBootName)
00306 {
00307     return( _impl->newCurrentTrans(newBootName) ) ;
00308 }
00309 
00310 //--------------
00311 // Operations --
00312 //--------------
00313 
00314 void
00315 BdbDomainOODB::setIndexMode( BdbIndexMode indexMode )
00316 {
00317     _impl->setIndexMode( indexMode );
00318 }
00319 
00320 void
00321 BdbDomainOODB::setMrowMode( BdbMode mrowMode )
00322 {
00323     _impl->setMrowMode( mrowMode );
00324 }
00325 
00326 void
00327 BdbDomainOODB::setInhibitPolicy( const BdbInhibitPolicy* policy )
00328 {
00329     _impl->setInhibitPolicy( policy ) ;
00330 }
00331 
00332 d_Boolean
00333 BdbDomainOODB::hasInhibitPolicy( ) const
00334 {
00335     return _impl->hasInhibitPolicy( );
00336 }
00337 
00338 BdbTransToken
00339 BdbDomainOODB::currentTransToken() const
00340 {
00341     return _impl->currentTransToken() ;
00342 }
00343 
00344 d_Boolean
00345 BdbDomainOODB::currentTransIsHeld() const
00346 {
00347     return _impl->currentTransIsHeld() ;
00348 }
00349 d_Boolean
00350 BdbDomainOODB::isStandalone() const
00351 {
00352     return _impl->isStandalone();
00353 }
00354 
00355 d_Long
00356 BdbDomainOODB::rpcTimeout( ) const
00357 {
00358     return _impl->rpcTimeout( );
00359 }
00360 
00361 void
00362 BdbDomainOODB::setRpcTimeout( d_Long secs )
00363 {
00364     _impl->setRpcTimeout( secs );
00365 }
00366 
00367 d_Boolean
00368 BdbDomainOODB::isVTablePointerChecked( ) const
00369 {
00370     return _impl->checkVTablePointer() ;
00371 }
00372 
00373 void 
00374 BdbDomainOODB::setCheckVTablePointer( d_Boolean isChecked )
00375 {
00376     _impl->setCheckVTablePointer( isChecked );
00377 }
00378 
00379 d_Long 
00380 BdbDomainOODB::lockWait( ) const
00381 {
00382     return _impl->lockWait( );
00383 }
00384 
00385 void 
00386 BdbDomainOODB::setLockWait( d_Long waitMode )
00387 {
00388     _impl->setLockWait( waitMode );
00389 }
00390 
00391 BdbIndexMode
00392 BdbDomainOODB::indexMode() const
00393 {
00394     return _impl->indexMode();
00395 }
00396 
00397 BdbMode
00398 BdbDomainOODB::mrowMode() const
00399 {
00400     return _impl->mrowMode();
00401 }
00402 
00403 BdbTransId
00404 BdbDomainOODB::transId() const
00405 {
00406     return _impl->transId();
00407 }
00408 
00409 BdbHandleCacheMgr*
00410 BdbDomainOODB::currentHandleCache( )
00411 {
00412     return _impl->currentHandleCache() ;
00413 }
00414 
00415 // Implementation taked from BdbApplication
00416 
00417 BdbStatus
00418 BdbDomainOODB::updateAndWait( BdbHandleAny& theObj, 
00419                               const char* const thePrefix, 
00420                               d_ULong timeout )
00421 {
00422     BdbStatus result  = BdbcError;
00423     d_ULong count     = 0;
00424     BdbMode theMrowMode = mrowMode();
00425 
00426     // First make a single attempt to gain the lock
00427     d_Long oldWait = lockWait( );
00428     setLockWait( 300 );
00429     result = theObj.update( );
00430     setLockWait( oldWait );
00431 
00432     if ( BdbcSuccess != result ) {
00433         // The lock attempt didn't succeed. Change the strategy to wait for 
00434         // multiples of 1 minute up to the specified timeout limit. First 
00435         // release all resources by committing the transaction and starting
00436         // a new one.
00437         commit            ( thePrefix );
00438         setMrowMode( theMrowMode );
00439         startUpdate       ( thePrefix );
00440 
00441         setLockWait( 60 );
00442         while ( ( BdbcSuccess != result ) && ( count < timeout ) ) {
00443             // Attempt to lock the object for updating
00444             result = theObj.update( );
00445             if ( BdbcSuccess != result ) {
00446                 // Attempt wasn't successful - issue some debug information & try again
00447                 char charbuf[256];
00448                 ooId theID = theObj;
00449                 sprintf( charbuf, "[%d,%d]", theID.get_DB( ), theID.get_OC( ) ); 
00450                 COUT1 << "BdbDomainOODB::updateAndWait: Update attempt on "
00451                       << charbuf << " failed - retrying..." << endl;
00452                 ErrMsg( warning ) << "BdbDomainOODB::updateAndWait"
00453                                   << ": Update collision detected on "
00454                                   << charbuf << " - waiting..." << endmsg ;
00455             }
00456             count++;
00457         }
00458         setLockWait( oldWait );
00459     }
00460     if ( BdbcSuccess != result ) {
00461        ErrMsg( error ) << "BdbDomainOODB::updateAndWait"
00462                        << ": Update collision wait timeout exceeded"
00463                        << endmsg ;
00464     }
00465     return result; 
00466 }
00467 
00468 BdbStatus
00469 BdbDomainOODB::updateAndWait( BdbHandleAny theHandles[], int nrElem, 
00470                               const char* const thePrefix, 
00471                               d_ULong timeout )
00472 {
00473     BdbStatus result  = BdbcError;
00474     BdbMode theMrowMode = mrowMode( );
00475     d_Boolean gotLock = d_False;
00476     int i, failedItem    = 0;
00477 
00478     // First make a single attempt to gain the lock(s), failing immediately
00479     // with no lock waiting if there's a problem. However, remember the
00480     // first item that failed and use as the first one to try for the
00481     // next attempt.
00482     d_Long oldWait = lockWait( );
00483     setLockWait( 300 );
00484     for ( i=0; i<nrElem; i++ ) {
00485         if ( ( result = theHandles[i].update( ) ) != BdbcSuccess ) {
00486             failedItem = i;
00487             break;
00488         }
00489     }
00490     setLockWait( oldWait );
00491 
00492     if ( BdbcSuccess != result ) {
00493 
00494         // The lock attempt didn't succeed. Change the strategy to wait for 
00495         // multiples of 1 minute up to the specified timeout limit. First 
00496         // release all resources by committing the transaction and starting
00497         // a new one.
00498         commit     ( thePrefix );
00499         setMrowMode( theMrowMode );
00500         startUpdate( thePrefix );
00501         d_ULong count = 0;
00502         while ( ( BdbcSuccess != result ) && ( count < timeout ) ) {
00503             gotLock = d_False;
00504 
00505             // Attempt to lock one object for updating, waiting for up to 60 secs.
00506             // The object that's used for this is the first one that previous failed.
00507             setLockWait( 60 );
00508             result = theHandles[failedItem].update( );
00509             if ( BdbcSuccess == result ) {
00510                 gotLock = d_True;
00511 
00512                 // Lock gained on the first object. Attempt to lock the others.
00513                 // Note that this attempt is done with zero lock waiting. 
00514                 // Remember the first failure for the next attempt.
00515                 setLockWait( BdbcNoWait );
00516                 for ( i=0; i<nrElem; i++ ) {
00517                     if ( ( result = theHandles[i].update( ) ) != BdbcSuccess ) {
00518                         failedItem = i;
00519                         break;
00520                     }
00521                 }
00522             }
00523             if ( BdbcSuccess != result ) {
00524                 // Attempt wasn't successful - issue some debug information & try again.
00525                 // If any objects were locked, release them by commiting the current
00526                 // transaction and starting a new one.
00527                 char charbuf[256];
00528                 ooId theID = theHandles[failedItem];
00529                 sprintf( charbuf, "[%d,%d]", theID.get_DB( ), theID.get_OC( ) ); 
00530                 COUT1 << "BdbDomainOODB::updateAndWait: Update attempt on "
00531                       << charbuf  << " (of multiple) failed - retrying..." << endl;
00532                 ErrMsg( warning ) << "BdbDomainOODB::updateAndWait"
00533                                   << ": Update collision detected on "
00534                                   << charbuf << " - waiting..." << endmsg ;
00535                 if ( gotLock ) {
00536                     commit     ( thePrefix );
00537                     setMrowMode( theMrowMode );
00538                     startUpdate( thePrefix );
00539                 }
00540             }
00541             count++;
00542             setLockWait( oldWait );
00543         }
00544     }
00545     if ( BdbcSuccess != result ) {
00546        ErrMsg( error ) << "BdbDomainOODB::updateAndWait"
00547                        << ": Update collision wait timeout exceeded"
00548                        << endmsg ;
00549     }
00550     return result; 
00551 }
00552 // end implementation
00553 
00554 BdbHandle(BdbFDObj)&
00555 BdbDomainOODB::fd( ) const
00556 {
00557     return _impl->fd( );
00558 }
00559 
00560 d_Boolean
00561 BdbDomainOODB::isActive() const
00562 {
00563     return _impl->isActive() ;
00564 }
00565 
00566 d_Boolean
00567 BdbDomainOODB::transIsOpen() const
00568 {
00569    return BdbcNoOpen != _impl->mode() ;
00570 }
00571 
00572 BdbStatus
00573 BdbDomainOODB::activate() const
00574 {
00575    char* inset = new char[ _activationCount + 1 ] ;
00576    for( d_ULong depth( 0 ) ;
00577         _activationCount != depth ;
00578         depth++ ) {
00579       inset[ depth ] = ' ' ;
00580    }
00581    inset[ _activationCount ] = '\0' ;
00582    _activationCount++ ;
00583    COUT2 << "ACTIVE DOMAIN: "
00584          << inset
00585          << "Activating Domain \""
00586          << _impl->label()
00587          << "\""
00588          << endl ;
00589    delete [] inset ;
00590    return _impl->activate() ;
00591 }
00592 
00593 BdbStatus
00594 BdbDomainOODB::deactivate() const
00595 {
00596    if( 0 == _activationCount ) {
00597       ErrMsg( fatal ) << "No activate domain, so can not deactivate one!"
00598                       << endmsg ;
00599       ::abort() ;
00600    }
00601    _activationCount-- ;
00602    char* inset = new char[ _activationCount + 1 ] ;
00603    for( d_ULong depth( 0 ) ;
00604         _activationCount != depth ;
00605         depth++ ) {
00606       inset[ depth ] = ' ' ;
00607    }
00608    inset[ _activationCount ] = '\0' ;
00609    COUT2 << "ACTIVE DOMAIN: "
00610          << inset
00611          << "Deactivating Domain \""
00612          << _impl->label()
00613          << "\""
00614          << endl ;
00615    delete [] inset ;
00616    return _impl->deactivate() ;
00617 }
00618   
00619 BdbStatus 
00620 BdbDomainOODB::startUpdate( const char* theTag )
00621 {
00622     activate() ;
00623     return _impl->startUpdate( theTag ) ;
00624 }
00625 
00626 BdbStatus 
00627 BdbDomainOODB::startRead( const char* theTag )
00628 {
00629     activate() ;
00630     return _impl->startRead( theTag );
00631 }
00632 
00633 BdbStatus 
00634 BdbDomainOODB::abort( const char* theTag )
00635 {
00636     BdbStatus result( _impl->abort( theTag ) );
00637     deactivate() ;
00638     return result ;
00639 }
00640 
00641 BdbStatus 
00642 BdbDomainOODB::commit( const char* theTag )
00643 {
00644     BdbStatus result( _impl->commit( theTag ) );
00645     deactivate() ;
00646     return result ;
00647 }
00648 
00649 BdbStatus 
00650 BdbDomainOODB::commitAndHold( const char* theTag )
00651 {
00652     BdbStatus result( _impl->commitAndHold( theTag ) );
00653     deactivate() ;
00654     return result ;
00655 }
00656 
00657 BdbStatus 
00658 BdbDomainOODB::checkPoint( const char* theTag )
00659 {
00660     return checkPoint( noOpCheckPoint() ,
00661                        theTag ) ;
00662 }
00663 
00664 BdbStatus 
00665 BdbDomainOODB::checkPoint( BdbCheckPointFunc& theFunction ,
00666                            const char* theTag )
00667 {
00668     activate() ;
00669     BdbStatus result( _impl->checkPoint( theFunction ,
00670                                          theTag ) );
00671     deactivate() ;
00672     return result ;
00673 }
00674 
00675 BdbMode
00676 BdbDomainOODB::change( BdbMode theMode, d_Boolean forceCommit , const char* theTag )
00677 {
00678     activate() ;
00679     BdbMode result( _impl->change( theMode, forceCommit, theTag ) );
00680     deactivate() ;
00681     return result ;
00682 }
00683 
00684 BdbStatus 
00685 BdbDomainOODB::closeAllAndReopen( const char* theTag )
00686 {
00687     return closeAllAndReopen( noOpNoOpen() ,
00688                               theTag ) ;
00689 }
00690 
00691 BdbStatus 
00692 BdbDomainOODB::closeAllAndReopen( BdbNoOpenTransFunc& theFunction ,
00693                                   const char* theTag )
00694 {
00695     activate() ;
00696     BdbStatus result( _impl->closeAllAndReopen( theFunction ,
00697                                                 theTag ) );
00698     deactivate() ;
00699     return result ;
00700 }
00701 
00702 BdbMode
00703 BdbDomainOODB::mode( ) const
00704 {
00705     return _impl->mode( );
00706 }
00707 
00708 const char*
00709 BdbDomainOODB::modeName() const
00710 {
00711     return _impl->modeName();
00712 }
00713 
00714 const char*
00715 BdbDomainOODB::modeName( BdbMode mode )
00716 {
00717     return _impl->modeName( mode ) ;
00718 }
00719 
00720 BdbNestingOptToken
00721 BdbDomainOODB::issueOptToken()
00722 {
00723     return _impl->issueOptToken() ;
00724 }
00725 
00726 void
00727 BdbDomainOODB::releaseOptToken( BdbNestingOptToken optToken )
00728 {
00729     _impl->releaseOptToken( optToken ) ;
00730 }
00731 
00732 BdbStatus
00733 BdbDomainOODB::startNestedRead( BdbNestingOptToken optToken )
00734 {
00735     activate() ;
00736     return _impl->startNestedRead( optToken ) ;
00737 }
00738 
00739 BdbStatus
00740 BdbDomainOODB::startNestedUpdate( BdbNestingOptToken optToken )
00741 {
00742     activate() ;
00743     return _impl->startNestedUpdate( optToken ) ;
00744 }
00745 
00746 BdbStatus
00747 BdbDomainOODB::commitNested( BdbNestingOptToken optToken )
00748 {
00749     BdbStatus result( _impl->commitNested( optToken ) );
00750     deactivate() ;
00751     return result ;
00752 }
00753 
00754 //      -----------------------------------------
00755 //      -- Private Function Member Definitions --
00756 //      -----------------------------------------
00757 
00758 const BdbDomainOODB*
00759 BdbDomainOODB::matchLabel( const char* label ,
00760                            const BdbDomainOODB* loopStart ) const
00761 {
00762    if( 0 == strcmp( label ,
00763                     _impl->label() ) ) {
00764       return( this ) ;
00765    }
00766 
00767    if( loopStart == _next ) {
00768       return( 0 ) ;
00769    }
00770    return( _next->matchLabel( label ,
00771                               loopStart ) ) ;
00772 }
00773 
00774 void
00775 BdbDomainOODB::addToRing( BdbDomainOODB* predecessor )
00776 {
00777    if( ( 0 != _next ) ||
00778        ( 0 != _previous ) ) {
00779       ErrMsg( fatal ) << "Can not add BdbDomainOODB to a ring as it is"
00780                       << " already in one!"
00781                       << endmsg ;
00782       ::abort() ;
00783    }
00784 
00785    if( 0 == predecessor ) {
00786       _next = this ;
00787       _previous = this ;
00788       return ;
00789    }
00790 
00791    // Set local pointers for ring
00792    _next = predecessor->_next ;
00793    _previous = _next->_previous ;
00794    if( predecessor != _previous ) {
00795       ErrMsg( fatal ) << "BdbDomainOODB ring structure broken!"
00796                       << endmsg ;
00797       ::abort() ;
00798    }
00799 
00800    // place this BdbDomainOODB in ring
00801    _next->_previous = this ;
00802    _previous->_next = this ;
00803 }
00804 
00805 void
00806 BdbDomainOODB::removeFromRing()
00807 {
00808    if( ( 0== _next ) ||
00809        ( 0 == _previous ) ) {
00810       ErrMsg( fatal ) << "Can not remove BdbDomainOODB from a ring as it is"
00811                       << " not in one!"
00812                       << endmsg ;
00813       ::abort() ;
00814    }
00815 
00816    _next->_previous = _previous ;
00817    _previous->_next = _next ;
00818 
00819    _next = 0 ;
00820    _previous = 0 ;
00821 }

 


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

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