Gaudi Framework, version v20r3

Generated: 24 Nov 2008

Service Class Reference

#include <Service.h>

Inheritance diagram for Service:

Inheritance graph
[legend]
Collaboration diagram for Service:

Collaboration graph
[legend]

List of all members.


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.


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.

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

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 482 of file Service.cpp.

00482                                                             {
00483   m_name       = name;
00484   m_refCount   = 0;
00485   m_svcLocator = svcloc;
00486   m_svcManager = 0;
00487   m_messageSvc = 0;
00488   m_state      = Gaudi::StateMachine::OFFLINE;
00489   m_targetState = Gaudi::StateMachine::OFFLINE;
00490   m_propertyMgr = new PropertyMgr();
00491   m_pAuditorSvc = 0;
00492   m_outputLevel = MSG::NIL;
00493   // Declare common Service properties with their defaults
00494   if ( name != "MessageSvc" )  {
00495     m_outputLevel = msgSvc()->outputLevel();
00496   }
00497   declareProperty( "OutputLevel", m_outputLevel);
00498   m_outputLevel.declareUpdateHandler(&Service::initOutputLevel, this);
00499 
00500   // Get the default setting for service auditing from the AppMgr
00501   declareProperty( "AuditServices", m_auditInit=true );
00502 
00503   IProperty *appMgr;
00504   bool audit(false);
00505   if (m_svcLocator->service("ApplicationMgr", appMgr, false).isSuccess()) {
00506     const Property& prop = appMgr->getProperty("AuditServices");
00507     Property &pr = const_cast<Property&>(prop);
00508     if (m_name != "IncidentSvc") {
00509       setProperty( pr ).ignore();
00510       audit = m_auditInit.value();
00511     } else {
00512       audit = false;
00513     }
00514   }
00515 
00516   declareProperty( "AuditInitialize"   , m_auditorInitialize   = audit );
00517   declareProperty( "AuditStart"        , m_auditorStart        = audit );
00518   declareProperty( "AuditStop"         , m_auditorStop         = audit );
00519   declareProperty( "AuditFinalize"     , m_auditorFinalize     = audit );
00520   declareProperty( "AuditReInitialize" , m_auditorReinitialize = audit );
00521   declareProperty( "AuditReStart"      , m_auditorRestart      = audit );
00522 
00523 }

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

Standard Destructor.

Definition at line 533 of file Service.cpp.

00533                   {
00534   delete m_propertyMgr;
00535 }


Member Function Documentation

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 GslSvc, ConversionSvc, DataSvc, MinimalEventLoopMgr, DataListenerSvc, PoolDbCacheSvc, PoolDbCnvSvc, PoolDbEvtSelector, PythonScriptingSvc, AIDATupleSvc, AlgContextSvc, AppMgrRunable, AuditorSvc, ChronoStatSvc, CounterSvc, MultiStoreSvc, DetDataSvc, EventCollectionSelector, EventSelector, ExceptionSvc, FastContainersSvc, HistogramSvc, HistorySvc, DataOnDemandSvc, IncidentSvc, IssueLogger, JobOptionsSvc, MessageSvc, NTupleSvc, ParticlePropertySvc, PersistencySvc, RndmEngine, RndmGenSvc, StatusCodeSvc, THistSvc, ToolSvc, VFSSvc, Gaudi::IODataManager, Gaudi::MultiFileCatalog, and PartPropSvc.

Definition at line 39 of file Service.cpp.

