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  

/BdbScribes/BdbPersPushPullUtility.cc

Go to the documentation of this file.
00001 #if !defined(BDBPERSPUSHPULLUTILITY_CC)
00002 #define BDBPERSPUSHPULLUTILITY_CC
00003 //--------------------------------------------------------------------------
00004 // File and Version Information:
00005 //      $Id: BdbPersPushPullUtility.cc,v 1.4 2002/06/21 19:42:44 ryd Exp $
00006 //
00007 // Description:
00008 //      Class BdbPersPushPullUtility
00009 //        provide type independent implementations of PushPull functions.
00010 //
00011 // Environment:
00012 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00013 //
00014 // Author List:
00015 //      Simon Patton            Originator
00016 //
00017 // Copyright Information:
00018 //      Copyright (C) 1999      LBNL
00019 //
00020 //------------------------------------------------------------------------
00021 
00022 //-----------------------
00023 // This Class's Header --
00024 //-----------------------
00025 #include "BdbScribes/BdbPersPushPullUtility.hh"
00026 
00027 //-------------
00028 // C Headers --
00029 //-------------
00030 extern "C" {
00031 }
00032 
00033 //---------------
00034 // C++ Headers --
00035 //---------------
00036 
00037 //----------------
00038 // BaBar Header --
00039 //----------------
00040 #include "BaBar/BaBar.hh"
00041 
00042 //-------------------------------
00043 // Collaborating Class Headers --
00044 //-------------------------------
00045 
00046 #include "BdbEvent/BdbEventT.hh"
00047 #include "BdbTrees/BdbTreeHdrT.hh"
00048 #include "BdbTrees/BdbTreeHdr.hh"
00049 #include "BdbClustering/BdbAbsPlacementManager.hh"
00050 #include "BdbUtil/BdbAbstractClusteringHint.hh"
00051 #include "ErrLogger/ErrLog.hh"
00052 
00053 //------------------------------------
00054 // Collaborating Class Declarations --
00055 //------------------------------------
00056 #include "BdbEvent/BdbEvent_ref.hh"
00057 
00058 //-----------------------------------------------------------------------
00059 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00060 //-----------------------------------------------------------------------
00061 
00062 //              -----------------------------------------------
00063 //              -- Static Data & Function Member Definitions --
00064 //              -----------------------------------------------
00065 
00066 BdbTreeHdrT
00067 BdbPersPushPullUtility::findHeader( const BdbEventT& aEvent ,
00068                                     const char* aName )
00069 {
00070    return( aEvent.findHeader( (const char*)aName ) ) ;
00071 }
00072 
00073 BdbTreeHdrT
00074 BdbPersPushPullUtility::getHeader( BdbEventT& aEvent ,
00075                                    const char* aName ,
00076                                    const BdbAbsPlacementManager& aPlacementManager )
00077 {
00078    // Find the Header if it exists.
00079    BdbTreeHdrT existingHeader( findHeader( aEvent ,
00080                                            aName ) ) ;
00081 
00082    // If header exists then finish.
00083    if( ! existingHeader.isNull( ) ) {
00084 
00085       // If header is borrowed, then abort
00086       // (dont in two step to keep OSF happy).
00087       if ( ! aEvent.ownsHeader( existingHeader ) ) {
00088          ErrMsg( fatal ) << "Event is only borrowing \""
00089                          << aName
00090                          << "\" header"
00091                          << ", can not write new data into it!"
00092                          << endmsg ;
00093          ::abort() ;
00094       }
00095       return( existingHeader ) ;
00096    }
00097 
00098    // Otherwise create header
00099    BdbAbstractClusteringHint* hint( aPlacementManager.getHeaderHint( aName ) ) ;
00100 
00101    // If the header's hint can not be found then the header name is
00102    //   not valid.
00103    if( 0 == hint ) {
00104       ErrMsg( fatal ) << "BdbPersPushPullUtility: Request for invalid header ("
00105                       << aName
00106                       << ")"
00107                       << endmsg ;
00108       ::abort();
00109    }
00110 
00111    // Get the persistent event to create the necessary header.
00112    BdbRefAny place( hint->hint() ) ;
00113    BdbTreeHdrT createdHeader( aEvent.createHeader( place ,
00114                                                    aName ) ) ;
00115 
00116    // If header now exists then finish.
00117    if( ! createdHeader.isNull() ) {
00118       return( createdHeader ) ;
00119    }
00120       
00121    // If the header is not successfully created the is an error.
00122    ErrMsg( fatal ) << "BdbPersPushPullUtility: Unable to create a new header ("
00123                    << aName
00124                    << ") in persistent event"
00125                    << endmsg ;
00126    ::abort() ;
00127    return( createdHeader ) ;
00128 }
00129 
00130 
00131 //              ---------------------------------
00132 //              -- Member Function Definitions --
00133 //              ---------------------------------
00134 
00135 //----------------
00136 // Constructors --
00137 //----------------
00138 
00139 // BdbPersPushPullUtility::BdbPersPushPullUtility( const BdbPersPushPullUtility& aRhs )
00140 // {
00141 // }
00142 
00143 //--------------
00144 // Destructor --
00145 //--------------
00146 
00147 //-------------
00148 // Operators --
00149 //-------------
00150     
00151 // const BdbPersPushPullUtility& BdbPersPushPullUtility::operator=( const BdbPersPushPullUtility& aRhs )
00152 // {
00153 // }
00154 
00155 //-------------
00156 // Selectors --
00157 //-------------
00158 
00159 //-------------
00160 // Modifiers --
00161 //-------------
00162 
00163 #endif // BDBPERSPUSHPULLUTILITY_CC

 


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

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