All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ToolSvc Class Reference

This service manages tools. More...

#include <src/ApplicationMgr/ToolSvc.h>

Inheritance diagram for ToolSvc:
Collaboration diagram for ToolSvc:

Public Types

typedef std::list< IAlgTool * > ListTools
 
- Public Types inherited from extends1< Service, IToolSvc >
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1
< IToolSvc
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< IToolSvc >
typedef IToolSvc::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 

Public Member Functions

virtual StatusCode initialize ()
 Initialize the service. More...
 
virtual StatusCode finalize ()
 Finalize the service. More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode retrieve (const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf)
 Retrieve tool, create it by default as common tool if it does not already exist. More...
 
virtual StatusCode retrieve (const std::string &tooltype, const std::string &toolname, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf)
 Retrieve tool, create it by default as common tool if it does not already exist. More...
 
virtual std::vector< std::string > getInstances (const std::string &toolType)
 Get names of all tool instances of a given type. More...
 
virtual StatusCode releaseTool (IAlgTool *tool)
 Release tool. More...
 
StatusCode create (const std::string &type, const IInterface *parent, IAlgTool *&tool)
 Create Tool standard way with automatically assigned name. More...
 
StatusCode create (const std::string &type, const std::string &name, const IInterface *parent, IAlgTool *&tool)
 Create Tool standard way with specified name. More...
 
bool existsTool (const std::string &toolname) const
 Check if the tool instance exists. More...
 
std::string nameTool (const std::string &nameByUser, const IInterface *parent)
 Get Tool full name by combining nameByUser and "parent" part. More...
 
unsigned long refCountTool (IAlgTool *tool) const
 Get current refcount for tool. More...
 
 ToolSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
virtual ~ToolSvc ()
 Destructor. More...
 
virtual void registerObserver (IToolSvc::Observer *obs)
 
virtual void unRegisterObserver (IToolSvc::Observer *obs)
 
- Public Member Functions inherited from extends1< Service, IToolSvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
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. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< IToolSvc >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IToolSvc
 DeclareInterfaceID (IToolSvc, 2, 0)
 InterfaceID. More...
 
template<class T >
StatusCode retrieveTool (const std::string &type, T *&tool, const IInterface *parent=0, bool createIf=true)
 Retrieve specified tool sub-type with tool dependent part of the name automatically assigned. More...
 
template<class T >
StatusCode retrieveTool (const std::string &type, const std::string &name, T *&tool, const IInterface *parent=0, bool createIf=true)
 Retrieve specified tool sub-type with tool dependent part of the name tool dependent part of the name specified by the requester. More...
 

Private Member Functions

unsigned long totalToolRefCount () const
 The total number of refCounts on all tools in the instancesTools list. More...
 
unsigned long totalToolRefCount (const ListTools &) const
 The total number of refCounts on all tools in the list. More...
 
unsigned long minimumToolRefCount () const
 The minimum number of refCounts of all tools. More...
 
StatusCode finalizeTool (IAlgTool *itool) const
 Finalize the given tool, with exception handling. More...
 

Private Attributes

ListTools m_instancesTools
 Common Tools. More...
 
IHistorySvcm_pHistorySvc
 Pointer to HistorySvc. More...
 
std::vector< IToolSvc::Observer * > m_observers
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

This service manages tools.

Tools can be common, in which case a single instance can be shared by different algorithms, or private in which case it is necessary to specify the parent when requesting it. The parent of a tool can be an algortihm or a Service The environment of a tool is set by using that of the parent. A common tool is considered to belong to the ToolSvc itself.

Author
G. Corti, P. Mato

Definition at line 23 of file ToolSvc.h.

Member Typedef Documentation

typedef std::list<IAlgTool*> ToolSvc::ListTools

Definition at line 28 of file ToolSvc.h.

Constructor & Destructor Documentation

ToolSvc::ToolSvc ( const std::string &  name,
ISvcLocator svc 
)

Standard Constructor.

Parameters
nameString with service name
svcPointer to service locator interface

Definition at line 31 of file ToolSvc.cpp.

33  : base_class(name, svc),
34  m_pHistorySvc(0)
35  { }
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:108
extends1 base_class
Typedef to this class.
Definition: extends.h:12
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
ToolSvc::~ToolSvc ( )
virtual

Destructor.

Definition at line 38 of file ToolSvc.cpp.

