The Gaudi Framework  v38r0 (2143aa4c)
AlgContextSvc Class Reference

#include </builds/gaudi/Gaudi/GaudiCommonSvc/src/AlgContextSvc.h>

Inheritance diagram for AlgContextSvc:
Collaboration diagram for AlgContextSvc:

Public Member Functions

StatusCode setCurrentAlg (IAlgorithm *a, const EventContext &context) override
 set the currently executing algorithm ("push_back") More...
 
StatusCode unSetCurrentAlg (IAlgorithm *a, const EventContext &context) 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 start () override
 
StatusCode finalize () override
 standard finalization of the service 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...
 
- 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...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
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 >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream 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...
 
Gaudi::Property< bool > m_check { this, "Check", true, "Flag to perform more checks" }
 
Gaudi::Property< bool > m_bypassInc
 
std::vector< int > m_inEvtLoop
 

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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- 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
std::vector< IAlgTool * > & tools ()
 
 ~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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Detailed Description

Definition at line 43 of file AlgContextSvc.h.

Constructor & Destructor Documentation

◆ AlgContextSvc() [1/2]

AlgContextSvc::AlgContextSvc ( )
privatedelete

◆ AlgContextSvc() [2/2]

AlgContextSvc::AlgContextSvc ( const AlgContextSvc )
privatedelete

Member Function Documentation

◆ algorithms()

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

get the stack of executed algorithms

See also
IAlgContextSvc

Definition at line 52 of file AlgContextSvc.h.

52 { return *m_algorithms; }

◆ currentAlg()

IAlgorithm * AlgContextSvc::currentAlg ( ) const
override

accessor to current algorithm:

See also
IAlgContextSvc

Definition at line 156 of file AlgContextSvc.cpp.

156  {
157  return ( m_algorithms.get() && !m_algorithms->empty() ) ? m_algorithms->back() : nullptr;
158 }

◆ finalize()

StatusCode AlgContextSvc::finalize ( )
override

standard finalization of the service

See also
IService

Definition at line 95 of file AlgContextSvc.cpp.

95  {
96  if ( m_algorithms.get() && !m_algorithms->empty() ) {
97  warning() << "Non-empty stack of algorithms #" << m_algorithms->size() << endmsg;
98  }
99  // Incident Service
100  if ( m_inc ) {
101  m_inc->removeListener( this );
102  m_inc.reset();
103  }
104  // finalize the base class
105  return Service::finalize();
106 }

◆ handle()

void AlgContextSvc::handle ( const Incident inc)
override

handle incident

See also
IIncidentListener

Definition at line 162 of file AlgContextSvc.cpp.

162  {
163  // some false sharing is possible but it should be negligable
164  auto currSlot = inc.context().slot();
165  if ( currSlot == EventContext::INVALID_CONTEXT_ID ) { currSlot = 0; }
166  if ( inc.type() == "BeginEvent" ) {
167  m_inEvtLoop[currSlot] = 1;
168  } else if ( inc.type() == "EndEvent" ) {
169  m_inEvtLoop[currSlot] = 0;
170  }
171 
172  // This check is invalidated with RTTI AlgContext object.
173  // Whole service needs to be rewritten. Commenting the error until then
174  // to prevent test failures.
175  // if ( m_algorithms.get() && !m_algorithms->empty() ) {
176  // //skip incident processing algorithm endevent incident
177  // if((m_algorithms->size()!=1) ||
178  // (m_algorithms->back()->type()!="IncidentProcAlg")){
179  // error() << "Non-empty stack of algorithms #"
180  // << m_algorithms->size() << endmsg ;
181  // }
182  // }
183 }

◆ initialize()

StatusCode AlgContextSvc::initialize ( )
override

standard initialization of the service

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

See also
IService

Definition at line 41 of file AlgContextSvc.cpp.

41  {
42  // Initialize the base class
44  if ( sc.isFailure() ) { return sc; }
45  // Incident Service
46  if ( m_inc ) {
47  m_inc->removeListener( this );
48  m_inc.reset();
49  }
50  // perform more checks?
52  numSlots = ( 1 > numSlots ) ? 1 : numSlots;
53  if ( numSlots > 1000 ) {
54  warning() << "Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots << endmsg;
55  numSlots = 1000;
56  warning() << "Setting numSlots to " << numSlots << endmsg;
57  }
58  m_inEvtLoop.resize( numSlots, 0 );
59 
60  if ( m_check ) {
61  m_inc = Service::service( "IncidentSvc", true );
62  if ( !m_inc ) {
63  error() << "Could not locate 'IncidentSvc'" << endmsg;
64  return StatusCode::FAILURE;
65  }
66  m_inc->addListener( this, IncidentType::BeginEvent );
67  m_inc->addListener( this, IncidentType::EndEvent );
68  }
69  if ( m_algorithms.get() && !m_algorithms->empty() ) {
70  warning() << "Non-empty stack of algorithms #" << m_algorithms->size() << endmsg;
71  }
72  return StatusCode::SUCCESS;
73 }

◆ operator=()

