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

GaudiEventLoopMgr.cpp

Go to the documentation of this file.
00001 //===================================================================
00002 //      GaudiEventLoopMgr.cpp
00003 //--------------------------------------------------------------------
00004 //
00005 //      Package    : GaudiEventLoopMgr ( The LHCb Offline System)
00006 //
00007 //  Description: implementation of the Application's bacth mode handler
00008 //
00009 //      Author     : M.Frank
00010 //  History    :
00011 // +---------+----------------------------------------------+---------
00012 // |    Date |                 Comment                      | Who     
00013 // +---------+----------------------------------------------+---------
00014 // | 29/10/98| Initial version                              | MF
00015 // +---------+----------------------------------------------+---------
00016 //
00017 //====================================================================
00018 #define  GAUDISVC_GAUDIEVENTLOOPMGR_CPP
00019 
00020 #include "GaudiKernel/SmartIF.h"
00021 #include "GaudiKernel/MsgStream.h"
00022 #include "GaudiKernel/SvcFactory.h"
00023 #include "GaudiKernel/DataSelectionAgent.h"
00024 #include "GaudiKernel/IConversionSvc.h"
00025 #include "GaudiKernel/IAddressCreator.h"
00026 #include "GaudiKernel/IDataManagerSvc.h"
00027 
00028 #include "GaudiEventLoopMgr.h"
00029 
00030 // Instantiation of a static factory class used by clients to create instances of this service
00031 static SvcFactory<GaudiEventLoopMgr> s_GaudiEventLoopMgrFactory;
00032 const ISvcFactory& GaudiEventLoopMgrFactory = s_GaudiEventLoopMgrFactory;
00033 
00034 // Standard Constructor
00035 GaudiEventLoopMgr::GaudiEventLoopMgr(const std::string& nam, ISvcLocator* svcLoc)
00036 : EventLoopMgr(nam, svcLoc)
00037 {
00038   // Initialize other services and selectors
00039   m_histoDataMgrSvc   = 0;
00040   m_histoPersSvc      = 0;
00041   declareProperty("HistogramPersistency", m_histPersName="");
00042 }
00043 
00044 // Standard Destructor
00045 GaudiEventLoopMgr::~GaudiEventLoopMgr()
00046 {
00047 }
00048 
00049 // implementation of IAppMgrUI::initalize
00050 StatusCode GaudiEventLoopMgr::initialize()    {
00051   StatusCode sc = EventLoopMgr::initialize();
00052   MsgStream log(msgSvc(), name());
00053   if ( sc.isSuccess() )     {
00054     //--------------------------------------------------------------------------------------------
00055     // Setup access to histogramming services
00056     //--------------------------------------------------------------------------------------------
00057     sc = serviceLocator()->service("HistogramDataSvc", m_histoDataMgrSvc);
00058     if( !sc.isSuccess() )  {
00059       log << MSG::FATAL << "Error retrieving HistogramDataSvc." << endreq;
00060       return sc;
00061     }
00062     SmartIF<IProperty> prpMgr(IID_IProperty, serviceLocator());
00063     if ( prpMgr.isValid() )   {
00064       if ( m_histPersName.length() == 0 )    {
00065         setProperty(prpMgr->getProperty("HistogramPersistency"));
00066       }
00067       if ( m_histPersName != "NONE" )   {
00068         sc = serviceLocator()->service("HistogramPersistencySvc", m_histoPersSvc );
00069         if( !sc.isSuccess() ) {
00070           log << MSG::WARNING << "Histograms cannot not be saved - though required." << endreq;
00071           return sc;
00072         }
00073       }
00074       else  {
00075         log << MSG::WARNING << "Histograms saving not required." << endreq;
00076       }
00077       return StatusCode::SUCCESS;
00078     }
00079     log << MSG::ERROR << "Error retrieving AppMgr interface IProperty." << endreq;
00080     return StatusCode::FAILURE;
00081   }
00082   else    {
00083     log << MSG::FATAL << "Error Initializing base class EventLoopMgr." << endreq;
00084   }
00085   return sc;
00086 }
00087 
00088 // implementation of IAppMgrUI::finalize
00089 StatusCode GaudiEventLoopMgr::finalize()    {
00090   //--------------------------------------------------------------------------------------------
00091   // Save Histograms Now
00092   //--------------------------------------------------------------------------------------------
00093   StatusCode sc = StatusCode::SUCCESS;
00094   if ( 0 != m_histoPersSvc )    {
00095     DataSelectionAgent agent;
00096     sc = m_histoDataMgrSvc->traverseTree( &agent );
00097     if( sc.isSuccess() )   {
00098       sc = m_histoPersSvc->createReps(agent.selectedObjects());
00099     }
00100     else {
00101       MsgStream log(msgSvc(), name());
00102       log << MSG::ERROR << "Error while traversing Histogram data store" << endreq;
00103     }
00104   }
00105   StatusCode sc2 = EventLoopMgr::finalize();
00106   return sc.isSuccess() && sc2.isSuccess() ? StatusCode::SUCCESS : StatusCode::FAILURE;
00107 }
00108 
00109 // implementation of IAppMgrUI::terminate
00110 StatusCode GaudiEventLoopMgr::terminate()   {
00111   m_histoDataMgrSvc = releaseInterface(m_histoDataMgrSvc);
00112   m_histoPersSvc    = releaseInterface(m_histoPersSvc);
00113   return EventLoopMgr::terminate();
00114 }

Generated at Wed Nov 21 12:22:29 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000