40 {
41 
42 }

Member Function Documentation

StatusCode ToolSvc::create ( const std::string &  type,
const IInterface parent,
IAlgTool *&  tool 
)

Create Tool standard way with automatically assigned name.

Definition at line 420 of file ToolSvc.cpp.

424 {
425  const std::string & toolname = tooltype;
426  return create( tooltype, toolname, parent, tool);
427 }
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:420
tuple toolname
Definition: gaudirun.py:291
StatusCode ToolSvc::create ( const std::string &  type,
const std::string &  name,
const IInterface parent,
IAlgTool *&  tool 
)

Create Tool standard way with specified name.

invoke create callbacks...

Definition at line 479 of file ToolSvc.cpp.

484 {
485  // protect against empty type
486  if ( UNLIKELY(tooltype.empty()) ) {
487  error() << "create(): No Tool Type given" << endmsg;
488  return StatusCode::FAILURE;
489  }
490 
491  // If parent has not been specified, assume it is the ToolSvc
492  if ( 0 == parent ) parent = this;
493 
494  tool = 0;
495  // Automatically deletes the tool if not explicitly kept (i.e. on success).
496  // The tool is removed from the list of known tools too.
497  ToolCreateGuard toolguard(m_instancesTools);
498 
499  // Check if the tool already exist : this should never happen
500  const std::string fullname = nameTool(toolname, parent);
501  if( UNLIKELY(existsTool(fullname)) ) {
502  error() << "Tool " << fullname << " already exists" << endmsg;
503  return StatusCode::FAILURE;
504  }
505  // instantiate the tool using the factory
506  try {
507  toolguard = AlgTool::Factory::create(tooltype, tooltype, fullname, parent);
508  if ( UNLIKELY(! toolguard.get()) ){
509  error() << "Cannot create tool " << tooltype << " (No factory found)" << endmsg;
510  return StatusCode::FAILURE;
511  }
512  }
513  catch ( const GaudiException& Exception ) {
514  // (1) perform the printout of message
515  fatal() << "Exception with tag=" << Exception.tag()
516  << " is caught whilst instantiating tool '" << tooltype << "'" << endmsg;
517  // (2) print the exception itself
518  // (NB! - GaudiException is a linked list of all "previous exceptions")
519  fatal() << Exception << endmsg;
520  return StatusCode::FAILURE;
521  }
522  catch( const std::exception& Exception ) {
523  // (1) perform the printout of message
524  fatal() << "Standard std::exception is caught whilst instantiating tool '"
525  << tooltype << "'" << endmsg;
526  // (2) print the exception itself
527  // (NB! - GaudiException is a linked list of all "previous exceptions")
528  fatal() << Exception.what() << endmsg;
529  return StatusCode::FAILURE;
530  }
531  catch(...) {
532  // (1) perform the printout
533  fatal() << "UNKNOWN Exception is caught whilst instantiating tool '"
534  << tooltype << "'" << endmsg;
535  return StatusCode::FAILURE;
536  }
537  ON_VERBOSE verbose() << "Created tool " << tooltype << "/" << fullname << endmsg;
538 
539  // Since only AlgTool has the setProperties() method it is necessary to cast
540  // to downcast IAlgTool to AlgTool in order to set the properties via the JobOptions
541  // service
542  AlgTool* mytool = dynamic_cast<AlgTool*> (toolguard.get());
543  if ( mytool != 0 ) {
544  StatusCode sc = mytool->setProperties();
545  if ( UNLIKELY(sc.isFailure()) ) {
546  error() << "Error setting properties for tool '"
547  << fullname << "'" << endmsg;
548  return sc;
549  }
550  }
551 
552  // Initialize the Tool
554  try {
555  sc = toolguard->sysInitialize();
556  }
557  // Catch any exceptions
558  catch ( const GaudiException & Exception )
559  {
560  error()
561  << "GaudiException with tag=" << Exception.tag()
562  << " caught whilst initializing tool '" << fullname << "'" << endmsg
563  << Exception << endmsg;
564  return StatusCode::FAILURE;
565  }
566  catch( const std::exception & Exception )
567  {
568  error()
569  << "Standard std::exception caught whilst initializing tool '"
570  << fullname << "'" << endmsg << Exception.what() << endmsg;
571  return StatusCode::FAILURE;
572  }
573  catch (...)
574  {
575  error()
576  << "UNKNOWN Exception caught whilst initializing tool '"
577  << fullname << "'" << endmsg;
578  return StatusCode::FAILURE;
579  }
580 
581  // Status of tool initialization
582  if ( UNLIKELY(sc.isFailure()) ) {
583  error() << "Error initializing tool '" << fullname << "'" << endmsg;
584  return sc;
585  }
586 
587  // Start the tool if we are running.
589  sc = toolguard->sysStart();
590 
591  if (UNLIKELY(sc.isFailure())) {
592  error() << "Error starting tool '" << fullname << "'" << endmsg;
593  return sc;
594  }
595  }
596 
597 
598  // The tool has been successfully created and initialized,
599  // so we the guard can be released
600  tool = toolguard.release();
601 
605  if (!m_observers.empty()) {
606  std::for_each( m_observers.begin(),
607  m_observers.end(),
609  bl::_1,
610  tool));
611  }
612  // TODO: replace by generic callback
613  // Register the tool with the HistorySvc
614  if (m_pHistorySvc != 0 ||
615  service("HistorySvc",m_pHistorySvc,false).isSuccess() ) {
617  }
618 
619  return StatusCode::SUCCESS;
620 
621 }
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:108
#define UNLIKELY(x)
Definition: Kernel.h:127
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Define general base for Gaudi exception.
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:245
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:624
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
tuple toolname
Definition: gaudirun.py:291
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:110
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:653
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
StatusCode setProperties()
Method for setting declared properties to the values specified in the jobOptions via the job option s...
Definition: AlgTool.cpp:147
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:235
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode registerAlgTool(const IAlgTool &)=0
virtual const std::string & tag() const
name tag for the exception, or exception type
virtual unsigned long release()=0
Release Interface instance.
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:34
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:142
void ignore() const
Definition: StatusCode.h:94
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_VERBOSE
Definition: ToolSvc.cpp:22
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool ToolSvc::existsTool ( const std::string &  toolname) const

