MinimalEventLoopMgr Class Reference

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

#include </tmp/marcocle/lhcb-release/1122/GAUDI/GAUDI_v27r0/InstallArea/x86_64-slc6-gcc49-opt/include/GaudiKernel/MinimalEventLoopMgr.h>

Inheritance diagram for MinimalEventLoopMgr:
Collaboration diagram for MinimalEventLoopMgr:

Public Types

typedef std::vector< SmartIF< IAlgorithm > > ListAlg
 
typedef std::vector< SmartIF< IAlgorithm > > ListAlg
 
- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
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 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...
 
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...
 
 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< BASE, Interfaces >
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
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::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

enum  State {
  OFFLINE, CONFIGURED, FINALIZED, INITIALIZED,
  OFFLINE, CONFIGURED, FINALIZED, INITIALIZED
}
 
enum  State {
  OFFLINE, CONFIGURED, FINALIZED, INITIALIZED,
  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...
 

Private Member Functions

 MinimalEventLoopMgr (const MinimalEventLoopMgr &)
 Fake copy constructor (never implemented). More...
 
MinimalEventLoopMgroperator= (const MinimalEventLoopMgr &)
 Fake assignment operator (never implemented). More...
 
 MinimalEventLoopMgr (const MinimalEventLoopMgr &)
 Fake copy constructor (never implemented). More...
 
MinimalEventLoopMgroperator= (const MinimalEventLoopMgr &)
 Fake assignment operator (never implemented). 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

Definition at line 28 of file MinimalEventLoopMgr.h.

Definition at line 28 of file MinimalEventLoopMgr.h.

Member Enumeration Documentation

Enumerator
OFFLINE 
CONFIGURED 
FINALIZED 
INITIALIZED 
OFFLINE 
CONFIGURED 
FINALIZED 
INITIALIZED 

Definition at line 32 of file MinimalEventLoopMgr.h.

Enumerator
OFFLINE 
CONFIGURED 
FINALIZED 
INITIALIZED 
OFFLINE 
CONFIGURED 
FINALIZED 
INITIALIZED 

Definition at line 32 of file MinimalEventLoopMgr.h.

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
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
void topAlgHandler(Property &p)
Top algorithm List handler.
std::string m_outStreamType
Out Stream type.
StringArrayProperty m_topAlgNames
List of top level algorithms names.
StringArrayProperty m_outStreamNames
List of output stream names.
MinimalEventLoopMgr::~MinimalEventLoopMgr ( )
overridedefault

Standard Destructor.

MinimalEventLoopMgr::MinimalEventLoopMgr ( const MinimalEventLoopMgr )
private

Fake copy constructor (never implemented).

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

Standard Constructor.

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
515  m_outStreamList.clear();
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  }
533  m_outStreamList.push_back( os );
534  }
535  return sc;
536  }
537  sc = StatusCode::FAILURE;
538  }
539  return sc;
540 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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
State m_state
State of the object.
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
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:23
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.
StatusCode MinimalEventLoopMgr::decodeOutStreams ( )

decodeOutStreamNameList & outStreamNameListHandler

StatusCode MinimalEventLoopMgr::decodeTopAlgs ( )

decodeTopAlgNameList & topAlgNameListHandler

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( );
466  m_topAlgList.reserve( m_topAlgNames.value().size() );
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 }
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
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
State m_state
State of the object.
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
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:23
const TYPE & value() const
explicit conversion
Definition: Property.h:341
tuple item
print s1,s2
Definition: ana.py:146
StringArrayProperty m_topAlgNames
List of top level algorithms names.
#define DEBMSG
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::executeEvent ( void *  par)
override
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 general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
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
std::string m_abortEventSource
Source of the AbortEvent incident.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
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
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:23
ListAlg m_outStreamList
List of output streams.
#define UNLIKELY(x)
Definition: Kernel.h:126
#define DEBMSG
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
#define LIKELY(x)
Definition: Kernel.h:125
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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode nextEvent(int maxevt) override
implementation of IEventProcessor::nextEvent
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::executeRun ( int  maxevt)
override

