| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# AppMgrRunable.cpp

Go to the documentation of this file.

    00001 // $Id: AppMgrRunable.cpp,v 1.8 2008/06/02 14:21:35 marcocle Exp $
    00002 #define  GAUDISVC_APPMGRRUNABLE_CPP
    00003
    00004 #include "GaudiKernel/SmartIF.h"
    00005 #include "GaudiKernel/SvcFactory.h"
    00006 #include "GaudiKernel/IAppMgrUI.h"
    00007 #include "GaudiKernel/ISvcLocator.h"
    00008
    00009 #include "AppMgrRunable.h"
    00010
    00011 // Instantiation of a static factory class used by clients to create instances of this service
    00012
    00013 DECLARE_SERVICE_FACTORY(AppMgrRunable)
    00014
    00015 // Standard Constructor
    00016 AppMgrRunable::AppMgrRunable(const std::string& nam, ISvcLocator* svcLoc)
    00017 : Service(nam, svcLoc), m_appMgrUI(0)
    00018 {
    00019   declareProperty("EvtMax", m_evtMax=0xFEEDBABE);
    00020 }
    00021
    00022 // Standard Destructor
    00023 AppMgrRunable::~AppMgrRunable()
    00024 {
    00025 }
    00026
    00027 // IInterface implementation : queryInterface
    00028 StatusCode AppMgrRunable::queryInterface(const InterfaceID& riid, void** ppvInterface)   {
    00029   if ( riid == IID_IRunable )   {
    00030     *ppvInterface = (IRunable*)this;
    00031   }
    00032   else  {
    00033     return Service::queryInterface(riid, ppvInterface);
    00034   }
    00035   addRef();
    00036   return StatusCode::SUCCESS;
    00037 }
    00038
    00039 // IService implementation: initialize the service
    00040 StatusCode AppMgrRunable::initialize()   {
    00041   StatusCode sc = Service::initialize();
    00042   if ( sc.isSuccess() )     {
    00043     sc = serviceLocator()->queryInterface(IID_IAppMgrUI, pp_cast<void>(&m_appMgrUI));
    00044     // get property from application manager
    00045     if ( m_evtMax == (int)0xFEEDBABE )   {
    00046       SmartIF<IProperty> props(IID_IProperty, serviceLocator());
    00047       setProperty(props->getProperty("EvtMax")).ignore();
    00048     }
    00049   }
    00050   return sc;
    00051 }
    00052
    00053 // IService implementation: initialize the service
    00054 StatusCode AppMgrRunable::start()   {
    00055   StatusCode sc = Service::start();
    00056   return sc;
    00057 }
    00058
    00059 // IService implementation: initialize the service
    00060 StatusCode AppMgrRunable::stop()   {
    00061   StatusCode sc = Service::stop();
    00062   return sc;
    00063 }
    00064
    00065 // IService implementation: finalize the service
    00066 StatusCode AppMgrRunable::finalize()     {
    00067   StatusCode sc = Service::finalize();
    00068   if ( 0 != m_appMgrUI ) m_appMgrUI->release();
    00069   m_appMgrUI = 0;
    00070   return sc;
    00071 }
    00072
    00073 // IRunable implementation : Run the class implementation
    00074 StatusCode AppMgrRunable::run()   {
    00075   if ( 0 != m_appMgrUI )    {
    00076     // loop over the events
    00077     return m_appMgrUI->nextEvent(m_evtMax);
    00078   }
    00079   return StatusCode::FAILURE;
    00080 }