Check if the tool instance exists.

Definition at line 653 of file ToolSvc.cpp.

655 {
656  for ( ListTools::const_iterator it = m_instancesTools.begin();
657  it != m_instancesTools.end(); ++it ) {
658  if ( (*it)->name() == fullname ) { return true; }
659  }
660  return false;
661 }
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
StatusCode ToolSvc::finalize ( )
virtual

Finalize the service.

Algorithm: 2 passes. First pass:

  • do not explicitly release any tools
  • finalize tools, in the order of increasing number of refCounts Second pass:
  • explicitly release all tools, one release() on all tools per loop. -> tools are deleted in the order of increasing number of refCounts.

Inner loop: full loop over all left-over tools

  • finalize tools with the minimum number of refCounts in the list.
  • Remove finalized tools from list of tools, and add them to the list of finalized tools, to be deleted at the end. This way, any non-finalized tools who still reference already finalized tools in their finalize() will still find a live tool. Outer loop: keep on going until nothing changes in the list of tools. Checking for:
  • number of left-over tools
  • total number of refcounts
  • minimum number of refcounts

Reimplemented from Service.

Definition at line 67 of file ToolSvc.cpp.

69 {
70  // Finalize and delete all left-over tools. Normally all tools created with
71  // ToolSvc are left over, since ToolSvc holds a refCount (via AlgTool ctor).
72  // Several cases need to be covered:
73  // 1) Simple dependencies: no circular dependencies between tools,
74  // and tools not using other tools
75  // 2) Tools-using-tools (but no circular dependencies)
76  // a) release() is called in the tool::finalize() (e.g. via GaudiAlgorithm)
77  // b) release() is called in the tool destructor (e.g. via ToolHandle)
78  // 3) Circular dependencies between tools
79  // a) release() is called in the tool::finalize() (e.g. via GaudiAlgorithm)
80  // b) release() is called in the tool destructor (e.g. via ToolHandle)
81  // 4) In addition to each of the above cases, refCounting of a particular tool
82  // might not have been done correctly in the code. Typically release()
83  // is not called, so we are left with a too high refCount.
84  // What to do with those, and how to avoid a crash while handling them...
85 
94  ListTools finalizedTools; // list of tools that have been finalized
95  info() << "Removing all tools created by ToolSvc" << endmsg;
96 
97  // Print out list of tools
98  ON_DEBUG {
99  MsgStream &log = debug();
100  log << " Tool List : ";
101  for ( ListTools::const_iterator iTool = m_instancesTools.begin();
102  iTool != m_instancesTools.end(); ++iTool ) {
103  log << (*iTool)->name() << ":" << refCountTool( *iTool ) << " ";
104  }
105  log << endmsg;
106  }
107 
108  //
109  // first pass: Finalize all tools (but don't delete them)
110  //
123  bool fail(false);
124  size_t toolCount = m_instancesTools.size();
125  unsigned long startRefCount = 0;
126  unsigned long endRefCount = totalToolRefCount();
127  unsigned long startMinRefCount = 0;
128  unsigned long endMinRefCount = minimumToolRefCount();
129  while ( toolCount > 0 &&
130  endRefCount > 0 &&
131  (endRefCount != startRefCount || endMinRefCount != startMinRefCount) ) {
132  ON_DEBUG if ( endMinRefCount != startMinRefCount ) {
133  debug() << toolCount << " tools left to finalize. Summed refCounts: "
134  << endRefCount << endmsg;
135  debug() << "Will finalize tools with refCount <= "
136  << endMinRefCount << endmsg;
137  }
138  startMinRefCount = endMinRefCount;
139  startRefCount = endRefCount;
140  unsigned long maxLoop = toolCount + 1;
141  while ( --maxLoop > 0 && m_instancesTools.size() > 0 ) {
142  IAlgTool* pTool = m_instancesTools.back();
143  // removing tool from list makes ToolSvc::releaseTool( IAlgTool* ) a noop
144  m_instancesTools.pop_back();
145  unsigned long count = refCountTool( pTool );
146  // cache tool name
147  std::string toolName = pTool->name();
148  if ( count <= startMinRefCount ) {
149  ON_DEBUG debug() << " Performing finalization of " << toolName
150  << " (refCount " << count << ")" << endmsg;
151  // finalize of one tool may trigger a release of another tool
152  // pTool->sysFinalize().ignore();
153  if (!finalizeTool(pTool).isSuccess()) {
154  warning() << " FAILURE finalizing " << toolName << endmsg;
155  fail = true;
156  }
157  // postpone deletion
158  finalizedTools.push_back(pTool);
159  } else {
160  // Place back in list to try again later
161  // ToolSvc::releaseTool( IAlgTool* ) remains active for this tool
162  ON_DEBUG debug() << " Delaying finalization of " << toolName
163  << " (refCount " << count << ")" << endmsg;
164  m_instancesTools.push_front(pTool);
165  }
166  } // end of inner loop
167  toolCount = m_instancesTools.size();
168  endRefCount = totalToolRefCount();
169  endMinRefCount = minimumToolRefCount();
170  }; // end of outer loop
171 
172  //
173  // Second pass: Delete all finalized tools
174  //
175  // Delete in the order of increasing number of refCounts.
176  // Loop over tools in the same order as the order in which they were finalized.
177  // All tools in the list of finalized tools are no longer in the instancesTools list.
178  // If a tool destructor calls releaseTool() on another tool, this will have no
179  // effect on the 'other tool' if this 'other tool' is in the list of finalized tools.
180  // If this 'other tool' is still in the instancesTools list, it may trigger finalization
181  // (in releaseTool()), deletion and removal from the instancesTools list.
182  // Therefore, the check on non-finalised tools should happen *after* the deletion
183  // of the finalized tools.
184  ON_DEBUG debug() << "Deleting " << finalizedTools.size() << " finalized tools" << endmsg;
185  unsigned long maxLoop = totalToolRefCount( finalizedTools ) + 1;
186  while ( --maxLoop > 0 && finalizedTools.size() > 0 ) {
187  IAlgTool* pTool = finalizedTools.front();
188  finalizedTools.pop_front();
189  unsigned long count = refCountTool( pTool );
190  if ( count == 1 ) {
191  ON_DEBUG debug() << " Performing deletion of " << pTool->name() << endmsg;
192  } else {
193  ON_VERBOSE verbose() << " Delaying deletion of " << pTool->name()
194  << " (refCount " << count << ")" << endmsg;
195  // Put it back at the end of the list if refCount still not zero
196  finalizedTools.push_back(pTool);
197  }
198  // do a forced release
199  pTool->release();
200  }
201 
202  // Error if by now not all tools are properly finalised
203  if ( !m_instancesTools.empty() ) {
204  error() << "Unable to finalize and delete the following tools : ";
205  for ( ListTools::const_iterator iTool = m_instancesTools.begin();
206  iTool != m_instancesTools.end(); ++iTool ) {
207  error() << (*iTool)->name() << ": " << refCountTool( *iTool ) << " ";
208  }
209  error() << endmsg;
210  }
211 
212  // by now, all tools should be deleted and removed.
213  if ( finalizedTools.size() > 0 ) {
214  error() << "Failed to delete the following " << finalizedTools.size()
215  << " finalized tools. Bug in ToolSvc::finalize()?: ";
216  for ( ListTools::const_iterator iTool = finalizedTools.begin();
217  iTool != finalizedTools.end(); ++iTool ) {
218  error() << (*iTool)->name() << ": " << refCountTool( *iTool ) << " ";
219  }
220  error() << endmsg;
221  }
222 
223  if ( 0 != m_pHistorySvc ) {
225  }
226 
227  // Finalize this specific service
228  if (! Service::finalize().isSuccess() || fail) {
229  return StatusCode::FAILURE;
230  } else {
231  return StatusCode::SUCCESS;
232  }
233 
234 
235 }
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:108
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:723
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
virtual const std::string & name() const =0
Retrieve the name of the instance.
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:717
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:664
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
virtual unsigned long release()=0
Release Interface instance.
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
#define ON_DEBUG
Definition: ToolSvc.cpp:21
std::list< IAlgTool * > ListTools
Definition: ToolSvc.h:28
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_VERBOSE
Definition: ToolSvc.cpp:22
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
unsigned long refCountTool(IAlgTool *tool) const
Get current refcount for tool.
Definition: ToolSvc.h:73
StatusCode ToolSvc::finalizeTool ( IAlgTool itool) const
private

