AlgContextSvc Class Reference

#include <src/AlgContextSvc.h>

Inheritance diagram for AlgContextSvc:
Collaboration diagram for AlgContextSvc:

Public Member Functions

StatusCode setCurrentAlg (IAlgorithm *a) override
 set the currently executing algorithm ("push_back") More...
 
StatusCode unSetCurrentAlg (IAlgorithm *a) override
 remove the algorithm ("pop_back") More...
 
IAlgorithmcurrentAlg () const override
 accessor to current algorithm: More...
 
const IAlgContextSvc::Algorithmsalgorithms () const override
 get the stack of executed algorithms More...
 
void handle (const Incident &) override
 handle incident More...
 
StatusCode initialize () override
 standard initialization of the service More...
 
StatusCode finalize () override
 standard finalization of the service More...
 
 AlgContextSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~AlgContextSvc () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from extends< Service, IAlgContextSvc, IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 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<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, 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...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 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...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Member Functions

 AlgContextSvc ()=delete
 
 AlgContextSvc (const AlgContextSvc &)=delete
 
AlgContextSvcoperator= (const AlgContextSvc &)=delete
 

Private Attributes

boost::thread_specific_ptr< IAlgContextSvc::Algorithmsm_algorithms
 the stack of current algorithms More...
 
SmartIF< IIncidentSvcm_inc = nullptr
 pointer to Incident Service More...
 
bool m_check = true
 

Additional Inherited Members

- Public Types inherited from extends< Service, IAlgContextSvc, IIncidentListener >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Detailed Description

Definition at line 28 of file AlgContextSvc.h.

Constructor & Destructor Documentation

AlgContextSvc::AlgContextSvc ( const std::string name,
ISvcLocator svc 
)

Standard Constructor.

Instantiation of a static factory class used by clients to create instances of this service.

See also
Service

Definition at line 29 of file AlgContextSvc.cpp.

31  : base_class ( name , svc )
32 {
33  declareProperty ( "Check" , m_check , "Flag to perform more checks" );
34 }
extends base_class
Typedef to this class.
Definition: extends.h:14
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
AlgContextSvc::~AlgContextSvc ( )
overridedefault

Standard Destructor.

AlgContextSvc::AlgContextSvc ( )
privatedelete
AlgContextSvc::AlgContextSvc ( const AlgContextSvc )
privatedelete

Member Function Documentation

const IAlgContextSvc::Algorithms& AlgContextSvc::algorithms ( ) const
inlineoverride

get the stack of executed algorithms

See also
IAlgContextSvc

Definition at line 40 of file AlgContextSvc.h.

41  { return *m_algorithms ; }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
IAlgorithm * AlgContextSvc::currentAlg ( ) const
override

accessor to current algorithm:

See also
IAlgContextSvc

Definition at line 134 of file AlgContextSvc.cpp.

135 {
136  return (m_algorithms.get() && ! m_algorithms->empty())
137  ? m_algorithms->back()
138  : nullptr;
139 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
StatusCode AlgContextSvc::finalize ( )
override

standard finalization of the service

See also
IService

Definition at line 71 of file AlgContextSvc.cpp.

72 {
73  if ( m_algorithms.get() && !m_algorithms->empty() )
74  {
75  warning() << "Non-empty stack of algorithms #"
76  << m_algorithms->size() << endmsg ;
77  }
78  // Incident Service
79  if ( m_inc )
80  {
81  m_inc -> removeListener ( this ) ;
82  m_inc.reset();
83  }
84  // finalize the base class
85  return Service::finalize () ;
86 }
StatusCode finalize() override
Definition: Service.cpp:193
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
Definition: AlgContextSvc.h:66
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void AlgContextSvc::handle ( const Incident )
override

handle incident

See also
IIncidentListener

Definition at line 143 of file AlgContextSvc.cpp.

143  {
144  if ( m_algorithms.get() && !m_algorithms->empty() ) {
145  error() << "Non-empty stack of algorithms #"
146  << m_algorithms->size() << endmsg ;
147  }
148 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
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 AlgContextSvc::initialize ( )
override

standard initialization of the service

See also
IService

Definition at line 38 of file AlgContextSvc.cpp.

39 {
40  // Initialize the base class
42  if ( sc.isFailure () ) { return sc ; }
43  // Incident Service
44  if ( m_inc )
45  {
46  m_inc -> removeListener ( this ) ;
47  m_inc.reset();
48  }
49  // perform more checks?
50  if ( m_check )
51  {
52  m_inc = Service::service ( "IncidentSvc" , true ) ;
53  if ( !m_inc )
54  {
55  error() << "Could not locate 'IncidentSvc'" << endmsg ;
56  return StatusCode::FAILURE ; // RETURN
57  }
58  m_inc -> addListener ( this , IncidentType::BeginEvent ) ;
59  m_inc -> addListener ( this , IncidentType::EndEvent ) ;
60  }
61  if ( m_algorithms.get() && !m_algorithms->empty() )
62  {
63  warning() << "Non-empty stack of algorithms #"
64  << m_algorithms->size() << endmsg ;
65  }
66  return StatusCode::SUCCESS ;
67 }
StatusCode initialize() override
Definition: Service.cpp:68
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
Definition: AlgContextSvc.h:66
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:144
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
AlgContextSvc& AlgContextSvc::operator= ( const AlgContextSvc )
privatedelete
StatusCode AlgContextSvc::setCurrentAlg ( IAlgorithm a)
override

set the currently executing algorithm ("push_back")

See also
IAlgContextSvc

Definition at line 90 of file AlgContextSvc.cpp.

91 {
92  if ( !a )
93  {
94  warning() << "IAlgorithm* points to NULL" << endmsg ;
95  return StatusCode::RECOVERABLE ; // RETURN
96  }
97  // check whether thread-local algorithm list already exists
98  // if not, create it
99  if ( ! m_algorithms.get()) {
101  }
102  m_algorithms->push_back ( a ) ;
103 
104  return StatusCode::SUCCESS ; // RETURN
105 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm a)
override

remove the algorithm ("pop_back")

See also
IAlgContextSvc

Definition at line 109 of file AlgContextSvc.cpp.

110 {
111  // check whether thread-local algorithm list already exists
112  // if not, create it
113  if ( ! m_algorithms.get()) {
115  }
116 
117  if ( !a )
118  {
119  warning() << "IAlgorithm* points to NULL" << endmsg ;
120  return StatusCode::RECOVERABLE ; // RETURN
121  }
122  if ( m_algorithms->empty() || m_algorithms->back() != a )
123  {
124  error() << "Algorithm stack is invalid" << endmsg ;
125  return StatusCode::FAILURE ;
126  }
127  m_algorithms->pop_back() ; // POP_BACK
128 
129  return StatusCode::SUCCESS ;
130 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:64
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

boost::thread_specific_ptr<IAlgContextSvc::Algorithms> AlgContextSvc::m_algorithms
private

the stack of current algorithms

Definition at line 64 of file AlgContextSvc.h.

bool AlgContextSvc::m_check = true
private

Definition at line 68 of file AlgContextSvc.h.

SmartIF<IIncidentSvc> AlgContextSvc::m_inc = nullptr
private

pointer to Incident Service

Definition at line 66 of file AlgContextSvc.h.


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