00041 {
00042   if ( 0 == ppvi ) { return StatusCode::FAILURE ; } // RETURN
00043   //
00044   if      ( IService        ::interfaceID() . versionMatch ( riid ) )
00045   { *ppvi = static_cast<IService*>        ( this ) ; }
00046   else if ( IProperty       ::interfaceID() . versionMatch ( riid ) )
00047   { *ppvi = static_cast<IProperty*>       ( this ) ; }
00048   else if ( IStateful       ::interfaceID() . versionMatch ( riid ) )
00049   { *ppvi = static_cast<IStateful*>       ( this ) ; }
00050   else if ( INamedInterface ::interfaceID() . versionMatch ( riid ) )
00051   { *ppvi = static_cast<INamedInterface*> ( this ) ; }
00052   else if ( IInterface      ::interfaceID() . versionMatch ( riid ) )
00053   { *ppvi = static_cast<IInterface*>      ( this ) ; }
00054   else { *ppvi = 0 ; return NO_INTERFACE ; } // RETURN
00055   // increment reference counter
00056   addRef();
00057   //
00058   return SUCCESS;
00059 }

unsigned long Service::addRef (  )  [virtual]

Reference Interface instance.

Implements IInterface.

Definition at line 20 of file Service.cpp.

00020                                 {
00021   m_refCount++;
00022   return m_refCount;
00023 }

unsigned long Service::release (  )  [virtual]

Release Interface instance.

Implements IInterface.

Definition at line 26 of file Service.cpp.

00026                                  {
00027   unsigned long count = --m_refCount;
00028   if( count == 0) {
00029     if (m_svcManager!=0) {
00030       m_svcManager->removeService(this).ignore();
00031     }
00032     delete this;
00033   }
00034   return count;
00035 }

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

Retrieve name of the service.

Implements INamedInterface.

Definition at line 385 of file Service.cpp.

00385                                        {
00386   return m_name;
00387 }

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

Retrieve ID of the Service.

Implements IService.

Reimplemented in ParticlePropertySvc, and PartPropSvc.

Definition at line 390 of file Service.cpp.

00390                                         {
00391   return IID_IService;
00392 }

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; }

StatusCode Service::initialize (  )  [virtual]

StatusCode Service::start (  )  [virtual]

Start (from INITIALIZED to RUNNING).

Implements IService.

Reimplemented in MinimalEventLoopMgr, and AppMgrRunable.

Definition at line 193 of file Service.cpp.

00193                           {
00194   // stub implementation
00195   return StatusCode::SUCCESS;
00196 }

StatusCode Service::stop (  )  [virtual]

Stop (from RUNNING to INITIALIZED).

Implements IService.

Reimplemented in MinimalEventLoopMgr, AppMgrRunable, and EventLoopMgr.

Definition at line 187 of file Service.cpp.

00187                          {
00188   // stub implementation
00189   return StatusCode::SUCCESS;
00190 }

StatusCode Service::finalize (  )  [virtual]

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; }

StatusCode Service::reinitialize (  )  [virtual]

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

Implements IService.

Reimplemented in DataSvc, MinimalEventLoopMgr, AIDATupleSvc, EventLoopMgr, EvtDataSvc, MultiStoreSvc, DetDataSvc, EventSelector, FastContainersSvc, HistogramSvc, HistorySvc, DataOnDemandSvc, IssueLogger, MessageSvc, NTupleSvc, HistogramPersistencySvc, StatusCodeSvc, and THistSvc.

Definition at line 344 of file Service.cpp.

00344                                  {
00345   /* @TODO
00346    * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
00347    *                 is causing too many problems
00348    *
00349   // Default implementation is finalize+initialize
00350   StatusCode sc = finalize();
00351   if (sc.isFailure()) {
00352     MsgStream log ( msgSvc() , name() );
00353     log << MSG::ERROR << "reinitialize(): cannot be finalized" << endreq;
00354     return sc;
00355   }
00356   sc = initialize();
00357   if (sc.isFailure()) {
00358     MsgStream log ( msgSvc() , name() );
00359     log << MSG::ERROR << "reinitialize(): cannot be initialized" << endreq;
00360     return sc;
00361   }
00362   */
00363   return StatusCode::SUCCESS;
00364 }

StatusCode Service::restart (  )  [virtual]

Initialization (from RUNNING to RUNNING, via INITIALIZED).

Implements IService.

Reimplemented in MinimalEventLoopMgr.

Definition at line 367 of file Service.cpp.