Finalize the given tool, with exception handling.

Definition at line 664 of file ToolSvc.cpp.

666 {
667 
668  // Cache tool name in case of errors
669  const std::string toolName = itool->name();
670  StatusCode sc;
671 
672  // Finalise the tool inside a try block
673  try {
674  sc = itool->sysFinalize();
675  }
676  // Catch any exceptions
677  catch ( const GaudiException & Exception )
678  {
679  error()
680  << "GaudiException with tag=" << Exception.tag()
681  << " caught whilst finalizing tool '" << toolName << "'" << endmsg
682  << Exception << endmsg;
683  sc = StatusCode::FAILURE;
684  }
685  catch( const std::exception & Exception )
686  {
687  error()
688  << "Standard std::exception caught whilst finalizing tool '"
689  << toolName << "'" << endmsg << Exception.what() << endmsg;
690  sc = StatusCode::FAILURE;
691  }
692  catch (...)
693  {
694  error()
695  << "UNKNOWN Exception caught whilst finalizing tool '"
696  << toolName << "'" << endmsg;
697  sc = StatusCode::FAILURE;
698  }
699 
700  return sc;
701 
702 }
Define general base for Gaudi exception.
virtual StatusCode sysFinalize()=0
Finalization of the Tool.
virtual const std::string & name() const =0
Retrieve the name of the instance.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & tag() const
name tag for the exception, or exception type
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< std::string > ToolSvc::getInstances ( const std::string &  toolType)
virtual

