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

IAlgContextSvc::Algorithms m_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 >
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extends base_class
 Typedef to this class. More...
 
typedef extend_interfaces< Interfaces...> extend_interfaces_base
 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 26 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 36 of file AlgContextSvc.h.

37  { return m_algorithms ; }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
IAlgorithm * AlgContextSvc::currentAlg ( ) const
override

accessor to current algorithm:

See also
IAlgContextSvc

Definition at line 135 of file AlgContextSvc.cpp.

136 { return m_algorithms.empty() ? nullptr : m_algorithms.back() ; }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
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.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 }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode finalize() override
Definition: Service.cpp:187
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: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 140 of file AlgContextSvc.cpp.

141 {
142  if ( !m_algorithms.empty() )
143  {
144  MsgStream log ( msgSvc() , name() ) ;
145  log << MSG::ERROR
146  << "Non-empty stack of algorithms #"
147  << m_algorithms.size() << endmsg ;
148  }
149 }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
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 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.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 }
const std::string BeginEvent
Processing of a new event has started.
Definition: Incident.h:60
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode initialize() override
Definition: Service.cpp:62
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:62
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
const std::string EndEvent
Processing of the last event has finished.
Definition: Incident.h:61
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:139
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  //
102  return StatusCode::RECOVERABLE ; // RETURN
103  }
104  m_algorithms.push_back ( a ) ;
105  //
106  return StatusCode::SUCCESS ; // RETURN
107 }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
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 AlgContextSvc::unSetCurrentAlg ( IAlgorithm a)
override

remove the algorithm ("pop_back")

See also
IAlgContextSvc

Definition at line 111 of file AlgContextSvc.cpp.

112 {
113  if ( !a )
114  {
115  MsgStream log ( msgSvc() , name() ) ;
116  log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
117  //
118  return StatusCode::RECOVERABLE ; // RETURN
119  }
120  if ( m_algorithms.empty() || m_algorithms.back() != a )
121  {
122  MsgStream log ( msgSvc() , name() ) ;
123  log << MSG::ERROR << "Algorithm stack is invalid" << endmsg ;
124  //
125  return StatusCode::FAILURE ;
126  }
127  //
128  m_algorithms.pop_back() ; // POP_BACK
129  //
130  return StatusCode::SUCCESS ;
131 }
IAlgContextSvc::Algorithms m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:60
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

Member Data Documentation

IAlgContextSvc::Algorithms AlgContextSvc::m_algorithms
private

the stack of current algorithms

Definition at line 60 of file AlgContextSvc.h.

bool AlgContextSvc::m_check = true
private

Definition at line 64 of file AlgContextSvc.h.

SmartIF<IIncidentSvc> AlgContextSvc::m_inc = nullptr
private

pointer to Incident Service

Definition at line 62 of file AlgContextSvc.h.


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