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  

/BdbModules/BdbEventUpdate.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: BdbEventUpdate.cc,v 1.14 2001/12/06 23:46:10 patton Exp $
00004 //
00005 // Description:
00006 //      Class BdbEventUpdate implementation file.
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Author List:
00012 //      David R. Quarrie        Original Author
00013 //
00014 // Copyright Information:
00015 //      Copyright (C) 1997      Lawrence Berkeley National Laboratory
00016 //
00017 //------------------------------------------------------------------------
00018 #include "BaBar/BaBar.hh"
00019 
00020 //-----------------------
00021 // This Class's Header --
00022 //-----------------------
00023 #include "BdbModules/BdbEventUpdate.hh"
00024 
00025 //-------------
00026 // C Headers --
00027 //-------------
00028 #include <stdlib.h>
00029 
00030 //-------------------------------
00031 // Collaborating Class Headers --
00032 //-------------------------------
00033 #include "BdbModules/BdbEventMerge.hh"
00034 #include "BdbModules/BdbEventInput.hh"
00035 #include "BdbModules/BdbAbsLoad.hh"
00036 #include "BdbScribes/BdbConversionManager.hh"
00037 #include "BdbEvent/BdbEventT.hh"
00038 #include "ProxyDict/Ifd.hh"
00039 #include "AbsEvent/AbsEvent.hh"
00040 #include "ErrLogger/ErrLog.hh"
00041 
00042 //------------------------------------
00043 // Collaborating Class Declarations --
00044 //------------------------------------
00045 #include "BdbEvent/BdbEvent_ref.hh"
00046 
00047 //-----------------------------------------------------------------------
00048 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00049 //-----------------------------------------------------------------------
00050 
00051 //              ----------------------------------------
00052 //              -- Public Function Member Definitions --
00053 //              ----------------------------------------
00054 
00055 //----------------
00056 // Constructors --
00057 //----------------
00058 
00059 BdbEventUpdate::BdbEventUpdate( const char* const theName, 
00060                                 const char* const theDescription )
00061    : AppModule( theName, theDescription ) ,
00062      _keyToSecondaryEvent( "keyToSecondaryEvent" ,
00063                            this ,
00064                            BdbEventMerge::primaryKey().asString() )
00065 {
00066   commands()->append( &_keyToSecondaryEvent ) ;
00067 }
00068 
00069 //--------------
00070 // Destructor --
00071 //--------------
00072 
00073 BdbEventUpdate::~BdbEventUpdate( )
00074 {
00075 }
00076 
00077 //-------------
00078 // Methods   --
00079 //-------------
00080 
00081 AppResult
00082 BdbEventUpdate::event( AbsEvent* anEvent )
00083 {
00084   if ( _verbose.value() ) {
00085      ErrMsg( trace ) << name()
00086                      << " event"
00087                      << endmsg ;
00088   }
00089 
00090   AbsEvent* eventToUse( anEvent ) ;
00091   
00092   // If key is set to a secondary event get that event
00093   if( BdbEventMerge::primaryKey() != _keyToSecondaryEvent.value() ) {
00094      eventToUse = Ifd< AbsEvent >::get( anEvent ,
00095                                         _keyToSecondaryEvent.value() ) ;
00096   }
00097 
00098   // If there is no event to work on, do nothing.
00099   if ( 0 == eventToUse ) {
00100      return AppResult::OK ;
00101   }
00102 
00103   // Get conversion manager from transient event
00104   BdbConversionManager* conversionManager( 0 ) ;
00105   conversionManager = Ifd< BdbConversionManager >::get( eventToUse ) ;
00106   if ( 0 == conversionManager ) {
00107       ErrMsg( fatal ) << name()
00108                       << ": failed to find ConversionManager in Event."
00109                       << endmsg ;
00110       ::abort() ;
00111   }
00112 
00113   // Check to see if input is required
00114   if ( ! conversionManager->inputRequired() ) {
00115      return AppResult::OK ;
00116   }
00117 
00118   // Get persistent event from transient event.
00119   BdbEventT* eventT( 0 ) ;
00120   eventT = Ifd< BdbEventT >::get( eventToUse ,
00121                                   BdbEventInput::bdbEventKey() );
00122   if ( eventT == 0 ) {
00123      if( BdbEventMerge::primaryKey() != _keyToSecondaryEvent.value() ) {
00124         ErrMsg( fatal ) << name()
00125                         << ": Couldn't find persitent event inside"
00126                         << " secondary event with key "
00127                         << ((IfdStrKey&)(_keyToSecondaryEvent.value())).asString()
00128                         << endmsg ;
00129         ::abort() ;
00130      }
00131      ErrMsg( fatal ) << name()
00132                      << ": Couldn't find persitent event inside"
00133                      << " primary event."
00134                      << endmsg ;
00135      ::abort() ;
00136   }
00137 
00138   // Now actually tell conversion manager to initiate
00139   // input
00140   conversionManager->convertToTransient( *eventT ,
00141                                          *eventToUse ) ;
00142 
00143   return AppResult::OK ;
00144 }
00145 
00146 void
00147 BdbEventUpdate::help( int argc, char** argv )
00148 {
00149    ErrMsg( routine )
00150       << "This is a BdbEventUpdate module named \""
00151       << name()
00152       << "\" and it is\n"
00153       << "responsible for updating a transient event so that is contains\n"
00154       << "all the event objects that have been specified by preceeding\n"
00155       << "xxxBdbLoad modules that are matched to the specified event.\n"
00156       << endmsg ;
00157    ErrMsg( routine )
00158       << "This module has one parameter:\n"
00159       << "\tkeyToSecondaryEvent: The Key used by a BdbEventMerge module\n"
00160       << "\t  to label the secondary event that this module is to\n"
00161       << "\t  update. A value of \""
00162       << BdbEventMerge::primaryKey().asString()
00163       << "\", which is the normal value,\n"
00164       << "\t  implies that this module should update the primary event\n"
00165       << "\t  and not a secondary event.\n"
00166       << endmsg ;
00167    ErrMsg( routine )
00168       << "The current value is as follows."
00169       << endmsg ;
00170 
00171    AppModule::help( argc, argv ) ;
00172 }
00173     
00174 //-------------
00175 // Selectors --
00176 //-------------

 


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

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