Get names of all tool instances of a given type.

Implements IToolSvc.

Definition at line 369 of file ToolSvc.cpp.

371 {
372 
373  std::vector<std::string> tools;
374 
375  ListTools::const_iterator it;
376  for (it = m_instancesTools.begin(); it != m_instancesTools.end(); ++it) {
377  if ((*it)->type() == toolType) {
378  tools.push_back( (*it)->name() );
379  }
380  }
381 
382  return tools;
383 
384 }
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
StatusCode ToolSvc::initialize ( )
virtual

Initialize the service.

Reimplemented from Service.

Definition at line 45 of file ToolSvc.cpp.

47 {
48 
49  // initialize the Service Base class
51  if (UNLIKELY(status.isFailure()))
52  {
53  error() << "Unable to initialize the Service" << endmsg;
54  return status;
55  }
56 
57  // set my own (ToolSvc) properties via the jobOptionService
58  if (UNLIKELY(setProperties().isFailure())) {
59  error() << "Unable to set base properties" << endmsg;
60  return StatusCode::FAILURE;
61  }
62 
63  return status;
64 }
#define UNLIKELY(x)
Definition: Kernel.h:127
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:371
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
unsigned long ToolSvc::minimumToolRefCount ( ) const
private

The minimum number of refCounts of all tools.

