MinimalEventLoopMgr Class Reference

This is the default processing manager of the application manager. More...

#include <GaudiKernel/MinimalEventLoopMgr.h>

Inheritance diagram for MinimalEventLoopMgr:
Collaboration diagram for MinimalEventLoopMgr:

Public Types

typedef std::vector< SmartIF< IAlgorithm > > ListAlg
 
- Public Types inherited from extends< Service, IEventProcessor >
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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- 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...
 

Public Member Functions

 MinimalEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor. More...
 
 ~MinimalEventLoopMgr () override=default
 Standard Destructor. More...
 
StatusCode initialize () override
 implementation of IService::initialize More...
 
StatusCode start () override
 implementation of IService::start More...
 
StatusCode stop () override
 implementation of IService::stop More...
 
StatusCode finalize () override
 implementation of IService::finalize More...
 
StatusCode reinitialize () override
 implementation of IService::reinitialize More...
 
StatusCode restart () override
 implementation of IService::restart More...
 
StatusCode nextEvent (int maxevt) override
 implementation of IEventProcessor::nextEvent More...
 
StatusCode executeEvent (void *par) override
 implementation of IEventProcessor::executeEvent(void* par) More...
 
StatusCode executeRun (int maxevt) override
 implementation of IEventProcessor::executeRun( ) More...
 
StatusCode stopRun () override
 implementation of IEventProcessor::stopRun( ) More...
 
void topAlgHandler (Property &p)
 Top algorithm List handler. More...
 
StatusCode decodeTopAlgs ()
 decodeTopAlgNameList & topAlgNameListHandler More...
 
void outStreamHandler (Property &p)
 Output stream List handler. More...
 
StatusCode decodeOutStreams ()
 decodeOutStreamNameList & outStreamNameListHandler More...
 
- Public Member Functions inherited from extends< Service, IEventProcessor >
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...
 
 ~extends () override=default
 Virtual destructor. 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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

enum  State { OFFLINE, CONFIGURED, FINALIZED, INITIALIZED }
 

Protected Attributes

SmartIF< IAppMgrUIm_appMgrUI
 Reference to the IAppMgrUI interface of the application manager. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service. More...
 
ListAlg m_topAlgList
 List of top level algorithms. More...
 
ListAlg m_outStreamList
 List of output streams. More...
 
std::string m_outStreamType
 Out Stream type. More...
 
StringArrayProperty m_topAlgNames
 List of top level algorithms names. More...
 
StringArrayProperty m_outStreamNames
 List of output stream names. More...
 
State m_state = OFFLINE
 State of the object. More...
 
bool m_scheduledStop = false
 Scheduled stop of event processing. More...
 
SmartIF< IIncidentListenerm_abortEventListener
 Instance of the incident listener waiting for AbortEvent. More...
 
bool m_abortEvent = false
 Flag signalling that the event being processedhas to be aborted (skip all following top algs). More...
 
std::string m_abortEventSource
 Source of the AbortEvent incident. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Private Member Functions

 MinimalEventLoopMgr (const MinimalEventLoopMgr &)
 Fake copy constructor (never implemented). More...
 
MinimalEventLoopMgroperator= (const MinimalEventLoopMgr &)
 Fake assignment operator (never implemented). More...
 

Additional Inherited Members

- Protected Member Functions inherited from Service
 ~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 > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

This is the default processing manager of the application manager.

This object handles the minimal requirements needed by the application manager. It also is capable of handling a bunch of algorithms and output streams. However, they list may as well be empty.

Author
Markus Frank
Version
1.0

Definition at line 25 of file MinimalEventLoopMgr.h.

Member Typedef Documentation

Member Enumeration Documentation

Constructor & Destructor Documentation

MinimalEventLoopMgr::MinimalEventLoopMgr ( const std::string nam,
ISvcLocator svcLoc 
)

Standard Constructor.

Definition at line 52 of file MinimalEventLoopMgr.cpp.

53  : base_class(nam, svcLoc), m_appMgrUI(svcLoc)
54 {
55  declareProperty("TopAlg", m_topAlgNames );
56  declareProperty("OutStream", m_outStreamNames );
57  declareProperty("OutStreamType", m_outStreamType = "OutputStream");
60 }
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
void outStreamHandler(Property &p)
Output stream List handler.
extends base_class
Typedef to this class.
Definition: extends.h:14
void topAlgHandler(Property &p)
Top algorithm List handler.
std::string m_outStreamType
Out Stream type.
StringArrayProperty m_topAlgNames
List of top level algorithms names.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
StringArrayProperty m_outStreamNames
List of output stream names.
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
MinimalEventLoopMgr::~MinimalEventLoopMgr ( )
overridedefault