AlgContextSvc& AlgContextSvc::operator= ( const AlgContextSvc )
privatedelete

◆ setCurrentAlg()

StatusCode AlgContextSvc::setCurrentAlg ( IAlgorithm a,
const EventContext context 
)
override

set the currently executing algorithm ("push_back")

See also
IAlgContextSvc

Definition at line 110 of file AlgContextSvc.cpp.

110  {
111  if ( !a ) {
112  warning() << "IAlgorithm* points to NULL" << endmsg;
114  }
115  if ( !m_bypassInc ) {
116  if ( !m_inEvtLoop[context.valid() ? context.slot() : 0] ) return StatusCode::SUCCESS;
117  }
118  // check whether thread-local algorithm list already exists
119  // if not, create it
120  if ( !m_algorithms.get() ) { m_algorithms.reset( new IAlgContextSvc::Algorithms() ); }
121  if ( a->type() != "IncidentProcAlg" ) m_algorithms->push_back( a );
122 
123  return StatusCode::SUCCESS;
124 }

◆ start()

StatusCode AlgContextSvc::start ( )
override

Definition at line 79 of file AlgContextSvc.cpp.

79  {
80  auto sc = Service::start();
82  numSlots = ( 1 > numSlots ) ? 1 : numSlots;
83  if ( numSlots > 1000 ) {
84  warning() << "Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots << endmsg;
85  numSlots = 1000;
86  }
87  m_inEvtLoop.resize( numSlots, 0 );
88 
89  return sc;
90 }

◆ unSetCurrentAlg()

StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm a,
const EventContext context 
)
override

remove the algorithm ("pop_back")

See also
IAlgContextSvc

Definition at line 128 of file AlgContextSvc.cpp.

128  {
129  // check whether thread-local algorithm list already exists
130  // if not, create it
131  if ( !m_algorithms.get() ) { m_algorithms.reset( new IAlgContextSvc::Algorithms() ); }
132 
133  if ( !a ) {
134  warning() << "IAlgorithm* points to NULL" << endmsg;
136  }
137 
138  if ( !m_bypassInc ) {
139  if ( !m_inEvtLoop[context.valid() ? context.slot() : 0] ) return StatusCode::SUCCESS;
140  }
141 
142  if ( a->type() != "IncidentProcAlg" ) {
143  // if ( m_algorithms->empty() || m_algorithms->back() != a ){
144  // error() << "Algorithm stack is invalid" << endmsg ;
145  // return StatusCode::FAILURE ;
146  // }
147  if ( !m_algorithms->empty() ) {
148  if ( m_algorithms->back() == a ) { m_algorithms->pop_back(); }
149  }
150  }
151  return StatusCode::SUCCESS;
152 }

Member Data Documentation

◆ m_algorithms

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

the stack of current algorithms

Definition at line 76 of file AlgContextSvc.h.

◆ m_bypassInc

Gaudi::Property<bool> AlgContextSvc::m_bypassInc
private
Initial value:
{ this, "BypassIncidents", false,
"Flag to bypass begin/endevent incident requirement" }

Definition at line 81 of file AlgContextSvc.h.

◆ m_check

Gaudi::Property<bool> AlgContextSvc::m_check { this, "Check", true, "Flag to perform more checks" }
private

Definition at line 80 of file AlgContextSvc.h.

◆ m_inc

SmartIF<IIncidentSvc> AlgContextSvc::m_inc = nullptr
private

pointer to Incident Service

Definition at line 78 of file AlgContextSvc.h.

◆ m_inEvtLoop

std::vector<int> AlgContextSvc::m_inEvtLoop
private

Definition at line 83 of file AlgContextSvc.h.


The documentation for this class was generated from the following files:
EventContext::valid
bool valid() const
Definition: EventContext.h:54
std::vector::resize
T resize(T... args)
AlgContextSvc::m_check
Gaudi::Property< bool > m_check
Definition: AlgContextSvc.h:80
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
AlgContextSvc::m_inc
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
Definition: AlgContextSvc.h:78
AlgContextSvc::m_inEvtLoop
std::vector< int > m_inEvtLoop
Definition: AlgContextSvc.h:83
Service::start
StatusCode start() override
Definition: Service.cpp:187
std::vector< IAlgorithm * >
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
AlgContextSvc::m_algorithms
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Definition: AlgContextSvc.h:76
EventContext::INVALID_CONTEXT_ID
static constexpr ContextID_t INVALID_CONTEXT_ID
Definition: EventContext.h:39
IAlgorithm::type
virtual const std::string & type() const =0
The type of the algorithm.
AlgContextSvc::m_bypassInc
Gaudi::Property< bool > m_bypassInc
Definition: AlgContextSvc.h:81
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents
static GAUDI_API std::size_t numConcurrentEvents()
number of Concurrent Events (for MT)
Definition: ConcurrencyFlags.h:57
Incident::context
EventContext context() const
Access to the EventContext of the source of the incident.
Definition: Incident.h:60
StatusCode
Definition: StatusCode.h:65
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:51
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:48
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
StatusCode::RECOVERABLE
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:102
Service::service
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:88