Definition at line 723 of file ToolSvc.cpp.

725 {
726  unsigned long count = 0;
727  if ( m_instancesTools.size() > 0 ) {
728  ListTools::const_iterator iTool = m_instancesTools.begin();
729  // start with first
730  count = refCountTool( *iTool );
731  // then compare the others
732  for( ++iTool; iTool != m_instancesTools.end(); ++iTool ) {
733  count = std::min( count, refCountTool( *iTool ) );
734  }
735  }
736  return count;
737 }
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
#define min(a, b)
unsigned long refCountTool(IAlgTool *tool) const
Get current refcount for tool.
Definition: ToolSvc.h:73
std::string ToolSvc::nameTool ( const std::string &  nameByUser,
const IInterface parent 
)

Get Tool full name by combining nameByUser and "parent" part.

Definition at line 624 of file ToolSvc.cpp.

627 {
628 
629  std::string fullname = "";
630  if ( parent == 0 ) { return this->name() + "." + toolname; } // RETURN
631 
632 
633  IInterface* cparent = const_cast<IInterface*>( parent ) ;
634  // check that parent has a name!
635  INamedInterface* _p = 0 ;
636  StatusCode sc = cparent->queryInterface( INamedInterface::interfaceID() , pp_cast<void>(&_p) ) ;
637  if ( sc.isSuccess() )
638  {
639  fullname = _p->name() + "." + toolname ;
640  _p->release() ;
641  return fullname ; // RETURN
642  }
643 
644  MsgStream log ( msgSvc(), name() );
645  log << MSG::ERROR
646  << "Private Tools only allowed for components implementing INamedInterface"
647  << endmsg;
648  //
649  return "." + toolname ;
650 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
tuple toolname
Definition: gaudirun.py:291
virtual const std::string & name() const =0
Retrieve the name of the instance.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
IInterface compliant class extending IInterface with the name() method.
virtual unsigned long release()=0
Release Interface instance.
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:171
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
unsigned long ToolSvc::refCountTool ( IAlgTool tool) const
inline

Get current refcount for tool.

Definition at line 73 of file ToolSvc.h.

73 { return tool->refCount(); }
virtual unsigned long refCount() const =0
Current number of reference counts.
void ToolSvc::registerObserver ( IToolSvc::Observer obs)
virtual

Implements IToolSvc.

Definition at line 739 of file ToolSvc.cpp.

739  {
740  if ( 0 == obs )
741  throw GaudiException( "Received NULL pointer", this->name() + "::registerObserver", StatusCode::FAILURE );
742  m_observers.push_back(obs);
743 }
Define general base for Gaudi exception.
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:110
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
StatusCode ToolSvc::releaseTool ( IAlgTool tool)
virtual

Release tool.

Implements IToolSvc.

Definition at line 386 of file ToolSvc.cpp.

388 {
390  // test if tool is in known list (protect trying to access a previously deleted tool)
391  if ( m_instancesTools.rend() != std::find( m_instancesTools.rbegin(),
392  m_instancesTools.rend(),
393  tool ) ) {
394  unsigned long count = refCountTool(tool);
395  if ( count == 1 ) {
396  MsgStream log( msgSvc(), name() );
397  // finalize the tool
398 
400  // We are being called during ToolSvc::finalize()
401  // message format matches the one in ToolSvc::finalize()
402  log << MSG::DEBUG << " Performing finalization of " << tool->name()
403  << " (refCount " << count << ")" << endmsg;
404  // message format matches the one in ToolSvc::finalize()
405  log << MSG::DEBUG << " Performing deletion of " << tool->name() << endmsg;
406  } else {
407  log << MSG::DEBUG << "Performing finalization and deletion of " << tool->name() << endmsg;
408  }
409  sc = finalizeTool(tool);
410  // remove from known tools...
411  m_instancesTools.remove(tool);
412  }
413  tool->release();
414  }
415 
416  return sc;
417 }
Gaudi::StateMachine::State m_targetState
Service state.
Definition: Service.h:247
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:664
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
virtual unsigned long release()=0
Release Interface instance.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
unsigned long refCountTool(IAlgTool *tool) const
Get current refcount for tool.
Definition: ToolSvc.h:73
StatusCode ToolSvc::retrieve ( const std::string &  type,
const InterfaceID iid,
IAlgTool *&  tool,
const IInterface parent,
bool  createIf 
)
virtual