Standard Destructor.

MinimalEventLoopMgr::MinimalEventLoopMgr ( const MinimalEventLoopMgr )
private

Fake copy constructor (never implemented).

Member Function Documentation

StatusCode MinimalEventLoopMgr::decodeOutStreams ( )

decodeOutStreamNameList & outStreamNameListHandler

Definition at line 509 of file MinimalEventLoopMgr.cpp.

509  {
511  if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
512  auto algMan = serviceLocator()->as<IAlgManager>();
513  if ( algMan ) {
514  // Reset the existing Top Algorithm List
516  for (const auto& it : m_outStreamNames.value( ) ) {
518  DEBMSG << "Creating " << m_outStreamType << it << endmsg;
519  const bool CREATE = false;
520  SmartIF<IAlgorithm> os = algMan->algorithm( item, CREATE );
521  if (os) {
522  DEBMSG << "Output Stream " << item.name() << " already exists" << endmsg;
523  } else {
524  DEBMSG << "Creating Output Stream " << it << endmsg;
525  IAlgorithm* ios = nullptr;
526  StatusCode sc1 = algMan->createAlgorithm( item.type(), item.name(), ios );
527  if( !sc1.isSuccess() ) {
528  error() << "Unable to create Output Stream " << it << endmsg;
529  return sc1;
530  }
531  os = ios; // manage reference counting
532  }
534  }
535  return sc;
536  }
537  sc = StatusCode::FAILURE;
538  }
539  return sc;
540 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
State m_state
State of the object.
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T clear(T...args)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
const TYPE & value() const
explicit conversion
Definition: Property.h:341
ListAlg m_outStreamList
List of output streams.
tuple item
print s1,s2
Definition: ana.py:146
std::string m_outStreamType
Out Stream type.
#define DEBMSG
StringArrayProperty m_outStreamNames
List of output stream names.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::decodeTopAlgs ( )

decodeTopAlgNameList & topAlgNameListHandler

Definition at line 459 of file MinimalEventLoopMgr.cpp.

459  {
461  if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
462  auto algMan = serviceLocator()->as<IAlgManager>();
463  if ( algMan ) {
464  // Reset the existing Top Algorithm List
465  m_topAlgList.clear( );
467  for (const auto& it : m_topAlgNames.value( )) {
469  // Got the type and name. Now creating the algorithm, avoiding duplicate creation.
470  std::string item_name = item.name() + getGaudiThreadIDfromName(name());
471  const bool CREATE = false;
472  SmartIF<IAlgorithm> alg = algMan->algorithm(item_name, CREATE);
473  if (alg) {
474  DEBMSG << "Top Algorithm " << item_name << " already exists" << endmsg;
475  }
476  else {
477  DEBMSG << "Creating Top Algorithm " << item.type() << " with name " << item_name << endmsg;
478  IAlgorithm *ialg = nullptr;
479  StatusCode sc1 = algMan->createAlgorithm(item.type(), item_name, ialg);
480  if( !sc1.isSuccess() ) {
481  error() << "Unable to create Top Algorithm " << item.type() << " with name " << item_name << endmsg;
482  return sc1;
483  }
484  alg = ialg; // manage reference counting
485  }
486  m_topAlgList.push_back(alg);
487  }
488  return sc;
489  }
490  sc = StatusCode::FAILURE;
491  }
492  return sc;
493 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
STL class.
State m_state
State of the object.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T clear(T...args)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
const TYPE & value() const
explicit conversion
Definition: Property.h:341
T size(T...args)
tuple item
print s1,s2
Definition: ana.py:146
StringArrayProperty m_topAlgNames
List of top level algorithms names.
#define DEBMSG
GAUDI_API std::string getGaudiThreadIDfromName(const std::string &name)
helper function to extract Gaudi Thread ID from thread copy name
Definition: ThreadGaudi.cpp:26
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
T reserve(T...args)
StatusCode MinimalEventLoopMgr::executeEvent ( void *  par)
override

implementation of IEventProcessor::executeEvent(void* par)

Definition at line 358 of file MinimalEventLoopMgr.cpp.

358  {
359  bool eventfailed = false;
360 
361  // Call the resetExecuted() method of ALL "known" algorithms
362  // (before we were reseting only the topalgs)
363  auto algMan = serviceLocator()->as<IAlgManager>();
364  if (LIKELY(algMan.isValid())) {
365  const auto& allAlgs = algMan->getAlgorithms();
366  std::for_each( std::begin(allAlgs), std::end(allAlgs),
367  [](IAlgorithm* alg) {
368  if (LIKELY(alg!=nullptr)) alg->resetExecuted();
369  } );
370  }
371 
372  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
373  const auto appmgr = serviceLocator()->as<IProperty>();
374  // Call the execute() method of all top algorithms
375  for (auto& ita : m_topAlgList ) {
377  try {
378  if (UNLIKELY(m_abortEvent)) {
379  DEBMSG << "AbortEvent incident fired by "
381  m_abortEvent = false;
382  sc.ignore();
383  break;
384  }
386  sc = ita->sysExecute();
387  rcg.ignore(); // disarm the guard
388  } catch ( const GaudiException& Exception ) {
389  fatal() << ".executeEvent(): Exception with tag=" << Exception.tag()
390  << " thrown by " << ita->name() << endmsg;
391  error() << Exception << endmsg;
392  } catch ( const std::exception& Exception ) {
393  fatal() << ".executeEvent(): Standard std::exception thrown by "
394  << ita->name() << endmsg;
395  error() << Exception.what() << endmsg;
396  } catch(...) {
397  fatal() << ".executeEvent(): UNKNOWN Exception thrown by "
398  << ita->name() << endmsg;
399  }
400 
401  if (UNLIKELY(!sc.isSuccess())) {
402  warning() << "Execution of algorithm " << ita->name() << " failed" << endmsg;
403  eventfailed = true;
404  }
405  }
406 
407  // ensure that the abortEvent flag is cleared before the next event
408  if (UNLIKELY(m_abortEvent)) {
409  DEBMSG << "AbortEvent incident fired by " << m_abortEventSource << endmsg;
410  m_abortEvent = false;
411  }
412 
413  // Call the execute() method of all output streams
414  for (auto& ito : m_outStreamList) {
415  ito->resetExecuted();
416  StatusCode sc;
417  sc = ito->sysExecute();
418  if (UNLIKELY(!sc.isSuccess())) {
419  warning() << "Execution of output stream " << ito->name() << " failed" << endmsg;
420  eventfailed = true;
421  }
422  }
423 
424  // Check if there was an error processing current event
425  if (UNLIKELY(eventfailed)){
426  error() << "Error processing event loop." << endmsg;
427  return StatusCode(StatusCode::FAILURE,true);
428  }
429  return StatusCode(StatusCode::SUCCESS,true);
430 }
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
Define general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
T end(T...args)
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
virtual const std::vector< IAlgorithm * > & getAlgorithms() const =0
Return the list of Algorithms.
virtual void resetExecuted()=0
Reset the Algorithm executed state for the current event.
constexpr int UnhandledException
Definition: AppReturnCode.h:27
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_abortEventSource
Source of the AbortEvent incident.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
#define LIKELY(x)
Definition: Kernel.h:125
ListAlg m_outStreamList
List of output streams.
T begin(T...args)
#define DEBMSG
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
T for_each(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
bool m_abortEvent
Flag signalling that the event being processedhas to be aborted (skip all following top algs)...
StatusCode MinimalEventLoopMgr::executeRun ( int  maxevt)
override

implementation of IEventProcessor::executeRun( )

Definition at line 306 of file MinimalEventLoopMgr.cpp.

306  {
307  StatusCode sc;
308  bool eventfailed = false;
309 
310  // Call the beginRun() method of all top algorithms
311  for (auto& ita : m_topAlgList ) {
312  sc = ita->sysBeginRun();
313  if (!sc.isSuccess()) {
314  warning() << "beginRun() of algorithm " << ita->name() << " failed" << endmsg;
315  eventfailed = true;
316  }
317  }
318 
319  // Call now the nextEvent(...)
320  sc = nextEvent(maxevt);
321  if (!sc.isSuccess()) eventfailed = true;
322 
323  // Call the endRun() method of all top algorithms
324  for (auto& ita : m_topAlgList) {
325  sc = ita->sysEndRun();
326  if (!sc.isSuccess()) {
327  warning() << "endRun() of algorithm " << ita->name() << " failed" << endmsg;
328  eventfailed = true;
329  }
330  }
331 
332  return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
333 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode nextEvent(int maxevt) override
implementation of IEventProcessor::nextEvent
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::finalize ( )
override

implementation of IService::finalize

Definition at line 247 of file MinimalEventLoopMgr.cpp.

247  {
250  // Call the finalize() method of all top algorithms
251  for (auto& ita : m_topAlgList ) {
252  sc = ita->sysFinalize();
253  if( !sc.isSuccess() ) {
254  scRet = StatusCode::FAILURE;
255  warning() << "Finalization of algorithm " << ita->name() << " failed" << endmsg;
256  }
257  }
258  // Call the finalize() method of all Output streams
259  for (auto &ita : m_outStreamList) {
260  sc = ita->sysFinalize();
261  if( !sc.isSuccess() ) {
262  scRet = StatusCode::FAILURE;
263  warning() << "Finalization of algorithm " << ita->name() << " failed" << endmsg;
264  }
265  }
266  // release all top algorithms
267  auto algMan = serviceLocator()->as<IAlgManager>();
268  for (auto &ita : m_topAlgList ) {
269  if (algMan->removeAlgorithm(ita).isFailure()) {
270  scRet = StatusCode::FAILURE;
271  warning() << "Problems removing Algorithm " << ita->name() << endmsg;
272  }
273  }
274  m_topAlgList.clear();
275  m_outStreamList.clear();
276  if ( sc.isSuccess() ) m_state = FINALIZED;
277 
278  m_incidentSvc->removeListener(m_abortEventListener, IncidentType::AbortEvent);
280 
282  m_appMgrUI.reset();
283 
284  sc = Service::finalize();
285 
286  if (sc.isFailure()) {
287  scRet = StatusCode::FAILURE;
288  error() << "Problems finalizing Service base class" << endmsg;
289  }
290 
291  return scRet;
292 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
StatusCode finalize() override
Definition: Service.cpp:193
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
State m_state
State of the object.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
ListAlg m_outStreamList
List of output streams.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::initialize ( )
override

implementation of IService::initialize

Definition at line 65 of file MinimalEventLoopMgr.cpp.

65  {
66 
67  if ( !m_appMgrUI ) return StatusCode::FAILURE;
68 
70  if ( !sc.isSuccess() ) {
71  error() << "Failed to initialize Service Base class." << endmsg;
72  return StatusCode::FAILURE;
73  }
74 
75  auto prpMgr = serviceLocator()->as<IProperty>();
76  if ( !prpMgr ) {
77  error() << "Error retrieving AppMgr interface IProperty." << endmsg;
78  return StatusCode::FAILURE;
79  }
80  if ( m_topAlgNames.value().empty() ) {
81  setProperty(prpMgr->getProperty("TopAlg")).ignore();
82  }
83  if ( m_outStreamNames.value().empty() ) {
84  setProperty(prpMgr->getProperty("OutStream")).ignore();
85  }
86 
87  // Get the references to the services that are needed by the ApplicationMgr itself
88  m_incidentSvc = serviceLocator()->service("IncidentSvc");
89  if( !m_incidentSvc ) {
90  fatal() << "Error retrieving IncidentSvc." << endmsg;
91  return StatusCode::FAILURE;
92  }
93 
94  m_abortEventListener = new AbortEventListener(m_abortEvent,m_abortEventSource);
95  m_incidentSvc->addListener(m_abortEventListener,IncidentType::AbortEvent);
96 
97  // The state is changed at this moment to allow decodeXXXX() to do something
99 
100  //--------------------------------------------------------------------------------------------
101  // Create output streams. Do not initialize them yet.
102  // The state is updated temporarily in order to enable the handler, which
103  // is also triggered by a change to the "OutputStream" Property.
104  //--------------------------------------------------------------------------------------------
105  sc = decodeOutStreams();
106  if ( !sc.isSuccess() ) {
107  error() << "Failed to initialize Output streams." << endmsg;
109  return sc;
110  }
111  //--------------------------------------------------------------------------------------------
112  // Create all needed Top Algorithms. Do not initialize them yet.
113  // The state is updated temporarily in order to enable the handler, which
114  // is also triggered by a change to the "TopAlg" Property.
115  //--------------------------------------------------------------------------------------------
116  sc = decodeTopAlgs();
117  if ( !sc.isSuccess() ) {
118  error() << "Failed to initialize Top Algorithms streams." << endmsg;
120  return sc;
121  }
122 
123  // Initialize all the new TopAlgs. In fact Algorithms are protected against getting
124  // initialized twice.
125  for (auto& ita : m_topAlgList ) {
126  sc = ita->sysInitialize();
127  if( !sc.isSuccess() ) {
128  error() << "Unable to initialize Algorithm: " << ita->name() << endmsg;
129  return sc;
130  }
131  }
132  for (auto& ita : m_outStreamList ) {
133  sc = ita->sysInitialize();
134  if( !sc.isSuccess() ) {
135  error() << "Unable to initialize Output Stream: " << ita->name() << endmsg;
136  return sc;
137  }
138  }
139 
140  return StatusCode::SUCCESS;
141 }
StatusCode initialize() override
Definition: Service.cpp:68
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
T empty(T...args)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode setProperty(const Property &p) override
Definition: Service.cpp:330
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
StatusCode decodeTopAlgs()
decodeTopAlgNameList & topAlgNameListHandler
State m_state
State of the object.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_abortEventSource
Source of the AbortEvent incident.
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
const TYPE & value() const
explicit conversion
Definition: Property.h:341
ListAlg m_outStreamList
List of output streams.
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StringArrayProperty m_topAlgNames
List of top level algorithms names.
StatusCode decodeOutStreams()
decodeOutStreamNameList & outStreamNameListHandler
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
StringArrayProperty m_outStreamNames
List of output stream names.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
ListAlg m_topAlgList
List of top level algorithms.
bool m_abortEvent
Flag signalling that the event being processedhas to be aborted (skip all following top algs)...
StatusCode MinimalEventLoopMgr::nextEvent ( int  maxevt)
override

implementation of IEventProcessor::nextEvent

Definition at line 297 of file MinimalEventLoopMgr.cpp.

297  {
298  error() << "This method cannot be called on an object of type "
299  << System::typeinfoName(typeid(*this)) << endmsg;
300  return StatusCode::FAILURE;
301 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MinimalEventLoopMgr& MinimalEventLoopMgr::operator= ( const MinimalEventLoopMgr )
private

Fake assignment operator (never implemented).

void MinimalEventLoopMgr::outStreamHandler ( Property p)

Output stream List handler.

Definition at line 498 of file MinimalEventLoopMgr.cpp.

498  {
499  if ( !(decodeOutStreams( )).isSuccess() ) {
500  throw GaudiException("Failed to initialize output streams.",
501  "MinimalEventLoopMgr::outStreamHandler",
503  }
504 }
Define general base for Gaudi exception.
StatusCode decodeOutStreams()
decodeOutStreamNameList & outStreamNameListHandler
StatusCode MinimalEventLoopMgr::reinitialize ( )
override

implementation of IService::reinitialize

Definition at line 198 of file MinimalEventLoopMgr.cpp.

198  {
200 
201  // Reinitialize all the TopAlgs.
202  for (auto& ita : m_topAlgList) {
203  sc = ita->sysReinitialize();
204  if( !sc.isSuccess() ) {
205  error() << "Unable to reinitialize Algorithm: " << ita->name() << endmsg;
206  return sc;
207  }
208  }
209  for (auto &ita : m_outStreamList ) {
210  sc = ita->sysReinitialize();
211  if( !sc.isSuccess() ) {
212  error() << "Unable to reinitialize Output Stream: " << ita->name() << endmsg;
213  return sc;
214  }
215  }
216 
217  return sc;
218 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::restart ( )
override

implementation of IService::restart

Definition at line 222 of file MinimalEventLoopMgr.cpp.

222  {
224 
225  // Restart all the TopAlgs.
226  for (auto& ita : m_topAlgList ) {
227  sc = ita->sysRestart();
228  if( !sc.isSuccess() ) {
229  error() << "Unable to restart Algorithm: " << ita->name() << endmsg;
230  return sc;
231  }
232  }
233  for (auto& ita : m_outStreamList ) {
234  sc = ita->sysRestart();
235  if( !sc.isSuccess() ) {
236  error() << "Unable to restart Output Stream: " << ita->name() << endmsg;
237  return sc;
238  }
239  }
240 
241  return sc;
242 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::start ( )
override

implementation of IService::start

Definition at line 145 of file MinimalEventLoopMgr.cpp.

145  {
146 
148  if ( ! sc.isSuccess() ) return sc;
149 
150  // Start all the new TopAlgs. In fact Algorithms are protected against getting
151  // started twice.
152  for (auto& ita : m_topAlgList) {
153  sc = ita->sysStart();
154  if( !sc.isSuccess() ) {
155  error() << "Unable to start Algorithm: " << ita->name() << endmsg;
156  return sc;
157  }
158  }
159  for (auto& ita : m_outStreamList ) {
160  sc = ita->sysStart();
161  if( !sc.isSuccess() ) {
162  error() << "Unable to start Output Stream: " << ita->name() << endmsg;
163  return sc;
164  }
165  }
166  return StatusCode::SUCCESS;
167 }
StatusCode start() override
Definition: Service.cpp:152
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::stop ( )
override

implementation of IService::stop

Definition at line 171 of file MinimalEventLoopMgr.cpp.

171  {
172 
174 
175  // Stop all the TopAlgs. In fact Algorithms are protected against getting
176  // stopped twice.
177  for (auto & ita : m_topAlgList ) {
178  sc = ita->sysStop();
179  if( !sc.isSuccess() ) {
180  error() << "Unable to stop Algorithm: " << ita->name() << endmsg;
181  return sc;
182  }
183  }
184  for (auto &ita : m_outStreamList ) {
185  sc = ita->sysStop();
186  if( !sc.isSuccess() ) {
187  error() << "Unable to stop Output Stream: " << ita->name() << endmsg;
188  return sc;
189  }
190  }
191 
192  return Service::stop();
193 }
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode stop() override
Definition: Service.cpp:146
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::stopRun ( )
override

implementation of IEventProcessor::stopRun( )

Definition at line 434 of file MinimalEventLoopMgr.cpp.

434  {
435  // Set the application return code
436  auto appmgr = serviceLocator()->as<IProperty>();
438  error() << "Could not set return code of the application ("
440  }
441  m_scheduledStop = true;
442  return StatusCode::SUCCESS;
443 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
bool m_scheduledStop
Scheduled stop of event processing.
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
constexpr int ScheduledStop
Definition: AppReturnCode.h:25
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:50
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void MinimalEventLoopMgr::topAlgHandler ( Property p)

Top algorithm List handler.

Definition at line 448 of file MinimalEventLoopMgr.cpp.

448  {
449  if ( !(decodeTopAlgs( )).isSuccess() ) {
450  throw GaudiException("Failed to initialize Top Algorithms streams.",
451  "MinimalEventLoopMgr::topAlgHandler",
453  }
454 }
Define general base for Gaudi exception.
StatusCode decodeTopAlgs()
decodeTopAlgNameList & topAlgNameListHandler

Member Data Documentation

bool MinimalEventLoopMgr::m_abortEvent = false
protected

Flag signalling that the event being processedhas to be aborted (skip all following top algs).

Definition at line 56 of file MinimalEventLoopMgr.h.

SmartIF<IIncidentListener> MinimalEventLoopMgr::m_abortEventListener
protected

Instance of the incident listener waiting for AbortEvent.

Definition at line 53 of file MinimalEventLoopMgr.h.

std::string MinimalEventLoopMgr::m_abortEventSource
protected

Source of the AbortEvent incident.

Definition at line 58 of file MinimalEventLoopMgr.h.

SmartIF<IAppMgrUI> MinimalEventLoopMgr::m_appMgrUI
protected

Reference to the IAppMgrUI interface of the application manager.

Definition at line 35 of file MinimalEventLoopMgr.h.

SmartIF<IIncidentSvc> MinimalEventLoopMgr::m_incidentSvc
protected

Reference to the incident service.

Definition at line 37 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_outStreamList
protected

List of output streams.

Definition at line 41 of file MinimalEventLoopMgr.h.

StringArrayProperty MinimalEventLoopMgr::m_outStreamNames
protected

List of output stream names.

Definition at line 47 of file MinimalEventLoopMgr.h.

std::string MinimalEventLoopMgr::m_outStreamType
protected

Out Stream type.

Definition at line 43 of file MinimalEventLoopMgr.h.

bool MinimalEventLoopMgr::m_scheduledStop = false
protected

Scheduled stop of event processing.

Definition at line 51 of file MinimalEventLoopMgr.h.

State MinimalEventLoopMgr::m_state = OFFLINE
protected

State of the object.

Definition at line 49 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_topAlgList
protected

List of top level algorithms.

Definition at line 39 of file MinimalEventLoopMgr.h.

StringArrayProperty MinimalEventLoopMgr::m_topAlgNames
protected

List of top level algorithms names.

Definition at line 45 of file MinimalEventLoopMgr.h.


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