The Gaudi Framework  master (37c0b60a)
IToolSvc::Observer Class Reference

allow call-backs when a tool is a created or retrieved More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/IToolSvc.h>

Collaboration diagram for IToolSvc::Observer:

Public Member Functions

virtual ~Observer ()
 
void setUnregister (std::function< void()> unregister)
 
virtual void onCreate (const IAlgTool *)
 
virtual void onRetrieve (const IAlgTool *)
 

Private Attributes

std::function< void()> m_unregister
 

Detailed Description

allow call-backs when a tool is a created or retrieved

class myObserver : public ITooSvc::Observer {
cout << "tool " << tool.name() << " created " << endl;
}
cout << "someone requested " << tool.name() <<endl;
}
}
myObserver *observer = new myObserver;
IToolSvc* svc = ...
svc->registerObserver(observer);

IToolSvc implementations will call 'Observer::onCreate' when a tool is created, and 'Observer::onRetrieve' if a tool is retrieved.

The user is responsible of the life time of the object and must un-register it before it is deleted (e.g. during the finalization).

Definition at line 230 of file IToolSvc.h.

Constructor & Destructor Documentation

◆ ~Observer()

virtual IToolSvc::Observer::~Observer ( )
inlinevirtual

Definition at line 232 of file IToolSvc.h.

232  {
233  if ( m_unregister ) m_unregister();
234  }

Member Function Documentation

◆ onCreate()

virtual void IToolSvc::Observer::onCreate ( const IAlgTool )
inlinevirtual

Definition at line 237 of file IToolSvc.h.

237 {}

◆ onRetrieve()

virtual void IToolSvc::Observer::onRetrieve ( const IAlgTool )
inlinevirtual

Definition at line 238 of file IToolSvc.h.

238 {}

◆ setUnregister()

void IToolSvc::Observer::setUnregister ( std::function< void()>  unregister)
inline

Definition at line 235 of file IToolSvc.h.

235 { m_unregister = std::move( unregister ); }

Member Data Documentation

◆ m_unregister

std::function<void()> IToolSvc::Observer::m_unregister
private

Definition at line 241 of file IToolSvc.h.


The documentation for this class was generated from the following file:
IAlgTool
Definition: IAlgTool.h:33
std::move
T move(T... args)
IToolSvc::registerObserver
virtual void registerObserver(Observer *obs)=0
IToolSvc::Observer::onCreate
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:237
bug_34121.tool
tool
Definition: bug_34121.py:18
IToolSvc::Observer::m_unregister
std::function< void()> m_unregister
Definition: IToolSvc.h:241
IToolSvc::Observer::onRetrieve
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:238
std::endl
T endl(T... args)
IToolSvc
Definition: IToolSvc.h:29