Retrieve tool, create it by default as common tool if it does not already exist.

Implements IToolSvc.

Definition at line 248 of file ToolSvc.cpp.

254 {
255 
256  // protect against empty type
257  if ( tooltype.empty() ) {
258  error() << "retrieve(): No Tool Type/Name given" << endmsg;
259  return StatusCode::FAILURE;
260  }
261 
262  {
263  // check for tools, which by name is required to be public:
264  const std::string::size_type pos = tooltype.find ( s_PUBLIC ) ;
265  if ( std::string::npos != pos )
266  {
267  // set parent for PUBLIC tool
268  parent = this ;
269  return retrieve ( std::string( tooltype , 0 , pos ) ,
270  iid , tool , parent , createIf ) ;
271  }
272  }
273 
274  const std::string::size_type pos = tooltype.find('/');
275  if( std::string::npos == pos ) {
276  return retrieve ( tooltype , tooltype , iid , tool , parent , createIf );
277  }
278  const std::string newtype ( tooltype , 0 , pos ) ;
279  const std::string newname ( tooltype , pos + 1 , std::string::npos ) ;
280  return retrieve ( newtype , newname , iid , tool , parent , createIf ) ;
281 }
virtual StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf)
Retrieve tool, create it by default as common tool if it does not already exist.
Definition: ToolSvc.cpp:248
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode ToolSvc::retrieve ( const std::string &  tooltype,
const std::string &  toolname,
const InterfaceID iid,
IAlgTool *&  tool,
const IInterface parent,
bool  createIf 
)
virtual

Retrieve tool, create it by default as common tool if it does not already exist.

invoke retrieve callbacks...

Implements IToolSvc.

Definition at line 286 of file ToolSvc.cpp.

293 {
294  // check the applicability of another method:
295  // ignore the provided name if it is empty or the type contains a name
296  if( toolname.empty() || (std::string::npos != tooltype.find('/')) )
297  { return retrieve ( tooltype , iid , tool , parent , createIf ) ; }
298 
299  {
300  // check for tools, which by name is required to be public:
301  const std::string::size_type pos = toolname.find ( s_PUBLIC ) ;
302  if ( std::string::npos != pos )
303  {
304  // set parent for PUBLIC tool
305  parent = this ;
306  return retrieve ( tooltype , std::string( toolname , 0 , pos ) ,
307  iid , tool , parent , createIf ) ;
308  }
309  }
310 
311  IAlgTool* itool = 0;
313 
314  tool = 0;
315 
316  // If parent is not specified it means it is the ToolSvc itself
317  if( 0 == parent ) {
318  parent = this;
319  }
320  const std::string fullname = nameTool( toolname, parent );
321 
322  // Find tool in list of those already existing, and tell its
323  // interface that it has been used one more time
324  ListTools::const_iterator it;
325  for( it = m_instancesTools.begin(); it != m_instancesTools.end(); ++it ) {
326  if( (*it)->name() == fullname ) {
327  ON_DEBUG debug() << "Retrieved tool " << toolname << endmsg;
328  itool = *it;
329  break;
330  }
331  }
332 
333  if ( 0 == itool ) {
334  // Instances of this tool do not exist, create an instance if desired
335  // otherwise return failure
336  if( UNLIKELY(!createIf) ) {
337  warning() << "Tool " << toolname
338  << " not found and creation not requested" << endmsg;
339  return sc;
340  }
341  else {
342  sc = create( tooltype, toolname, parent, itool );
343  if ( sc.isFailure() ) { return sc; }
344  }
345  }
346 
347  // Get the right interface of it
348  sc = itool->queryInterface( iid, (void**)&tool);
349  if( UNLIKELY(sc.isFailure()) ) {
350  error() << "Tool " << toolname
351  << " either does not implement the correct interface, or its version is incompatible"
352  << endmsg;
353  return sc;
354  }
358  if (!m_observers.empty()) {
359  std::for_each( m_observers.begin(),
360  m_observers.end(),
362  bl::_1,
363  itool));
364  }
365 
366  return sc;
367 }
#define UNLIKELY(x)
Definition: Kernel.h:127
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:624
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:420
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
tuple toolname
Definition: gaudirun.py:291
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:110
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf)
Retrieve tool, create it by default as common tool if it does not already exist.
Definition: ToolSvc.cpp:248
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:236
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
#define ON_DEBUG
Definition: ToolSvc.cpp:21
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
StatusCode ToolSvc::start ( )
virtual