implementation of IEventProcessor::executeRun( )

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< IIncidentSvc > m_incidentSvc
Reference to the incident service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode finalize() override
Definition: Service.cpp:188
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< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
State m_state
State of the object.
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
ListAlg m_outStreamList
List of output streams.
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
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.
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::finalize ( )
override

implementation of IService::finalize

StatusCode MinimalEventLoopMgr::initialize ( )
override

implementation of IService::initialize

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 }
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
StatusCode initialize() override
Definition: Service.cpp:63
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
StatusCode decodeTopAlgs()
decodeTopAlgNameList & topAlgNameListHandler
State m_state
State of the object.
std::string m_abortEventSource
Source of the AbortEvent incident.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:254
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.
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
StringArrayProperty m_topAlgNames
List of top level algorithms names.
StatusCode decodeOutStreams()
decodeOutStreamNameList & outStreamNameListHandler
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.
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

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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
MinimalEventLoopMgr& MinimalEventLoopMgr::operator= ( const MinimalEventLoopMgr )
private

Fake assignment operator (never implemented).

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
void MinimalEventLoopMgr::outStreamHandler ( Property p)

Output stream List handler.

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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::reinitialize ( )
override

implementation of IService::reinitialize

StatusCode MinimalEventLoopMgr::restart ( )
override

implementation of IService::restart

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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode start() override
Definition: Service.cpp:147
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::start ( )
override

implementation of IService::start

StatusCode MinimalEventLoopMgr::stop ( )
override

implementation of IService::stop

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 & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode stop() override
Definition: Service.cpp:141
ListAlg m_outStreamList
List of output streams.
ListAlg m_topAlgList
List of top level algorithms.
StatusCode MinimalEventLoopMgr::stopRun ( )
override

implementation of IEventProcessor::stopRun( )

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 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool m_scheduledStop
Scheduled stop of event processing.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
constexpr int ScheduledStop
Definition: AppReturnCode.h:25
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
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
void MinimalEventLoopMgr::topAlgHandler ( Property p)

Top algorithm List handler.

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 55 of file MinimalEventLoopMgr.h.

SmartIF< IIncidentListener > MinimalEventLoopMgr::m_abortEventListener
protected

Instance of the incident listener waiting for AbortEvent.

Definition at line 52 of file MinimalEventLoopMgr.h.

std::string MinimalEventLoopMgr::m_abortEventSource
protected

Source of the AbortEvent incident.

Definition at line 57 of file MinimalEventLoopMgr.h.

SmartIF< IAppMgrUI > MinimalEventLoopMgr::m_appMgrUI
protected

Reference to the IAppMgrUI interface of the application manager.

Definition at line 34 of file MinimalEventLoopMgr.h.

SmartIF< IIncidentSvc > MinimalEventLoopMgr::m_incidentSvc
protected

Reference to the incident service.

Definition at line 36 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_outStreamList
protected

List of output streams.

Definition at line 40 of file MinimalEventLoopMgr.h.

StringArrayProperty MinimalEventLoopMgr::m_outStreamNames
protected

List of output stream names.

Definition at line 46 of file MinimalEventLoopMgr.h.

std::string MinimalEventLoopMgr::m_outStreamType
protected

Out Stream type.

Definition at line 42 of file MinimalEventLoopMgr.h.

bool MinimalEventLoopMgr::m_scheduledStop = false
protected

Scheduled stop of event processing.

Definition at line 50 of file MinimalEventLoopMgr.h.

State MinimalEventLoopMgr::m_state = OFFLINE
protected

State of the object.

Definition at line 48 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_topAlgList
protected

List of top level algorithms.

Definition at line 38 of file MinimalEventLoopMgr.h.

StringArrayProperty MinimalEventLoopMgr::m_topAlgNames
protected

List of top level algorithms names.

Definition at line 44 of file MinimalEventLoopMgr.h.


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