Go to the documentation of this file.
20 #include <boost/thread.hpp>
60 using extends::extends;
64 boost::thread_specific_ptr<IAlgContextSvc::Algorithms>
m_algorithms;
70 "Flag to bypass begin/endevent incident requirement" };
82 m_inc->removeListener(
this );
87 numSlots = ( 1 > numSlots ) ? 1 : numSlots;
88 if ( numSlots > 1000 ) {
89 warning() <<
"Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots <<
endmsg;
91 warning() <<
"Setting numSlots to " << numSlots <<
endmsg;
93 m_inEvtLoop.resize( numSlots, 0 );
98 error() <<
"Could not locate 'IncidentSvc'" <<
endmsg;
101 m_inc->addListener(
this, IncidentType::BeginEvent );
102 m_inc->addListener(
this, IncidentType::EndEvent );
104 if ( m_algorithms.get() && !m_algorithms->empty() ) {
105 warning() <<
"Non-empty stack of algorithms #" << m_algorithms->size() <<
endmsg;
117 numSlots = ( 1 > numSlots ) ? 1 : numSlots;
118 if ( numSlots > 1000 ) {
119 warning() <<
"Num Slots are greater than 1000. Is this correct? numSlots=" << numSlots <<
endmsg;
133 m_inc->removeListener(
this );
142 warning() <<
"IAlgorithm* points to NULL" <<
endmsg;
162 warning() <<
"IAlgorithm* points to NULL" <<
endmsg;
170 if ( a->
type() !=
"IncidentProcAlg" ) {
190 if ( inc.
type() ==
"BeginEvent" ) {
192 }
else if ( inc.
type() ==
"EndEvent" ) {
210 #if defined( BUILD_UNIT_TESTS )
211 # if __has_include( <catch2/catch.hpp>)
213 # include <catch2/catch.hpp>
216 # include <catch2/catch_test_macros.hpp>
222 struct ServiceLocator :
implements<ISvcLocator> {
227 bool existsService( std::string_view )
const override {
return false; }
229 const bool )
override {
239 TEST_CASE(
"AlgContextSvc basic operations" ) {
242 REQUIRE( acs.setProperty(
"BypassIncidents",
true ).isSuccess() );
246 auto empty_algorithms = &acs.algorithms();
247 REQUIRE( empty_algorithms !=
nullptr );
248 CHECK( empty_algorithms->empty() );
250 mock::Algorithm
alg{
"dummy", svcLoc };
254 REQUIRE( acs.setCurrentAlg( &
alg,
ctx ).isSuccess() );
268 REQUIRE( acs.unSetCurrentAlg( &
alg,
ctx ).isSuccess() );
IAlgorithm * currentAlg() const override
accessor to current algorithm:
Gaudi::Property< bool > m_check
StatusCode initialize() override
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
void handle(const Incident &) override
std::vector< int > m_inEvtLoop
StatusCode start() override
StatusCode start() override
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Alias for backward compatibility.
StatusCode setCurrentAlg(IAlgorithm *a, const EventContext &context) override
set the currently executing algorithm ("push_back")
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
static constexpr ContextID_t INVALID_CONTEXT_ID
virtual const std::string & type() const =0
The type of the algorithm.
Gaudi::Property< bool > m_bypassInc
StatusCode finalize() override
static GAUDI_API std::size_t numConcurrentEvents()
number of Concurrent Events (for MT)
EventContext context() const
Access to the EventContext of the source of the incident.
Helper class to parse a string of format "type/name".
Base class from which all concrete algorithm classes should be derived.
const IAlgContextSvc::Algorithms & algorithms() const override
get the stack of executed algorithms
StatusCode unSetCurrentAlg(IAlgorithm *a, const EventContext &context) override
remove the algorithm ("pop_back")
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Base class used to extend a class implementing other interfaces.
StatusCode finalize() override
Base class used to implement the interfaces.
constexpr static const auto SUCCESS
#define DECLARE_COMPONENT(type)
const std::string & type() const
Access to the incident type.
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
constexpr static const auto FAILURE
constexpr static const auto RECOVERABLE
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.
StatusCode initialize() override