00367                             {
00368   // Default implementation is stop+start
00369   StatusCode sc = stop();
00370   if (sc.isFailure()) {
00371     MsgStream log ( msgSvc() , name() );
00372     log << MSG::ERROR << "restart(): cannot be stopped" << endreq;
00373     return sc;
00374   }
00375   sc = start();
00376   if (sc.isFailure()) {
00377     MsgStream log ( msgSvc() , name() );
00378     log << MSG::ERROR << "restart(): cannot be started" << endreq;
00379     return sc;
00380   }
00381   return StatusCode::SUCCESS;
00382 }

StatusCode Service::sysInitialize (  )  [virtual]

Initilize Service.

Implements IService.

Reimplemented in AuditorSvc.

Definition at line 62 of file Service.cpp.

00062                                   {
00063   StatusCode sc;
00064 
00065   try {
00066     m_targetState = Gaudi::StateMachine::INITIALIZED;
00067     Gaudi::Guards::AuditorGuard guard(this,
00068                                       // check if we want to audit the initialize
00069                                       (m_auditorInitialize) ? auditorSvc() : 0,
00070                                       IAuditor::Initialize);
00071     sc = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
00072     if (sc.isSuccess())
00073       m_state = m_targetState;
00074     return sc;
00075   }
00076   catch ( const GaudiException& Exception )  {
00077     MsgStream log ( msgSvc() , name() );
00078     log << MSG::FATAL << "in sysInitialize(): exception with tag=" << Exception.tag()
00079         << " is caught" << endreq;
00080     log << MSG::ERROR << Exception  << endreq;
00081     //    Stat stat( chronoSvc() , Exception.tag() );
00082   }
00083   catch( const std::exception& Exception ) {
00084     MsgStream log ( msgSvc() , name() );
00085     log << MSG::FATAL << "in sysInitialize(): standard std::exception is caught" << endreq;
00086     log << MSG::ERROR << Exception.what()  << endreq;
00087     //    Stat stat( chronoSvc() , "*std::exception*" );
00088   }
00089   catch(...) {
00090     MsgStream log ( msgSvc() , name() );
00091     log << MSG::FATAL << "in sysInitialize(): UNKNOWN Exception is caught" << endreq;
00092     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00093   }
00094 
00095   return StatusCode::FAILURE;
00096 }

StatusCode Service::sysStart (  )  [virtual]

Initilize Service.

Implements IService.

Definition at line 112 of file Service.cpp.

00112                              {
00113   StatusCode sc;
00114 
00115   try {
00116     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
00117     Gaudi::Guards::AuditorGuard guard(this,
00118                                       // check if we want to audit the initialize
00119                                       (m_auditorStart) ? auditorSvc() : 0,
00120                                       IAuditor::Start);
00121     sc = start();
00122     if (sc.isSuccess())
00123       m_state = m_targetState;
00124     return sc;
00125   }
00126   catch ( const GaudiException& Exception )  {
00127     MsgStream log ( msgSvc() , name() );
00128     log << MSG::FATAL << "in sysStart(): exception with tag=" << Exception.tag()
00129         << " is caught" << endreq;
00130     log << MSG::ERROR << Exception  << endreq;
00131     //    Stat stat( chronoSvc() , Exception.tag() );
00132   }
00133   catch( const std::exception& Exception ) {
00134     MsgStream log ( msgSvc() , name() );
00135     log << MSG::FATAL << "in sysStart(): standard std::exception is caught" << endreq;
00136     log << MSG::ERROR << Exception.what()  << endreq;
00137     //    Stat stat( chronoSvc() , "*std::exception*" );
00138   }
00139   catch(...) {
00140     MsgStream log ( msgSvc() , name() );
00141     log << MSG::FATAL << "in sysStart(): UNKNOWN Exception is caught" << endreq;
00142     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00143   }
00144 
00145   return StatusCode::FAILURE;
00146 }

StatusCode Service::sysStop (  )  [virtual]