Start (from INITIALIZED to RUNNING).

Reimplemented from Service.

Definition at line 753 of file ToolSvc.cpp.

755 {
756 
757  ON_DEBUG debug() << "START transition for AlgTools" << endmsg;
758 
759  bool fail(false);
760  for ( ListTools::const_iterator iTool = m_instancesTools.begin();
761  iTool != m_instancesTools.end(); ++iTool ) {
762  ON_VERBOSE verbose() << (*iTool)->name() << "::start()" << endmsg;
763 
764  if (UNLIKELY(!(*iTool)->sysStart().isSuccess())) {
765  fail = true;
766  error() << (*iTool)->name() << " failed to start()" << endmsg;
767  }
768 
769  }
770 
771  if (UNLIKELY(fail)) {
772  error() << "One or more AlgTools failed to start()" << endmsg;
773  return StatusCode::FAILURE;
774  } else {
775  return StatusCode::SUCCESS;
776  }
777 
778 }
#define UNLIKELY(x)
Definition: Kernel.h:127
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
#define ON_DEBUG
Definition: ToolSvc.cpp:21
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_VERBOSE
Definition: ToolSvc.cpp:22
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode ToolSvc::stop ( )
virtual

Stop (from RUNNING to INITIALIZED).

Reimplemented from Service.

Definition at line 782 of file ToolSvc.cpp.

784 {
785 
786  ON_DEBUG debug() << "STOP transition for AlgTools" << endmsg;
787 
788  bool fail(false);
789  for ( ListTools::const_iterator iTool = m_instancesTools.begin();
790  iTool != m_instancesTools.end(); ++iTool ) {
791  ON_VERBOSE verbose() << (*iTool)->name() << "::stop()" << endmsg;
792 
793  if (UNLIKELY(!(*iTool)->sysStop().isSuccess())) {
794  fail = true;
795  error() << (*iTool)->name() << " failed to stop()" << endmsg;
796  }
797 
798  }
799 
800  if (UNLIKELY(fail)) {
801  error() << "One or more AlgTools failed to stop()" << endmsg;
802  return StatusCode::FAILURE;
803  } else {
804  return StatusCode::SUCCESS;
805  }
806 
807 }
#define UNLIKELY(x)
Definition: Kernel.h:127
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
#define ON_DEBUG
Definition: ToolSvc.cpp:21
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
#define ON_VERBOSE
Definition: ToolSvc.cpp:22
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
unsigned long ToolSvc::totalToolRefCount ( ) const
private

The total number of refCounts on all tools in the instancesTools list.

Definition at line 717 of file ToolSvc.cpp.

719 {
721 }
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:717
unsigned long ToolSvc::totalToolRefCount ( const ListTools toolList) const
private

The total number of refCounts on all tools in the list.

Definition at line 705 of file ToolSvc.cpp.

707 {
708  unsigned long count = 0;
709  for ( ListTools::const_iterator iTool = toolList.begin();
710  iTool != toolList.end(); ++iTool ) {
711  count += refCountTool( *iTool );
712  }
713  return count;
714 }
unsigned long refCountTool(IAlgTool *tool) const
Get current refcount for tool.
Definition: ToolSvc.h:73
void ToolSvc::unRegisterObserver ( IToolSvc::Observer obs)
virtual

Implements IToolSvc.

Definition at line 745 of file ToolSvc.cpp.

745  {
746  std::vector<IToolSvc::Observer*>::iterator i =
747  find(m_observers.begin(),m_observers.end(),obs);
748  if (i!=m_observers.end()) m_observers.erase(i);
749 }
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:110
list i
Definition: ana.py:128

Member Data Documentation

ListTools ToolSvc::m_instancesTools
private

Common Tools.

Definition at line 105 of file ToolSvc.h.

std::vector<IToolSvc::Observer*> ToolSvc::m_observers
private

Definition at line 110 of file ToolSvc.h.

IHistorySvc* ToolSvc::m_pHistorySvc
private

Pointer to HistorySvc.

Definition at line 108 of file ToolSvc.h.


The documentation for this class was generated from the following files: