The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
AlgContextSvc Class Reference

Simple implementation of interface IAlgContextSvc for Algorithm Context Service. More...

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")
 
StatusCode unSetCurrentAlg (IAlgorithm *a, const EventContext &context) override
 remove the algorithm ("pop_back")
 
IAlgorithmcurrentAlg () const override
 accessor to current algorithm:
 
const IAlgContextSvc::Algorithmsalgorithms () const override
 get the stack of executed algorithms
 
void handle (const Incident &) override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode finalize () override
 
- Public Member Functions inherited from extends< Service, IAlgContextSvc, IIncidentListener >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
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.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
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, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
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.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Private Attributes

boost::thread_specific_ptr< IAlgContextSvc::Algorithmsm_algorithms
 the stack of current algorithms
 
SmartIF< IIncidentSvcm_inc = nullptr
 pointer to Incident Service
 
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
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- 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
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
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.
 

Detailed Description

Simple implementation of interface IAlgContextSvc for Algorithm Context Service.

Author
ATLAS Collaboration
modified by Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.ye.ed.nosp@m.u
incident listening removed by Benedikt Hegner
S. Kama. Added multi-context incident based queueing to support Serial-MT cases
Date
2007-03-07 (modified)

Definition at line 34 of file AlgContextSvc.cpp.

Member Function Documentation

◆ algorithms()

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

get the stack of executed algorithms

See also
IAlgContextSvc

Definition at line 43 of file AlgContextSvc.cpp.

43 {
44 if ( !m_algorithms.get() ) {
45 static IAlgContextSvc::Algorithms empty;
46 return empty;
47 }
48 return *m_algorithms;
49 }
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
std::vector< IAlgorithm * > Algorithms
the actual type of algorithm' stack

◆ currentAlg()

IAlgorithm * AlgContextSvc::currentAlg ( ) const
override

accessor to current algorithm:

See also
IAlgContextSvc

Definition at line 182 of file AlgContextSvc.cpp.

182 {
183 return ( m_algorithms.get() && !m_algorithms->empty() ) ? m_algorithms->back() : nullptr;
184}

◆ finalize()

StatusCode AlgContextSvc::finalize ( )
override

Definition at line 127 of file AlgContextSvc.cpp.

127 {
128 if ( m_algorithms.get() && !m_algorithms->empty() ) {
129 warning() << "Non-empty stack of algorithms #" << m_algorithms->size() << endmsg;
130 }
131 // Incident Service
132 if ( m_inc ) {
133 m_inc->removeListener( this );
134 m_inc.reset();
135 }
136 // finalize the base class
137 return Service::finalize();
138}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode finalize() override
Definition Service.cpp:223

◆ handle()

void AlgContextSvc::handle ( const Incident & inc)
override

Definition at line 186 of file AlgContextSvc.cpp.

186 {
187 // some false sharing is possible but it should be negligible
188 auto currSlot = inc.context().slot();
189 if ( currSlot == EventContext::INVALID_CONTEXT_ID ) { currSlot = 0; }
190 if ( inc.type() == "BeginEvent" ) {
191 m_inEvtLoop[currSlot] = 1;
192 } else if ( inc.type() == "EndEvent" ) {
193 m_inEvtLoop[currSlot] = 0;
194 }
195
196 // This check is invalidated with RTTI AlgContext object.
197 // Whole service needs to be rewritten. Commenting the error until then
198 // to prevent test failures.
199 // if ( m_algorithms.get() && !m_algorithms->empty() ) {
200 // //skip incident processing algorithm endevent incident
201 // if((m_algorithms->size()!=1) ||
202 // (m_algorithms->back()->type()!="IncidentProcAlg")){
203 // error() << "Non-empty stack of algorithms #"
204 // << m_algorithms->size() << endmsg ;
205 // }
206 // }
207}
std::vector< int > m_inEvtLoop
ContextID_t slot() const
static constexpr ContextID_t INVALID_CONTEXT_ID
EventContext context() const
Access to the EventContext of the source of the incident.
Definition Incident.h:55
const std::string & type() const
Access to the incident type.
Definition Incident.h:43

◆ initialize()

StatusCode AlgContextSvc::initialize ( )
override

Definition at line 76 of file AlgContextSvc.cpp.

76 {
77 // Initialize the base class
78 StatusCode sc = Service::initialize();
79 if ( sc.isFailure() ) { return sc; }
80 // Incident Service
81 if ( m_inc ) {
82 m_inc->removeListener( this );
83 m_inc.reset();
84 }
85 // perform more checks?
87 numSlots = ( 1 > numSlots ) ? 1 : numSlots;
88 if ( numSlots > 1000 ) {
89 warning() << "Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots << endmsg;
90 numSlots = 1000;
91 warning() << "Setting numSlots to " << numSlots << endmsg;
92 }
93 m_inEvtLoop.resize( numSlots, 0 );
94
95 if ( m_check ) {
96 m_inc = Service::service( "IncidentSvc", true );
97 if ( !m_inc ) {
98 error() << "Could not locate 'IncidentSvc'" << endmsg;
100 }
101 m_inc->addListener( this, IncidentType::BeginEvent );
102 m_inc->addListener( this, IncidentType::EndEvent );
103 }
104 if ( m_algorithms.get() && !m_algorithms->empty() ) {
105 warning() << "Non-empty stack of algorithms #" << m_algorithms->size() << endmsg;
106 }
107 return StatusCode::SUCCESS;
108}
Gaudi::Property< bool > m_check
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
static GAUDI_API std::size_t numConcurrentEvents()
number of Concurrent Events (for MT)
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
Definition Service.h:79
StatusCode initialize() override
Definition Service.cpp:118
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ setCurrentAlg()

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

set the currently executing algorithm ("push_back")

See also
IAlgContextSvc

Definition at line 140 of file AlgContextSvc.cpp.

140 {
141 if ( !a ) {
142 warning() << "IAlgorithm* points to NULL" << endmsg;
144 }
145 if ( !m_bypassInc ) {
146 if ( !m_inEvtLoop[context.valid() ? context.slot() : 0] ) return StatusCode::SUCCESS;
147 }
148 // check whether thread-local algorithm list already exists
149 // if not, create it
150 if ( !m_algorithms.get() ) { m_algorithms.reset( new IAlgContextSvc::Algorithms() ); }
151 if ( a->type() != "IncidentProcAlg" ) m_algorithms->push_back( a );
152
153 return StatusCode::SUCCESS;
154}
Gaudi::Property< bool > m_bypassInc
bool valid() const
virtual const std::string & type() const =0
The type of the algorithm.
constexpr static const auto RECOVERABLE
Definition StatusCode.h:101

◆ start()

StatusCode AlgContextSvc::start ( )
override

Definition at line 114 of file AlgContextSvc.cpp.

114 {
115 auto sc = Service::start();
117 numSlots = ( 1 > numSlots ) ? 1 : numSlots;
118 if ( numSlots > 1000 ) {
119 warning() << "Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots << endmsg;
120 numSlots = 1000;
121 }
122 m_inEvtLoop.resize( numSlots, 0 );
123
124 return sc;
125}
StatusCode start() override
Definition Service.cpp:187

◆ unSetCurrentAlg()

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

remove the algorithm ("pop_back")

See also
IAlgContextSvc

Definition at line 156 of file AlgContextSvc.cpp.

156 {
157 // check whether thread-local algorithm list already exists
158 // if not, create it
159 if ( !m_algorithms.get() ) { m_algorithms.reset( new IAlgContextSvc::Algorithms() ); }
160
161 if ( !a ) {
162 warning() << "IAlgorithm* points to NULL" << endmsg;
164 }
165
166 if ( !m_bypassInc ) {
167 if ( !m_inEvtLoop[context.valid() ? context.slot() : 0] ) return StatusCode::SUCCESS;
168 }
169
170 if ( a->type() != "IncidentProcAlg" ) {
171 // if ( m_algorithms->empty() || m_algorithms->back() != a ){
172 // error() << "Algorithm stack is invalid" << endmsg ;
173 // return StatusCode::FAILURE ;
174 // }
175 if ( !m_algorithms->empty() ) {
176 if ( m_algorithms->back() == a ) { m_algorithms->pop_back(); }
177 }
178 }
179 return StatusCode::SUCCESS;
180}

Member Data Documentation

◆ m_algorithms

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

the stack of current algorithms

Definition at line 64 of file AlgContextSvc.cpp.

◆ m_bypassInc

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

Definition at line 69 of file AlgContextSvc.cpp.

69 { this, "BypassIncidents", false,
70 "Flag to bypass begin/endevent incident requirement" };

◆ m_check

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

Definition at line 68 of file AlgContextSvc.cpp.

68{ this, "Check", true, "Flag to perform more checks" };

◆ m_inc

SmartIF<IIncidentSvc> AlgContextSvc::m_inc = nullptr
private

pointer to Incident Service

Definition at line 66 of file AlgContextSvc.cpp.

◆ m_inEvtLoop

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

Definition at line 71 of file AlgContextSvc.cpp.


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