| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# ApplicationMgr.h

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiSvc/src/ApplicationMgr/ApplicationMgr.h,v 1.34 2008/11/10 15:29:09 marcocle Exp $   //
    00002 #ifndef GAUDI_APPLICATIONMGR_H
    00003 #define GAUDI_APPLICATIONMGR_H
    00004
    00005 #include "GaudiKernel/Kernel.h"
    00006 #include "GaudiKernel/IAppMgrUI.h"
    00007 #include "GaudiKernel/IEventProcessor.h"
    00008 #include "GaudiKernel/IProperty.h"
    00009 #include "GaudiKernel/IStateful.h"
    00010 #include "GaudiKernel/IComponentManager.h"
    00011 #include "GaudiKernel/IAlgorithm.h"
    00012 #include "GaudiKernel/IAlgManager.h"
    00013 #include "GaudiKernel/ISvcManager.h"
    00014 #include "GaudiKernel/Service.h"
    00015 #include "GaudiKernel/CommonMessaging.h"
    00016 #include "GaudiKernel/PropertyMgr.h"
    00017
    00018 // STL include files
    00019 #include <list>
    00020 #include <vector>
    00021
    00022 // Forward declarations
    00023 class ISvcLocator;
    00024 class ServiceManager;
    00025 class AlgorithmManager;
    00026 class DLLClassManager;
    00027
    00028 class IMessageSvc;
    00029 class IIncidentSvc;
    00030 class IRunable;
    00031 class IDataManagerSvc;
    00032 class IConversionSvc;
    00033 class IJobOptionsSvc;
    00034
    00047 class ApplicationMgr : public CommonMessaging<implements4<IAppMgrUI,
    00048                                                           IEventProcessor,
    00049                                                           IService,
    00050                                                           IStateful> > {
    00051   typedef CommonMessaging<implements4<IAppMgrUI,
    00052                                       IEventProcessor,
    00053                                       IService,
    00054                                       IStateful> > base_class;
    00055 public:
    00056   typedef std::list<std::pair<IService*,int> >  ListSvc;
    00057   typedef std::list<std::string>   ListName;
    00058   typedef std::vector<std::string> VectorName;
    00059
    00060 public:
    00061
    00062   // default creator
    00063   ApplicationMgr(IInterface* = 0);
    00064   // virtual destructor
    00065   virtual ~ApplicationMgr();
    00066
    00067   // implementation of IInterface::queryInterface
    00068   virtual StatusCode queryInterface(const InterfaceID& iid, void** pinterface);
    00069
    00070   // implementation of IAppMgrUI::run
    00071   virtual StatusCode run();
    00072   // implementation of IAppMgrUI::configure
    00073   virtual StatusCode configure();
    00074   // implementation of IAppMgrUI::terminate
    00075   virtual StatusCode terminate();
    00076   // implementation of IAppMgrUI::initialize
    00077   virtual StatusCode initialize();
    00078   // implementation of IAppMgrUI::start
    00079   virtual StatusCode start();
    00080   // implementation of IAppMgrUI::stop
    00081   virtual StatusCode stop();
    00082   // implementation of IAppMgrUI::finalize
    00083   virtual StatusCode finalize();
    00084   // implementation of IAppMgrUI::nextEvent
    00085   virtual StatusCode nextEvent(int maxevt);
    00086   // implementation of IAppMgrUI::name
    00087   virtual const std::string&  name() const;
    00089   virtual StatusCode executeEvent(void* par);
    00091   virtual StatusCode executeRun(int evtmax);
    00093   virtual StatusCode stopRun();
    00094
    00095   // implementation of IStateful::state
    00096   virtual Gaudi::StateMachine::State FSMState() const;
    00097   // implementation of IStateful::targetState
    00098   virtual Gaudi::StateMachine::State targetFSMState() const;
    00099   // implementation of IStateful::reinitialize
    00100   virtual StatusCode reinitialize();
    00101   // implementation of IStateful::reinitialize
    00102   virtual StatusCode restart();
    00103   // implementation of IService::sysItinitilaize
    00104   virtual StatusCode sysInitialize() { return StatusCode::SUCCESS; }
    00105   // implementation of IService::sysStart
    00106   virtual StatusCode sysStart() { return StatusCode::SUCCESS; }
    00107   // implementation of IService::sysStop
    00108   virtual StatusCode sysStop() { return StatusCode::SUCCESS; }
    00109   // implementation of IService::sysFinalize
    00110   virtual StatusCode sysFinalize() { return StatusCode::SUCCESS; }
    00111   // implementation of IService::sysReinitialize
    00112   virtual StatusCode sysReinitialize() { return StatusCode::SUCCESS; }
    00113   // implementation of IService::sysRestart
    00114   virtual StatusCode sysRestart() { return StatusCode::SUCCESS; }
    00115
    00116   // SI Go Handler
    00117   void       SIGoHandler             ( Property& theProp );
    00118   // SI Exit handler
    00119   void       SIExitHandler           ( Property& theProp );
    00120
    00122
    00123   void       evtLoopPropertyHandler  ( Property& theProp );
    00124   StatusCode decodeExtSvcNameList    ( );
    00125   StatusCode decodeCreateSvcNameList ( );
    00126   void createSvcNameListHandler(Property &);
    00127   void       extSvcNameListHandler   ( Property& theProp );
    00128   StatusCode decodeMultiThreadSvcNameList( );
    00129   void  multiThreadSvcNameListHandler( Property& theProp );
    00130   StatusCode decodeDllNameList       ( );
    00131   void       dllNameListHandler      ( Property& theProp );
    00132   void       reflexDebugPropertyHandler ( Property& theProp );
    00133   void       initLoopCheckHndlr      ( Property& );
    00135
    00136   template <class I>
    00137   SmartIF<IComponentManager> &getManager() {
    00138     return m_managers[I::interfaceID().id()];
    00139   }
    00140
    00141   inline SmartIF<ISvcManager> &svcManager() {
    00142     // Cache the casted pointer to ISvcManager
    00143     if (!m_svcManager) {
    00144       m_svcManager = getManager<IService>();
    00145     }
    00146     return m_svcManager;
    00147   }
    00148
    00149   inline SmartIF<IAlgManager> &algManager() {
    00150     // Cache the casted pointer to IAlgManager
    00151     if (!m_algManager) {
    00152       m_algManager = getManager<IAlgorithm>();
    00153     }
    00154     return m_algManager;
    00155   }
    00156
    00158   virtual SmartIF<ISvcLocator>& serviceLocator() const {
    00159     return m_svcLocator;
    00160   }
    00161
    00162 protected:
    00164   StatusCode declareMultiSvcType(const std::string& name,
    00165                                  const std::string& type);
    00167   StatusCode addMultiSvc(const Gaudi::Utils::TypeNameString &typeName,
    00168                          int prio);
    00169
    00170   // implementation of IService::setServiceManager
    00171   void setServiceManager(ISvcManager*) {}
    00172
    00174   StatusCode i_startup();
    00175
    00180   StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures = false);
    00181
    00184   typedef std::map<unsigned long, SmartIF<IComponentManager> > ManagersMap;
    00188   ManagersMap         m_managers;
    00190   StringArrayProperty m_declaredManagers;
    00191
    00193   SmartIF<ISvcManager> m_svcManager;
    00194
    00196   SmartIF<IAlgManager> m_algManager;
    00197
    00198
    00199   // data members
    00200   DLLClassManager*    m_classManager;
    00201   mutable SmartIF<ISvcLocator> m_svcLocator;
    00202
    00203   IntegerProperty     m_SIGo;
    00204   IntegerProperty     m_SIExit;
    00205   StringArrayProperty m_topAlgNameList;
    00206   StringArrayProperty m_outStreamNameList;
    00207   StringProperty      m_outStreamType;
    00208   StringProperty      m_messageSvcType;
    00209   StringProperty      m_jobOptionsSvcType;
    00210
    00211
    00212   ListSvc             m_topSvcList;
    00213   ListName            m_topSvcNameList;
    00214
    00215   std::string         m_name;
    00216   Gaudi::StateMachine::State m_state;
    00217   Gaudi::StateMachine::State m_targetState;
    00218
    00219   VectorName          m_defServices;
    00220   VectorName          m_svcMapping;
    00221   VectorName          m_svcOptMapping;
    00222
    00223   PropertyMgr*        m_propertyMgr;
    00224   SmartIF<IMessageSvc>      m_messageSvc;
    00225   SmartIF<IRunable>         m_runable;
    00226   SmartIF<IEventProcessor>  m_processingMgr;
    00227   SmartIF<IJobOptionsSvc>   m_jobOptionsSvc;
    00228
    00229   //
    00230   // The public ApplicationMgr properties
    00231   //
    00232
    00233   int                  m_evtMax;
    00234   StringArrayProperty  m_extSvcNameList;
    00235   BooleanProperty      m_extSvcCreates;
    00236
    00238   StringArrayProperty  m_multiThreadSvcNameList;
    00239   int                  m_noOfEvtThreads;
    00240
    00241   StringArrayProperty  m_dllNameList;
    00242   std::string          m_jobOptionsType;
    00243   std::string          m_jobOptionsPath;
    00244   std::string          m_runableType;
    00245   std::string          m_eventLoopMgr;
    00246   std::string          m_evtsel;
    00247   std::string          m_histPersName;
    00248   int                  m_outputLevel;
    00249   std::string          m_appName;
    00250   std::string          m_appVersion;
    00251   bool                 m_actHistory;
    00252   bool                 m_codeCheck;
    00253   IntegerProperty      m_reflexDebugLevel;
    00254
    00255   StringArrayProperty  m_createSvcNameList;
    00256
    00258   BooleanProperty      m_auditTools;
    00259   BooleanProperty      m_auditSvcs;
    00260   BooleanProperty      m_auditAlgs;
    00261
    00262   std::map<std::string,std::string> m_environment;
    00263
    00265   BooleanProperty      m_loopCheck;
    00266
    00269   BooleanProperty      m_stopOnSignal;
    00270
    00273   BooleanProperty      m_stalledEventMonitoring;
    00274
    00275   // Flag to activate the printout of properties
    00276   bool                 m_propertiesPrint ;
    00277
    00279   IntegerProperty      m_returnCode;
    00280
    00281 private:
    00282    std::vector<std::string> m_okDlls;
    00283 };
    00284 #endif  // GAUDI_APPLICATIONMGR_H