Initilize Service.

Implements IService.

Definition at line 149 of file Service.cpp.

00149                             {
00150   StatusCode sc;
00151 
00152   try {
00153     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
00154     Gaudi::Guards::AuditorGuard guard(this,
00155                                       // check if we want to audit the initialize
00156                                       (m_auditorStop) ? auditorSvc() : 0,
00157                                       IAuditor::Stop);
00158     sc = stop();
00159     if (sc.isSuccess())
00160       m_state = m_targetState;
00161     return sc;
00162   }
00163   catch ( const GaudiException& Exception )  {
00164     MsgStream log ( msgSvc() , name() );
00165     log << MSG::FATAL << "in sysStop(): exception with tag=" << Exception.tag()
00166         << " is caught" << endreq;
00167     log << MSG::ERROR << Exception  << endreq;
00168     //    Stat stat( chronoSvc() , Exception.tag() );
00169   }
00170   catch( const std::exception& Exception ) {
00171     MsgStream log ( msgSvc() , name() );
00172     log << MSG::FATAL << "in sysStop(): standard std::exception is caught" << endreq;
00173     log << MSG::ERROR << Exception.what()  << endreq;
00174     //    Stat stat( chronoSvc() , "*std::exception*" );
00175   }
00176   catch(...) {
00177     MsgStream log ( msgSvc() , name() );
00178     log << MSG::FATAL << "in sysStop(): UNKNOWN Exception is caught" << endreq;
00179     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00180   }
00181 
00182   return StatusCode::FAILURE;
00183 }

StatusCode Service::sysFinalize (  )  [virtual]

Finalize Service.

Implements IService.

Reimplemented in AuditorSvc.

Definition at line 199 of file Service.cpp.

00199                                 {
00200 
00201   StatusCode sc(StatusCode::FAILURE);
00202 
00203   try {
00204     m_targetState = Gaudi::StateMachine::OFFLINE;
00205     Gaudi::Guards::AuditorGuard guard(this,
00206                                       // check if we want to audit the initialize
00207                                       (m_auditorFinalize) ? auditorSvc() : 0,
00208                                       IAuditor::Finalize);
00209     sc = finalize();
00210     if (sc.isSuccess())
00211       m_state = m_targetState;
00212   }
00213   catch( const GaudiException& Exception ) {
00214     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00215     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00216         << " is caught " << endreq;
00217     log << MSG::ERROR << Exception  << endreq;
00218     //    Stat stat( chronoSvc() , Exception.tag() ) ;
00219   }
00220   catch( const std::exception& Exception ) {
00221     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00222     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
00223     log << MSG::ERROR << Exception.what()  << endreq;
00224     //    Stat stat( chronoSvc() , "*std::exception*" ) ;
00225   }
00226   catch( ... ) {
00227     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00228     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
00229     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00230   }
00231 
00232   if( m_messageSvc ) {
00233     m_messageSvc->release();
00234     m_messageSvc = 0;
00235   }
00236   if( m_pAuditorSvc ) {
00237     m_pAuditorSvc->release();
00238     m_pAuditorSvc = 0;
00239   }
00240 
00241   return sc ;
00242 
00243 }

StatusCode Service::sysReinitialize (  )  [virtual]

Re-initialize the Service.

Implements IService.

Definition at line 253 of file Service.cpp.

