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< BASE, Interfaces >
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~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< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
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 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...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... 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
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 38 of file AlgContextSvc.h.

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

accessor to current algorithm:

See also
IAlgContextSvc

Definition at line 142 of file AlgContextSvc.cpp.

143 {
144  return (m_algorithms.get() && ! m_algorithms->empty())
145  ? m_algorithms->back()
146  : nullptr;
147 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:62
StatusCode AlgContextSvc::finalize ( )
override

standard finalization of the service

See also
IService

Definition at line 74 of file AlgContextSvc.cpp.

75 {
76  if ( m_algorithms.get() && !m_algorithms->empty() )
77  {
78  MsgStream log ( msgSvc() , name() ) ;
79  log << MSG::WARNING
80  << "Non-empty stack of algorithms #"
81  << m_algorithms->size() << endmsg ;
82  }
83  // Incident Service
84  if ( m_inc )
85  {
86  m_inc -> removeListener ( this ) ;
87  m_inc.reset();
88  }
89  // finalize the base class
90  return Service::finalize () ;
91 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode finalize() override
Definition: Service.cpp:188
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
Definition: AlgContextSvc.h:64
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:62
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
void AlgContextSvc::handle ( const Incident )
override

handle incident

See also
IIncidentListener

Definition at line 151 of file AlgContextSvc.cpp.

151  {
152  if ( m_algorithms.get() && !m_algorithms->empty() ) {
153  MsgStream log ( msgSvc() , name() ) ;
154  log << MSG::ERROR
155  << "Non-empty stack of algorithms #"
156  << m_algorithms->size() << endmsg ;
157  }
158 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:62
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  MsgStream log ( msgSvc() , name() ) ;
56  log << MSG::ERROR << "Could not locate 'IncidentSvc'" << endmsg ;
57  return StatusCode::FAILURE ; // RETURN
58  }
59  m_inc -> addListener ( this , IncidentType::BeginEvent ) ;
60  m_inc -> addListener ( this , IncidentType::EndEvent ) ;
61  }
62  if ( m_algorithms.get() && !m_algorithms->empty() )
63  {
64  MsgStream log ( msgSvc() , name() ) ;
65  log << MSG::WARNING
66  << "Non-empty stack of algorithms #"
67  << m_algorithms->size() << endmsg ;
68  }
69  return StatusCode::SUCCESS ;
70 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode initialize() override
Definition: Service.cpp:63
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
Definition: AlgContextSvc.h:64
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:62
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:141
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
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 95 of file AlgContextSvc.cpp.

96 {
97  if ( !a )
98  {
99  MsgStream log ( msgSvc() , name() ) ;
100  log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
101  return StatusCode::RECOVERABLE ; // RETURN
102  }
103  // check whether thread-local algorithm list already exists
104  // if not, create it
105  if ( ! m_algorithms.get()) {
107  }
108  m_algorithms->push_back ( a ) ;
109 
110  return StatusCode::SUCCESS ; // RETURN
111 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:62
std::vector< IAlgorithm * > Algorithms
the actual type of algorithm' stack
StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm a)
override

remove the algorithm ("pop_back")

See also
IAlgContextSvc

Definition at line 115 of file AlgContextSvc.cpp.

116 {
117  // check whether thread-local algorithm list already exists
118  // if not, create it
119  if ( ! m_algorithms.get()) {
121  }
122 
123  if ( !a )
124  {
125  MsgStream log ( msgSvc() , name() ) ;
126  log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
127  return StatusCode::RECOVERABLE ; // RETURN
128  }
129  if ( m_algorithms->empty() || m_algorithms->back() != a )
130  {
131  MsgStream log ( msgSvc() , name() ) ;
132  log << MSG::ERROR << "Algorithm stack is invalid" << endmsg ;
133  return StatusCode::FAILURE ;
134  }
135  m_algorithms->pop_back() ; // POP_BACK
136 
137  return StatusCode::SUCCESS ;
138 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:62
std::vector< IAlgorithm * > Algorithms
the actual type of algorithm' stack

Member Data Documentation

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

the stack of current algorithms

Definition at line 62 of file AlgContextSvc.h.

bool AlgContextSvc::m_check = true
private

Definition at line 66 of file AlgContextSvc.h.

SmartIF<IIncidentSvc> AlgContextSvc::m_inc = nullptr
private

pointer to Incident Service

Definition at line 64 of file AlgContextSvc.h.


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