| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Service Class Reference

Base class for all services. More...

#include <Service.h>

Inheritance diagram for Service:

[legend]
Collaboration diagram for Service:
[legend]
List of all members.

Public Types

 SUCCESS = 1
 Normal successful completion.
 NO_INTERFACE
 Requested interface is not available.
 VERSMISMATCH
 Requested interface version is incompatible.
 LAST_ERROR
 Last error.
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...

Public Member Functions

virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 Query interfaces of Interface.
virtual unsigned long addRef ()
 Reference Interface instance.
virtual unsigned long release ()
 Release Interface instance.
virtual const std::string & name () const
 Retrieve name of the service.
virtual const InterfaceIDtype () const
 Retrieve ID of the Service.
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED).
virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING).
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED).
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE).
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state.
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us.
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED).
virtual StatusCode sysInitialize ()
 Initilize Service.
virtual StatusCode sysStart ()
 Initilize Service.
virtual StatusCode sysStop ()
 Initilize Service.
virtual StatusCode sysFinalize ()
 Finalize Service.
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
virtual StatusCode sysRestart ()
 Re-initialize the Service.
virtual StatusCode setProperty (const Property &p)
 Set the property by property.
virtual StatusCode setProperty (const std::string &s)
 Set the property by string.
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string.
virtual StatusCode getProperty (Property *p) const
 Get the property by property.
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name.
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string.
virtual const std::vector<
Property * > & 
getProperties () const
 Get list of properties.
template<class TYPE>
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
ISvcLocatorserviceLocator () const
 Retrieve pointer to service locator.
IMessageSvcmsgSvc ()
 Retrieve pointer to message service.
IMessageSvcmsgSvc () const
IMessageSvcmessageService ()
IMessageSvcmessageService () const
StatusCode setProperties ()
 Method for setting declared properties to the values specifed for the job.
template<class T>
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
template<class T>
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
template<class T>
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
IAuditorSvcauditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.

Static Public Member Functions

static const InterfaceIDinterfaceID ()
 Retrieve interface ID.
static const InterfaceIDinterfaceID ()
 Retrieve interface ID.
static const InterfaceIDinterfaceID ()
 Retrieve interface ID.

Protected Member Functions

virtual ~Service ()
 Standard Destructor.
int outputLevel () const
 get the Service's output level

Protected Attributes

IntegerProperty m_outputLevel
 Service output level.
Gaudi::StateMachine::State m_state
 Service state.
Gaudi::StateMachine::State m_targetState
 Service state.
IMessageSvcm_messageSvc
 MessageSvc reference.

Private Member Functions