00253                                     {
00254 
00255   StatusCode sc;
00256 
00257   // Check that the current status is the correct one.
00258   if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
00259     MsgStream log ( msgSvc() , name() );
00260     log << MSG::ERROR
00261         << "sysReinitialize(): cannot reinitialize service not initialized"
00262         << endreq;
00263     return StatusCode::FAILURE;
00264   }
00265 
00266   try {
00267 
00268     Gaudi::Guards::AuditorGuard guard(this,
00269                                       // check if we want to audit the initialize
00270                                       (m_auditorReinitialize) ? auditorSvc() : 0,
00271                                       IAuditor::ReInitialize);
00272     sc = reinitialize();
00273     return sc;
00274   }
00275   catch( const GaudiException& Exception ) {
00276     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
00277     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00278         << " is caught " << endreq;
00279     log << MSG::ERROR << Exception  << endreq;
00280     //    Stat stat( chronoSvc() , Exception.tag() ) ;
00281   }
00282   catch( const std::exception& Exception ) {
00283     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
00284     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
00285     log << MSG::ERROR << Exception.what()  << endreq;
00286     //    Stat stat( chronoSvc() , "*std::exception*" ) ;
00287   }
00288   catch( ... ) {
00289     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
00290     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
00291     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00292   }
00293   return StatusCode::FAILURE ;
00294 
00295 }

StatusCode Service::sysRestart (  )  [virtual]

Re-initialize the Service.

Implements IService.

Definition at line 298 of file Service.cpp.

00298                                {
00299 
00300   StatusCode sc;
00301 
00302   // Check that the current status is the correct one.
00303   if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
00304     MsgStream log ( msgSvc() , name() );
00305     log << MSG::ERROR
00306         << "sysRestart(): cannot restart service in state " << FSMState()
00307         << " -- must be RUNNING "
00308         << endreq;
00309     return StatusCode::FAILURE;
00310   }
00311 
00312   try {
00313 
00314     Gaudi::Guards::AuditorGuard guard(this,
00315                                       // check if we want to audit the initialize
00316                                       (m_auditorRestart) ? auditorSvc() : 0,
00317                                       IAuditor::ReStart);
00318     sc = restart();
00319     return sc;
00320   }
00321   catch( const GaudiException& Exception ) {
00322     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
00323     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
00324         << " is caught " << endreq;
00325     log << MSG::ERROR << Exception  << endreq;
00326     //    Stat stat( chronoSvc() , Exception.tag() ) ;
00327   }
00328   catch( const std::exception& Exception ) {
00329     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
00330     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
00331     log << MSG::ERROR << Exception.what()  << endreq;
00332     //    Stat stat( chronoSvc() , "*std::exception*" ) ;
00333   }
00334   catch( ... ) {
00335     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
00336     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
00337     //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
00338   }
00339   return StatusCode::FAILURE ;
00340 
00341 }

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

Set the property by property.

Implements IProperty.

Reimplemented in JobOptionsSvc.

Definition at line 429 of file Service.cpp.

00429                                                  {
00430   return m_propertyMgr->setProperty(p);
00431 }

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

Set the property by string.

Implements IProperty.

Definition at line 433 of file Service.cpp.

00433                                                   {
00434   return m_propertyMgr->setProperty(s);
00435 }

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

Set the property by std::string.

Implements IProperty.

Definition at line 437 of file Service.cpp.

00437                                                                       {
00438   return m_propertyMgr->setProperty(n,v);
00439 }

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

Get the property by property.

Implements IProperty.

Reimplemented in JobOptionsSvc.

Definition at line 441 of file Service.cpp.

00441                                                  {
00442   return m_propertyMgr->getProperty(p);
00443 }

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

Get the property by name.

Implements IProperty.

Definition at line 445 of file Service.cpp.

00445                                                              {
00446   return m_propertyMgr->getProperty(n);
00447 }

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

Get the property by std::string.

Implements IProperty.

Definition at line 449 of file Service.cpp.

00449                                                                        {
00450   return m_propertyMgr->getProperty(n,v);
00451 }

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

Get list of properties.

Implements IProperty.

Definition at line 453 of file Service.cpp.

00453                                                          {
00454   return m_propertyMgr->getProperties();
00455 }

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.

Definition at line 395 of file Service.cpp.

00395                                            {
00396   return m_svcLocator;
00397 }

IMessageSvc * Service::msgSvc (  ) 

Retrieve pointer to message service.

Definition at line 400 of file Service.cpp.

