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;
98 error() <<
"Could not locate 'IncidentSvc'" <<
endmsg;
101 m_inc->addListener(
this, IncidentType::BeginEvent );
102 m_inc->addListener(
this, IncidentType::EndEvent );
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 );
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> {
223 std::list<IService*> m_services;
226 const std::list<IService*>& getServices()
const override {
return m_services; }
227 bool existsService( std::string_view )
const override {
return false; }
228 SmartIF<IService>& service(
const Gaudi::Utils::TypeNameString& ,
229 const bool )
override {
233 struct Algorithm : Gaudi::Algorithm {
239TEST_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() );
260 CHECK( empty_algorithms != algorithms );
262 REQUIRE( algorithms !=
nullptr );
268 REQUIRE( acs.unSetCurrentAlg( &alg, ctx ).isSuccess() );
271 REQUIRE( algorithms !=
nullptr );
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
Simple implementation of interface IAlgContextSvc for Algorithm Context Service.
StatusCode start() override
void handle(const Incident &) override
StatusCode finalize() override
StatusCode initialize() override
StatusCode setCurrentAlg(IAlgorithm *a, const EventContext &context) override
set the currently executing algorithm ("push_back")
const IAlgContextSvc::Algorithms & algorithms() const override
get the stack of executed algorithms
Gaudi::Property< bool > m_bypassInc
SmartIF< IIncidentSvc > m_inc
pointer to Incident Service
std::vector< int > m_inEvtLoop
StatusCode unSetCurrentAlg(IAlgorithm *a, const EventContext &context) override
remove the algorithm ("pop_back")
IAlgorithm * currentAlg() const override
accessor to current algorithm:
boost::thread_specific_ptr< IAlgContextSvc::Algorithms > m_algorithms
the stack of current algorithms
Gaudi::Property< bool > m_check
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class represents an entry point to all the event specific data.
static constexpr ContextID_t INVALID_CONTEXT_ID
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
static GAUDI_API std::size_t numConcurrentEvents()
number of Concurrent Events (for MT)
Implementation of property with value of concrete type.
std::vector< IAlgorithm * > Algorithms
the actual type of algorithm' stack
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual const std::string & type() const =0
The type of the algorithm.
Base class for all Incidents (computing events).
EventContext context() const
Access to the EventContext of the source of the incident.
const std::string & type() const
Access to the incident type.
StatusCode finalize() override
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
StatusCode start() override
StatusCode initialize() override
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
constexpr static const auto RECOVERABLE
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
Base class used to extend a class implementing other interfaces.
Base class used to implement the interfaces.