StatusCode service_i (const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
 implementation of service method
StatusCode service_i (const std::string &svcType, const std::string &svcName, const InterfaceID &iid, void **ppSvc) const
void setServiceManager (ISvcManager *)
void initOutputLevel (Property &prop)
 callback for output level property

Private Attributes

std::string m_name
 Service Name.
unsigned long m_refCount
 Reference counter.
ISvcLocatorm_svcLocator
 Service Locator reference.
ISvcManagerm_svcManager
PropertyMgrm_propertyMgr
 Property Manager.
IAuditorSvcm_pAuditorSvc
 Auditor Service.
BooleanProperty m_auditInit
bool m_auditorInitialize
bool m_auditorStart
bool m_auditorStop
bool m_auditorFinalize
bool m_auditorReinitialize
bool m_auditorRestart

Friends

class ServiceManager

Detailed Description

Base class for all services.

It implements the IService and IProperty interfaces.

Author:
Pere Mato

Definition at line 30 of file Service.h.


Member Enumeration Documentation

enum IInterface::Status [inherited]

Return status.

Enumerator:
SUCCESS  Normal successful completion.
NO_INTERFACE  Requested interface is not available.
VERSMISMATCH  Requested interface version is incompatible.
LAST_ERROR  Last error.

Reimplemented in IConversionSvc, IConverter, and IDataProviderSvc.

Definition at line 113 of file IInterface.h.

00113                 {
00115     SUCCESS = 1,
00117     NO_INTERFACE,
00119     VERSMISMATCH,
00121     LAST_ERROR
00122   };


Constructor & Destructor Documentation

Service::Service ( const std::string &  name,
ISvcLocator svcloc 
)

Standard Constructor.

virtual Service::~Service (  )  [protected, virtual]

Standard Destructor.


Member Function Documentation

virtual StatusCode Service::queryInterface ( const InterfaceID riid,
void **  ppvUnknown 
) [virtual]

Query interfaces of Interface.

Parameters:
riid ID of Interface to be retrieved
ppvUnknown Pointer to Location for interface pointer

Implements IInterface.

Reimplemented in ConversionSvc, DataSvc, and MinimalEventLoopMgr.

virtual unsigned long Service::addRef (  )  [virtual]

Reference Interface instance.

Implements IInterface.

virtual unsigned long Service::release (  )  [virtual]

Release Interface instance.

Implements IInterface.

virtual const std::string& Service::name (  )  const [virtual]

Retrieve name of the service.

Implements INamedInterface.

virtual const InterfaceID& Service::type (  )  const [virtual]

Retrieve ID of the Service.

Implements IService.

virtual StatusCode Service::configure (  )  [inline, virtual]

Configuration (from OFFLINE to CONFIGURED).

Implements IService.

Definition at line 53 of file Service.h.

00053 { return StatusCode::SUCCESS; }

virtual StatusCode Service::initialize (  )  [virtual]

Initialization (from CONFIGURED to INITIALIZED).

Implements IService.

Reimplemented in ConversionSvc, DataSvc, and MinimalEventLoopMgr.

virtual StatusCode Service::start (  )  [virtual]

Start (from INITIALIZED to RUNNING).

Implements IService.

Reimplemented in MinimalEventLoopMgr.

virtual StatusCode Service::stop (  )  [virtual]

Stop (from RUNNING to INITIALIZED).

Implements IService.

Reimplemented in MinimalEventLoopMgr.

virtual StatusCode Service::finalize (  )  [virtual]

Finalize (from INITIALIZED to CONFIGURED).

Implements IService.

Reimplemented in ConversionSvc, DataSvc, and MinimalEventLoopMgr.

virtual StatusCode Service::terminate (  )  [inline, virtual]

Initialization (from CONFIGURED to OFFLINE).

Implements IService.

Definition at line 58 of file Service.h.

00058 { return StatusCode::SUCCESS; }

virtual Gaudi::StateMachine::State Service::FSMState (  )  const [inline, virtual]

Get the current state.

Implements IService.

Definition at line 59 of file Service.h.

00059 { return m_state; }

virtual Gaudi::StateMachine::State Service::targetFSMState (  )  const [inline, virtual]

When we are in the middle of a transition, get the state where the transition is leading us.

Otherwise it returns the same state as state().

Implements IService.

Definition at line 60 of file Service.h.

00060 { return m_targetState; }

virtual StatusCode Service::reinitialize (  )  [virtual]

Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).

Implements IService.

Reimplemented in DataSvc, and MinimalEventLoopMgr.

virtual StatusCode Service::restart (  )  [virtual]

Initialization (from RUNNING to RUNNING, via INITIALIZED).

Implements IService.

Reimplemented in MinimalEventLoopMgr.

virtual StatusCode Service::sysInitialize (  )  [virtual]

Initilize Service.

Implements IService.

virtual StatusCode Service::sysStart (  )  [virtual]

Initilize Service.

Implements IService.

virtual StatusCode Service::sysStop (  )  [virtual]

Initilize Service.

Implements IService.

virtual StatusCode Service::sysFinalize (  )  [virtual]

Finalize Service.

Implements IService.

virtual StatusCode Service::sysReinitialize (  )  [virtual]

Re-initialize the Service.

Implements IService.

virtual StatusCode Service::sysRestart (  )  [virtual]

Re-initialize the Service.

Implements IService.

virtual StatusCode Service::setProperty ( const Property p  )  [virtual]

Set the property by property.

Implements IProperty.

virtual StatusCode Service::setProperty ( const std::string &  s  )  [virtual]

Set the property by string.

Implements IProperty.

virtual StatusCode Service::setProperty ( const std::string &  n,
const std::string &  v 
) [virtual]

Set the property by std::string.

Implements IProperty.

virtual StatusCode Service::getProperty ( Property p  )  const [virtual]

Get the property by property.

Implements IProperty.

virtual const Property& Service::getProperty ( const std::string &  name  )  const [virtual]

Get the property by name.

Implements IProperty.

virtual StatusCode Service::getProperty ( const std::string &  n,
std::string &  v 
) const [virtual]

Get the property by std::string.

Implements IProperty.

virtual const std::vector<Property*>& Service::getProperties (  )  const [virtual]

Get list of properties.

Implements IProperty.

template<class TYPE>
StatusCode Service::setProperty ( const std::string &  name,
const TYPE &  value 
) [inline]

set the property form the value

  std::vector<double> data = ... ;
  setProperty( "Data" , data ) ;
  
  std::map<std::string,double> cuts = ... ;
  setProperty( "Cuts" , cuts ) ;

  std::map<std::string,std::string> dict = ... ;
  setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convinient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

    setProperty ( "OutputLevel" , "1"    ) ;
    setProperty ( "Enable"      , "True" ) ;
    setProperty ( "ErrorMax"    , "10"   ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters:
name name of the property
value value of the property
See also:
Gaudi::Utils::setProperty
Author:
Vanya BELYAEV ibelyaev@physics.syr.edu
Date:
2007-05-13

Definition at line 128 of file Service.h.

00130   { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }

ISvcLocator* Service::serviceLocator (  )  const

Retrieve pointer to service locator.

IMessageSvc* Service::msgSvc (  ) 

Retrieve pointer to message service.

IMessageSvc* Service::msgSvc (  )  const

IMessageSvc* Service::messageService (  ) 

IMessageSvc* Service::messageService (  )  const

StatusCode Service::setProperties (  ) 

Method for setting declared properties to the values specifed for the job.

template<class T>
StatusCode Service::service ( const std::string &  name,
T *&  psvc,
bool  createIf = true 
) const [inline]

Access a service by name, creating it if it doesn't already exist.

Definition at line 152 of file Service.h.

00152                                                                                     {
00153     return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
00154   }

template<class T>
StatusCode Service::service ( const std::string &  svcType,
const std::string &  svcName,
T *&  psvc 
) const [inline]

Access a service by name and type, creating it if it doesn't already exist.

Definition at line 159 of file Service.h.

00160                                       {
00161     return service_i(svcType, svcName, T::interfaceID(), (void**)&psvc);
00162   }

template<class T>
Property* Service::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
) const [inline]

Declare the named property.

  MySvc ( const std::string& name , 
          ISvcLocator*       pSvc ) 
     : Service ( name , pSvc ) 
     , m_property1   ( ... )
     , m_property2   ( ... )
   {
     // declare the property 
     declareProperty( "Property1" , m_property1 , "Doc fro property #1" ) ;

     // declare the property and attach the handler  to it
     declareProperty( "Property2" , m_property2 , "Doc for property #2" ) 
        -> declareUpdateHandler( &MyAlg::handler_2 ) ;
  
   }

See also:
PropertyMgr

PropertyMgr::declareProperty

Parameters:
name the property name
proeprty the property itself,
doc the documentation string
Returns:
the actual property objects

Definition at line 194 of file Service.h.

00197   { 
00198     return m_propertyMgr -> declareProperty ( name , property , doc ) ;
00199   }

Property* Service::declareRemoteProperty ( const std::string &  name,
IProperty rsvc,
const std::string &  rname = "" 
) const [inline]

Declare remote named properties.

This is used to declare as a local property a property of another services or algorithm. The only needed information is IProperty interface of the remote service and the its property name if different of the current one.

Parameters:
name Local property name
rsvc Remote IProperty interface
rname Name of the property at remote service

Definition at line 210 of file Service.h.

00213   {
00214         return m_propertyMgr -> declareRemoteProperty ( name , rsvc , rname ) ;
00215   }

IAuditorSvc* Service::auditorSvc (  )  const

The standard auditor service.May not be invoked before sysInitialize() has been invoked.

int Service::outputLevel (  )  const [inline, protected]

get the Service's output level

Definition at line 235 of file Service.h.

00235 { return m_outputLevel.value(); }

StatusCode Service::service_i ( const std::string &  svcName,
bool  createIf,
const InterfaceID iid,
void **  ppSvc 
) const [private]

implementation of service method

StatusCode Service::service_i ( const std::string &  svcType,
const std::string &  svcName,
const InterfaceID iid,
void **  ppSvc 
) const [private]

void Service::setServiceManager ( ISvcManager  )  [private, virtual]

Implements IService.

void Service::initOutputLevel ( Property prop  )  [private]

callback for output level property

static const InterfaceID& IService::interfaceID (  )  [inline, static, inherited]

Retrieve interface ID.

Reimplemented from INamedInterface.

Reimplemented in IAuditorSvc, IChronoStatSvc, IHistorySvc, IIssueLogger, IMagneticFieldSvc, IParticlePropertySvc, IPartPropSvc, IRndmGenSvc, IStatusCodeSvc, and ITHistSvc.

Definition at line 26 of file IService.h.

00026 { return IID_IService; }

static const InterfaceID& IProperty::interfaceID (  )  [inline, static, inherited]

Retrieve interface ID.

Reimplemented from IInterface.

Definition at line 28 of file IProperty.h.

00028 { return IID_IProperty; }

static const InterfaceID& IStateful::interfaceID (  )  [inline, static, inherited]

Retrieve interface ID.

Reimplemented from IInterface.

Definition at line 23 of file IStateful.h.

00023 { return IID_IStateful; }


Friends And Related Function Documentation

friend class ServiceManager [friend]

Reimplemented from IService.

Definition at line 34 of file Service.h.


Member Data Documentation

IntegerProperty Service::m_outputLevel [protected]

Service output level.

Definition at line 226 of file Service.h.

Gaudi::StateMachine::State Service::m_state [protected]

Service state.

Reimplemented in MinimalEventLoopMgr.

Definition at line 228 of file Service.h.

Gaudi::StateMachine::State Service::m_targetState [protected]

Service state.

Definition at line 230 of file Service.h.

IMessageSvc* Service::m_messageSvc [mutable, protected]

MessageSvc reference.

Definition at line 232 of file Service.h.

std::string Service::m_name [private]

Service Name.

Definition at line 239 of file Service.h.

unsigned long Service::m_refCount [private]

Reference counter.

Definition at line 241 of file Service.h.

ISvcLocator* Service::m_svcLocator [private]

Service Locator reference.

Definition at line 243 of file Service.h.

ISvcManager* Service::m_svcManager [private]

Definition at line 244 of file Service.h.

PropertyMgr* Service::m_propertyMgr [private]

Property Manager.

Definition at line 246 of file Service.h.

IAuditorSvc* Service::m_pAuditorSvc [mutable, private]

Auditor Service.

Definition at line 259 of file Service.h.

BooleanProperty Service::m_auditInit [private]

Definition at line 260 of file Service.h.

bool Service::m_auditorInitialize [private]

Definition at line 261 of file Service.h.

bool Service::m_auditorStart [private]

Definition at line 262 of file Service.h.

bool Service::m_auditorStop [private]

Definition at line 263 of file Service.h.

bool Service::m_auditorFinalize [private]

Definition at line 264 of file Service.h.

bool Service::m_auditorReinitialize [private]

Definition at line 265 of file Service.h.

bool Service::m_auditorRestart [private]

Definition at line 266 of file Service.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:13 2011 for GaudiKernel by doxygen 1.4.7