00400                                 {
00401   if ( 0 == m_messageSvc ) {
00402     StatusCode sc = serviceLocator()->service( "MessageSvc", m_messageSvc, true );
00403     if( sc.isFailure() ) {
00404       throw GaudiException("Service [MessageSvc] not found", name(), sc);
00405     }
00406   }
00407   return m_messageSvc;
00408 }

IMessageSvc * Service::msgSvc (  )  const

Definition at line 410 of file Service.cpp.

00410                                      {
00411   if ( 0 == m_messageSvc ) {
00412     StatusCode sc = serviceLocator()->service( "MessageSvc", m_messageSvc, true );
00413     if( sc.isFailure() ) {
00414       throw GaudiException("Service [MessageSvc] not found", name(), sc);
00415     }
00416   }
00417   return m_messageSvc;
00418 }

IMessageSvc * Service::messageService (  ) 

Definition at line 420 of file Service.cpp.

00420                                         {
00421   return msgSvc();
00422 }

IMessageSvc * Service::messageService (  )  const

Definition at line 423 of file Service.cpp.

00423                                              {
00424   return msgSvc();
00425 }

StatusCode Service::setProperties (  ) 

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

Definition at line 458 of file Service.cpp.

00458                                   {
00459   IJobOptionsSvc* jos;
00460   const bool CREATEIF(true);
00461   StatusCode sc = serviceLocator()->service( "JobOptionsSvc", jos, CREATEIF );
00462   if( sc.isFailure() ) {
00463     throw GaudiException("Service [JobOptionsSvc] not found", name(), sc);
00464   }
00465   // set first generic Properties
00466   sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
00467   if( sc.isFailure() ) return StatusCode::FAILURE;
00468 
00469   // set specific Properties
00470   if (isGaudiThreaded(name())) {
00471     if (jos->setMyProperties( name(), this ).isFailure()) {
00472       return StatusCode::FAILURE;
00473     }
00474   }
00475   jos->release();
00476   return StatusCode::SUCCESS;
00477 }

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.

Definition at line 557 of file Service.cpp.

00557                                        {
00558   if ( 0 == m_pAuditorSvc ) {
00559     StatusCode sc = service( "AuditorSvc", m_pAuditorSvc, true );
00560     if( sc.isFailure() ) {
00561       throw GaudiException("Service [AuditorSvc] not found", name(), sc);
00562     }
00563   }
00564   return m_pAuditorSvc;
00565 }

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

get the Service's output level

Reimplemented in MessageSvc.

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

Definition at line 539 of file Service.cpp.

00540                                                                {
00541   MsgStream log(msgSvc(), name());
00542   ServiceLocatorHelper helper(*serviceLocator(), log, name());
00543   return helper.getService(svcName, createIf, iid, ppSvc);
00544 }

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

Definition at line 547 of file Service.cpp.

00550                                        {
00551 
00552   MsgStream log(msgSvc(), name());
00553   ServiceLocatorHelper helper(*serviceLocator(), log, name());
00554   return  helper.createService(svcType, svcName, iid, ppSvc);
00555 }

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

Implements IService.

Definition at line 568 of file Service.cpp.

00568                                            {
00569   m_svcManager = ism;
00570 }

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

callback for output level property

Definition at line 526 of file Service.cpp.

00526                                                 {
00527   if ( name() != "MessageSvc" ) {
00528     msgSvc()->setOutputLevel( name(), m_outputLevel );
00529   }
00530 }


Friends And Related Function Documentation

friend class ServiceManager [friend]

Reimplemented from IService.

Definition at line 34 of file Service.h.


Member Data Documentation

Service output level.

Definition at line 226 of file Service.h.

Service state.

Reimplemented in MinimalEventLoopMgr.

Definition at line 228 of file Service.h.

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.

Service Locator reference.

Definition at line 243 of file Service.h.

Definition at line 244 of file Service.h.

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.

Definition at line 260 of file Service.h.

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.

Definition at line 264 of file Service.h.

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 files:

Generated at Mon Nov 24 14:46:28 2008 for Gaudi Framework, version v20r3 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004