The Gaudi Framework master (934d2c3c)
Loading...
Searching...
No Matches
ApplicationMgr.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11
12// Local includes
13#include "AlgorithmManager.h"
14#include "DLLClassManager.h"
15#include "ServiceManager.h"
16
17// Framework includes
19#include <Gaudi/MonitoringHub.h>
30#include <GaudiKernel/Kernel.h>
32#include <GaudiKernel/Service.h>
33
34#include <GAUDI_VERSION.h>
39#include <GaudiKernel/Message.h>
42#include <GaudiKernel/SmartIF.h>
44#include <GaudiKernel/System.h>
45#include <GaudiKernel/Time.h>
47
48// Root includes
49#include <TError.h>
50#include <TROOT.h>
51
52// STL includes
53#include <algorithm>
54#include <cassert>
55#include <limits>
56#include <sstream>
57#include <vector>
58
72 : public PropertyHolder<CommonMessaging<implements<IAppMgrUI, Gaudi::Interfaces::IQueueingEventProcessor, IService,
73 IStateful, INamedInterface, IProperty>>> {
74public:
75 // default creator
76 ApplicationMgr( IInterface* = nullptr );
77
78 // Allow delegation of interfaces implementations
79 void const* i_cast( const InterfaceID& iid ) const override;
80
81 // implementation of IAppMgrUI::run
82 StatusCode run() override;
83 // implementation of IAppMgrUI::configure
84 StatusCode configure() override;
85 // implementation of IAppMgrUI::terminate
86 StatusCode terminate() override;
87 // implementation of IAppMgrUI::initialize
88 StatusCode initialize() override;
89 // implementation of IAppMgrUI::start
90 StatusCode start() override;
91 // implementation of IAppMgrUI::stop
92 StatusCode stop() override;
93 // implementation of IAppMgrUI::finalize
94 StatusCode finalize() override;
95 // implementation of IAppMgrUI::nextEvent
96 StatusCode nextEvent( int maxevt ) override;
97 // implementation of IAppMgrUI::name
98 const std::string& name() const override;
102 StatusCode executeEvent( EventContext&& ctx ) override;
104 StatusCode executeRun( int evtmax ) override;
106 StatusCode stopRun() override;
107
108 // implementation of IStateful::state
109 Gaudi::StateMachine::State FSMState() const override;
110 // implementation of IStateful::targetState
112 // implementation of IStateful::reinitialize
113 StatusCode reinitialize() override;
114 // implementation of IStateful::reinitialize
115 StatusCode restart() override;
116 // implementation of IService::sysItinitilaize
118 // implementation of IService::sysStart
120 // implementation of IService::sysStop
122 // implementation of IService::sysFinalize
124 // implementation of IService::sysReinitialize
126 // implementation of IService::sysRestart
128
130 void push( EventContext&& ctx ) override;
131 bool empty() const override;
132 std::optional<Gaudi::Interfaces::IQueueingEventProcessor::ResultType> pop() override;
134
136
146
147 template <class I>
149 return m_managers[I::interfaceID().id()];
150 }
151
153 // Cache the casted pointer to ISvcManager
155 return m_svcManager;
156 }
157
159 // Cache the casted pointer to IAlgManager
161 return m_algManager;
162 }
163
166
168 void outputLevelUpdate() override;
169
171
173 void printAlgsSequences();
174
175protected:
176 // implementation of IService::setServiceManager
177 void setServiceManager( ISvcManager* ) override {}
178
181
186 StatusCode GoToState( Gaudi::StateMachine::State state, bool ignoreFailures = false );
187
197
200
203
204 // data members
208
210 [this]( auto& ) {
211 // Re-initialize everything
212 this->reinitialize().ignore();
213 // Execute a number of events
214 this->executeRun( m_evtMax ).ignore();
215 },
216 "For SI's \"Go\" command via callback" };
218 [this]( auto& ) {
219 finalize().ignore();
220 terminate().ignore();
221 ::exit( 0 );
222 },
223 "For SI's \"Exit\" command via callback" };
225 "TopAlg",
226 {},
228 "List of top level algorithms names",
229 "vector<Algorithm>" };
231 this, "OutStream", {}, &ApplicationMgr::evtLoopPropertyHandler, "List of output stream names" };
232 Gaudi::Property<std::string> m_messageSvcType{ this, "MessageSvcType", "MessageSvc", "MessageSvc type",
233 "Service:IMessageSvc" };
234 Gaudi::Property<std::string> m_jobOptionsSvcType{ this, "JobOptionsSvcType", "JobOptionsSvc", "JobOptionsSvc type",
235 "Service:Gaudi::Interfaces::IOptionsSvc" };
236
237 std::string m_name = "ApplicationMgr";
240
241 Gaudi::Property<std::vector<std::string>> m_svcMapping{ this, "SvcMapping", {}, "Default mapping of services" };
243 this, "SvcOptMapping", {}, "Default mapping of optional services" };
244
248
250
252
253 //
254 // The public ApplicationMgr properties
255 //
256
257 Gaudi::Property<int> m_evtMax{ this, "EvtMax", -1, "Number of events to be processed (-1 means all events)" };
259 this, "ExtSvc", {}, "List of external services names", "vector<Service>" };
260 Gaudi::Property<bool> m_extSvcCreates{ this, "ExtSvcCreates", true,
261 "LHCb (default) or ATLAS definition of \"ExtSvc\"" };
262
263 Gaudi::Property<std::vector<std::string>> m_dllNameList{ this, "Dlls", {}, "List of DDL's names" };
264 Gaudi::Property<std::string> m_jobOptionsType{ this, "JobOptionsType", "FILE", "Source type (e.g. dbase, file...)" };
265 Gaudi::Property<std::string> m_jobOptionsPath{ this, "JobOptionsPath", {}, "The \"file\" to look for properties" };
267 this, "JobOptionsPostAction", {}, "additional command to run on config" };
269 this, "JobOptionsPreAction", {}, "additional command to run on config" };
270 Gaudi::Property<std::string> m_runableType{ this, "Runable", "AppMgrRunable", "Runable type", "Service:IRunable" };
271 Gaudi::Property<std::string> m_eventLoopMgr{ this, "EventLoop", "EventLoopMgr", "Processing manager type",
272 "Service:IEventProcessor" };
273 Gaudi::Property<std::string> m_evtsel{ this, "EvtSel", {}, "Event selection" };
274 Gaudi::Property<std::string> m_histPersName{ this, "HistogramPersistency", "NONE", "Name of the Hist Pers Svc" };
275 Gaudi::Property<int> m_outputLevel{ this, "OutputLevel", MSG::INFO, "Message output level" };
276 Gaudi::Property<std::string> m_appName{ this, "AppName", "ApplicationMgr", "The name of the application" };
277 Gaudi::Property<std::string> m_appVersion{ this, "AppVersion", {}, "The version of the application" };
278 Gaudi::Property<bool> m_actHistory{ this, "ActivateHistory", false, "Activate HistorySvc" };
279 Gaudi::Property<int> m_pluginDebugLevel{ this, "PluginDebugLevel", 0,
280 [this]( auto& ) {
281 // Setup debug level for the plugin system
282 if ( m_pluginDebugLevel.value() ) {
283 MsgStream log( m_messageSvc, this->name() );
284 log << MSG::INFO
285 << "Updating Gaudi::PluginService::SetDebug(level) to level="
287 }
288 Gaudi::PluginService::SetDebug( m_pluginDebugLevel );
289 },
290 "Debug level for the plugin system" };
291
293 this, "CreateSvc", {}, "List of extra services to be created" };
294
296 Gaudi::Property<bool> m_auditTools{ this, "AuditTools", false };
297 Gaudi::Property<bool> m_auditSvcs{ this, "AuditServices", false };
298 Gaudi::Property<bool> m_auditAlgs{ this, "AuditAlgorithms", false };
299
301 this, "Environment", {}, "Environment variables to set" };
302
303 Gaudi::Property<bool> m_loopCheck{ this, "InitializationLoopCheck", true,
304 [this]( auto& ) { this->svcManager()->setLoopCheckEnabled( m_loopCheck ); },
305 "For ServiceMgr initialization loop checking" };
306
310 this, "StopOnSignal", false, "Flag to enable/disable the signal handler that schedule a stop of the event loop" };
311
312 Gaudi::Property<bool> m_propertiesPrint{ this, "PropertiesPrint", false,
313 "Flag to activate the printout of properties" };
314
317 "Return code of the application. Set internally in case of error conditions." };
318
319 Gaudi::Property<bool> m_printAlgsSequence{ this, "PrintAlgsSequence", false,
320 "Print the sequence of algorithms that have been loaded." };
321
322 Gaudi::Property<bool> m_useMessageSvcForROOTMessages{ this, "UseMessageSvcForROOTMessages", true,
323 "Replace ROOT error handler with MessageSvc." };
324
325 Gaudi::Property<bool> m_enableROOTThreadSafety{ this, "EnableROOTThreadSafety", true,
326 "Enable ROOT thread safety at startup." };
327
328 // For concurrency
330
331private:
333
335 template <typename SELF, typename PIMPL, typename METHOD, typename... ARGS>
336 static auto i_delegateToEvtProc( SELF* self, PIMPL& member, std::string_view method_name, METHOD&& method,
337 ARGS&&... args ) {
338 if ( self->m_state == Gaudi::StateMachine::RUNNING ) {
339 if ( bool( member ) ) {
340 return std::invoke( method, *member.get(), std::forward<ARGS>( args )... );
341 } else {
342 std::stringstream s;
343 s << method_name << ": event processor is not a \""
344 << System::typeinfoName( typeid( decltype( *member.get() ) ) ) << '"';
345 throw GaudiException{ s.str(), self->name(), StatusCode::FAILURE };
346 }
347 }
348 std::stringstream s;
349 s << method_name << ": Invalid state \"" << self->FSMState() << '"';
350 throw GaudiException{ s.str(), self->name(), StatusCode::FAILURE };
351 }
352};
353
354using System::getEnv;
355using System::isEnvSet;
356
357#define ON_DEBUG if ( m_outputLevel <= MSG::DEBUG )
358#define ON_VERBOSE if ( m_outputLevel <= MSG::VERBOSE )
359
361
362namespace {
364 static IMessageSvc* s_messageSvcInstance{ nullptr };
366 static ErrorHandlerFunc_t s_originalRootErrorHandler{ nullptr };
367
369 void ROOTErrorHandlerAdapter( int level, Bool_t abort, const char* location, const char* msg ) {
370 if ( s_messageSvcInstance ) {
371 // we pass the message to MessageSvc only if it is not suppressed by ROOT itself
372 if ( level >= gErrorIgnoreLevel ) {
373 // # Map ROOT level to Gaudi level:
374 // ROOT levels go from 0 to 6000 in step of 1000,
375 // kInfo is 1000 while MSG::INFO is 3, so we aim for `level / 1000 + 2`,
376 // but we have to put a cap at MSG::FATAL.
377 int msgLevel = std::min<int>( level / 1000 + 2, MSG::FATAL );
378 if ( msgLevel >= s_messageSvcInstance->outputLevel( location ) ) {
379 s_messageSvcInstance->reportMessage( Message{ location, msgLevel, msg }, msgLevel );
380 }
381 }
382 } else {
383 // If a message is sent when we do not have an IMessageSvc, let's use something else
384 if ( s_originalRootErrorHandler ) {
385 // either the original handler (if any)
386 s_originalRootErrorHandler( level, abort, location, msg );
387 } else {
388 // or some minimalistic implementation from ROOT (just not to loose the message)
389 ROOT::Internal::MinimalErrorHandler( level, abort, location, msg );
390 }
391 }
392 }
393
394} // namespace
395
396// Implementation class for the Application Manager. In this way the
397// ApplicationMgr class is a fully insulated concrete class. Clients
398// (main programs) will not need to re-compile if there are changes
399// in the implementation
400
402 // IInterface initialization
403 addRef(); // Initial count set to 1
404
405 // Instantiate component managers
407
409
410 // Instantiate internal services
411 // SvcLocator/Factory HAS to be already instantiated
412 m_classManager = new DLLClassManager( this );
413
414 AlgorithmManager* algMgr = new AlgorithmManager( this );
416 // m_managers[IAlgorithm::interfaceID().id()] = new HiveAlgorithmManager(this);
417
418 // This property is not hosted in the ApplicationMgr instance
419 declareProperty( "AlgTypeAliases", algMgr->typeAliases(),
420 "Aliases of algorithm types, to replace an algorithm type for every instance" );
421
422 // ServiceMgr Initialization loop checking
424
425 m_svcMapping = { "EvtDataSvc/EventDataSvc",
426 "DetDataSvc/DetectorDataSvc",
427 "HistogramSvc/HistogramDataSvc",
428 "HbookCnv::PersSvc/HbookHistSvc",
429 "RootHistCnv::PersSvc/RootHistSvc",
430 "EvtPersistencySvc/EventPersistencySvc",
431 "DetPersistencySvc/DetectorPersistencySvc",
432 "HistogramPersistencySvc/HistogramPersistencySvc" };
433}
434
435void const* ApplicationMgr::i_cast( const InterfaceID& iid ) const {
436 // try our own interfaces
437 if ( auto output = base_class::i_cast( iid ) ) { return output; }
438 // delegate to other instances
439 if ( ISvcLocator::interfaceID().versionMatch( iid ) ) { return serviceLocator().get(); }
440 if ( ISvcManager::interfaceID().versionMatch( iid ) ) {
441 return const_cast<ApplicationMgr*>( this )->svcManager().get();
442 }
443 if ( IAlgManager::interfaceID().versionMatch( iid ) ) {
444 return const_cast<ApplicationMgr*>( this )->algManager().get();
445 }
446 if ( IClassManager::interfaceID().versionMatch( iid ) ) { return m_classManager.get(); }
447 if ( IMessageSvc::interfaceID().versionMatch( iid ) ) {
448 // Note that 0 can be a valid IMessageSvc pointer value (when used for
449 // MsgStream).
450 return m_messageSvc.get();
451 }
452 return nullptr;
453}
454
456
457 StatusCode sc;
458
459 // declare factories in current module
461
462 // Note: we cannot use CommonMessaging methods here because MessageSvc is not there yet
463 MsgStream log( nullptr, name() );
464
465 // Enable ROOT thread safety
467 if ( gROOT ) {
468 ROOT::EnableThreadSafety();
469 } else {
471 << "ROOT not yet initialized, we cannot enable thread safety "
472 "(EnableROOTThreadSafety==True)"
473 << endmsg;
474 }
475 }
476
477 // Create the Message service
478 auto msgsvc = svcManager()->createService( Gaudi::Utils::TypeNameString( "MessageSvc", m_messageSvcType ) );
479 if ( !msgsvc ) {
480 log << MSG::FATAL << "Error creating MessageSvc of type " << m_messageSvcType << endmsg;
481 return StatusCode::FAILURE;
482 }
483 // Get the useful interface from Message services
484 m_messageSvc = m_svcLocator->service( "MessageSvc" );
485 if ( !m_messageSvc ) {
486 log << MSG::FATAL << "Error retrieving MessageSvc." << endmsg;
487 return StatusCode::FAILURE;
488 }
489 sc = m_messageSvc.as<IProperty>()->setProperty( "OutputLevel", m_outputLevel );
490 if ( !sc ) {
491 log << MSG::FATAL << "Error setting OutputLevel option of MessageSvc" << endmsg;
492 return sc;
493 }
495 if ( gROOT ) {
496 // if ROOT is already initialized (usually it is the case) we redirect messages to MessageSvc.
497 s_messageSvcInstance = m_messageSvc.get();
498 s_originalRootErrorHandler = SetErrorHandler( ROOTErrorHandlerAdapter );
499 } else {
501 << "ROOT not yet initialized, we cannot override the error handler are requested "
502 "(UseMessageSvcForROOTMessages==true)"
503 << endmsg;
504 }
505 }
506
507 auto jobsvc = svcManager()->createService( Gaudi::Utils::TypeNameString( "JobOptionsSvc", m_jobOptionsSvcType ) );
508 // Create the Job Options service
509 if ( !jobsvc ) {
510 log << MSG::FATAL << "Error creating JobOptionsSvc" << endmsg;
511 return StatusCode::FAILURE;
512 }
513
514 auto jobOptsIProp = jobsvc.as<IProperty>();
515 if ( !jobOptsIProp ) {
516 log << MSG::FATAL << "Error locating JobOptionsSvc" << endmsg;
517 return StatusCode::FAILURE;
518 }
519 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "TYPE", m_jobOptionsType ) );
520 if ( !sc.isSuccess() ) {
521 log << MSG::FATAL << "Error setting TYPE option in JobOptionsSvc" << endmsg;
522 return sc;
523 }
524
525 if ( !m_jobOptionsPreAction.empty() ) {
526 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "PYTHONPARAMS", m_jobOptionsPreAction ) );
527 if ( !sc.isSuccess() ) {
528 log << MSG::FATAL << "Error setting JobOptionsPreAction option in JobOptionsSvc" << endmsg;
529 return sc;
530 }
531 }
532
533 if ( !m_jobOptionsPostAction.empty() ) {
534 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "PYTHONACTION", m_jobOptionsPostAction ) );
535 if ( !sc.isSuccess() ) {
536 log << MSG::FATAL << "Error setting JobOptionsPostAction option in JobOptionsSvc" << endmsg;
537 return sc;
538 }
539 }
540
541 if ( !m_jobOptionsPath.empty() ) { // The command line takes precedence
542 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "PATH", m_jobOptionsPath ) );
543 if ( !sc.isSuccess() ) {
544 log << MSG::FATAL << "Error setting PATH option in JobOptionsSvc" << endmsg;
545 return sc;
546 }
547 } else if ( isEnvSet( "JOBOPTPATH" ) ) { // Otherwise the Environment JOBOPTPATH
548 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "PATH", getEnv( "JOBOPTPATH" ) ) );
549 if ( !sc.isSuccess() ) {
550 log << MSG::FATAL << "Error setting PATH option in JobOptionsSvc from env" << endmsg;
551 return sc;
552 }
553 } else { // Otherwise the default
554 sc = jobOptsIProp->setProperty( Gaudi::Property<std::string>( "PATH", "../options/job.opts" ) );
555 if ( !sc.isSuccess() ) {
556 log << MSG::FATAL << "Error setting PATH option in JobOptionsSvc to default" << endmsg;
557 return sc;
558 }
559 }
560 jobOptsIProp.reset();
561
562 // Sets my default the Output Level of the Message service to be
563 // the same as this
564 auto msgSvcIProp = msgsvc.as<IProperty>();
565 msgSvcIProp->setProperty( Gaudi::Property<int>( "OutputLevel", m_outputLevel ) ).ignore();
566 msgSvcIProp.reset();
567
568 sc = jobsvc->sysInitialize();
569 if ( !sc.isSuccess() ) {
570 log << MSG::FATAL << "Error initializing JobOptionsSvc" << endmsg;
571 return sc;
572 }
573 sc = msgsvc->sysInitialize();
574 if ( !sc.isSuccess() ) {
575 log << MSG::FATAL << "Error initializing MessageSvc" << endmsg;
576 return sc;
577 }
578
579 // Make sure output level caches are up to date.
581
582 return sc;
583}
584
586
587 // Check if the state is compatible with the transition
588 MsgStream tlog( m_messageSvc, name() );
590 tlog << MSG::INFO << "Already Configured" << endmsg;
591 return StatusCode::SUCCESS;
592 }
594 tlog << MSG::FATAL << "configure: Invalid state \"" << m_state << "\"" << endmsg;
595 return StatusCode::FAILURE;
596 }
598
599 // Reset application return code.
601
602 StatusCode sc;
603 sc = i_startup();
604 if ( !sc.isSuccess() ) { return sc; }
605
606 {
608 // Get my own options using the Job options service
609 if ( log.level() <= MSG::DEBUG ) log << MSG::DEBUG << "Getting my own properties" << endmsg;
610 bindPropertiesTo( serviceLocator()->getOptsSvc() );
611 }
612
613 // Make sure that the OutputLevel is in sync
616
617 // Check current outputLevel to eventually inform the MessageSvc
618 if ( m_outputLevel != MSG::NIL && !m_appName.empty() ) {
619 // Print a welcome message
621 << "=================================================================="
622 << "==================================================================" << std::endl
623 << " "
624 << " Welcome to " << m_appName.value();
625
626 if ( !m_appVersion.empty() ) {
627 log << MSG::ALWAYS << " version " << m_appVersion.value();
628 } else {
629 log << MSG::ALWAYS << " (GaudiCoreSvc "
630 << "v" << GAUDI_MAJOR_VERSION << "r" << GAUDI_MINOR_VERSION
631#if GAUDI_PATCH_VERSION
632 << "p" << GAUDI_PATCH_VERSION
633#endif
634 << ")";
635 }
636
637 // Add the host name and current time to the message
639 << " "
640 << " running on " << System::hostName() << " on " << Gaudi::Time::current().format( true ) << std::endl
641 << "=================================================================="
642 << "==================================================================" << endmsg;
643 }
644
645 // print all own properties if the options "PropertiesPrint" is set to true
646 if ( m_propertiesPrint ) {
647 const auto& properties = getProperties();
648 log << MSG::ALWAYS << "List of ALL properties of " << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
649 << " #properties = " << properties.size() << endmsg;
650 for ( const auto& property : properties ) { log << "Property ['Name': Value] = " << *property << endmsg; }
651 }
652
653 // set the requested environment variables
654 for ( auto& var : m_environment ) {
655 const std::string& name = var.first;
656 const std::string& value = var.second;
657 std::string old = System::getEnv( name.c_str() );
658 const MSG::Level lvl = ( !old.empty() && ( old != "UNKNOWN" ) ) ? MSG::WARNING : MSG::DEBUG;
659 if ( m_outputLevel <= lvl ) log << lvl << "Setting " << name << " = " << value << endmsg;
660 System::setEnv( name, value );
661 }
662
663 // Declare Service Types
664 for ( auto& j : m_svcMapping ) {
666 if ( svcManager()->declareSvcType( itm.name(), itm.type() ).isFailure() ) {
667 log << MSG::ERROR << "configure: declaring svc type:'" << j << "' failed." << endmsg;
668 return StatusCode::FAILURE;
669 } else {
671 log << MSG::VERBOSE << "declared service " << j << endmsg;
672 }
673 }
674 for ( auto& j : m_svcOptMapping ) {
676 if ( svcManager()->declareSvcType( itm.name(), itm.type() ).isFailure() ) {
677 log << MSG::ERROR << "declaring svc type:'" << j << "' failed." << endmsg;
678 return StatusCode::FAILURE;
679 }
680 }
681
682 //--------------------------------------------------------------------------
683 // Declare other Services and Algorithms by loading DLL's
684 sc = decodeDllNameList();
685 if ( sc.isFailure() ) {
686 log << MSG::ERROR << "Failure loading declared DLL's" << endmsg;
687 return sc;
688 }
689
690 //--------------------------------------------------------------------------
691 // Deal with the services explicitly declared by the user.
693 if ( sc.isFailure() ) {
694 log << MSG::ERROR << "Failure during external service association" << endmsg;
695 return sc;
696 }
697
699 if ( sc.isFailure() ) {
700 log << MSG::ERROR << "Failure during external service creation" << endmsg;
701 return sc;
702 }
703
704 //--------------------------------------------------------------------------
705 // Retrieve intrinsic services. If needed configure them.
706 //--------------------------------------------------------------------------
707 const Gaudi::Utils::TypeNameString evtloop_item( m_eventLoopMgr );
708 sc = svcManager()->addService( evtloop_item, ServiceManager::DEFAULT_SVC_PRIORITY * 10 );
709 if ( !sc.isSuccess() ) {
710 log << MSG::FATAL << "Error adding :" << m_eventLoopMgr << endmsg;
711 return sc;
712 } else {
714 log << MSG::VERBOSE << "added service " << evtloop_item << endmsg;
715 }
716
718 if ( !m_runable ) {
719 log << MSG::FATAL << "Error retrieving Runable: " << m_runableType.value() << "\n Check option ApplicationMgr."
720 << m_runableType.name() << endmsg;
721 return sc;
722 }
723 m_processingMgr = m_svcLocator->service( evtloop_item );
724 if ( !m_processingMgr ) {
725 log << MSG::FATAL << "Error retrieving Processing manager: " << m_eventLoopMgr.value()
726 << "\n Check option ApplicationMgr." << m_eventLoopMgr.name() << "\n No events will be processed." << endmsg;
727 return sc;
728 }
729 // The IEventProcessor might also be an IQueueingEventProcessor
731
732 // Establish Update Handlers for ExtSvc and DLLs Properties
736
737 if ( m_actHistory ) {
738 // Create HistorySvc with a priority to ensure it's initialized last, finalized first
739 sc = svcManager()->addService( "HistorySvc", std::numeric_limits<int>::max() );
740 if ( sc.isFailure() ) {
741 log << MSG::FATAL << "Error adding HistorySvc" << endmsg;
742 return StatusCode::FAILURE;
743 }
744 }
745
746 log << MSG::INFO << "Application Manager Configured successfully" << endmsg;
748 return StatusCode::SUCCESS;
749}
750
752 StatusCode sc;
753
755
756 // Make sure output level caches are up to date.
758
759 // I cannot add these services in configure() because they are coming from GaudiUtils
760 // and it messes up genconf when rebuilding it.
761 if ( m_stopOnSignal ) {
762 // Instantiate the service that schedules a stop when a signal is received
763 std::string svcname( "Gaudi::Utils::StopSignalHandler" );
764 sc = svcManager()->addService( svcname );
765 if ( sc.isFailure() ) {
766 log << MSG::INFO << "Cannot instantiate " << svcname << "signals will be ignored" << endmsg;
767 }
768 }
769
771 log << MSG::INFO << "Already Initialized!" << endmsg;
772 return StatusCode::SUCCESS;
773 }
775 log << MSG::FATAL << "initialize: Invalid state \"" << m_state << "\"" << endmsg;
776 return StatusCode::FAILURE;
777 }
779
780 //--------------------------------------------------------------------------
781 // Initialize the list of top Services
782 //--------------------------------------------------------------------------
783 sc = svcManager()->initialize();
784 if ( !sc.isSuccess() ) return sc;
785
786 sc = algManager()->initialize();
787 if ( !sc.isSuccess() ) return sc;
788
789 //--------------------------------------------------------------------------
790 // Final steps: Inform user and change internal state
791 //--------------------------------------------------------------------------
792 log << MSG::INFO << "Application Manager Initialized successfully" << endmsg;
794
796
797 return sc;
798}
799
801
803
805 log << MSG::INFO << "Already Initialized!" << endmsg;
806 return StatusCode::SUCCESS;
807 }
809 log << MSG::FATAL << "start: Invalid state \"" << m_state << "\"" << endmsg;
810 return StatusCode::FAILURE;
811 }
813
814 //--------------------------------------------------------------------------
815 // Initialize the list of top Services
816 //--------------------------------------------------------------------------
817 return m_svcLocator->service( "JobOptionsSvc" )
818 ->sysStart()
819 .andThen( [&]() { return m_messageSvc.as<IService>()->sysStart(); } )
820 .andThen( [&]() { return svcManager()->start(); } )
821 .andThen( [&]() { return algManager()->start(); } )
822 .andThen( [&]() {
823 //--------------------------------------------------------------------------
824 // Final steps: Inform user and change internal state
825 //--------------------------------------------------------------------------
826 log << MSG::INFO << "Application Manager Started successfully" << endmsg;
828 } );
829}
830
834 log << MSG::FATAL << "nextEvent: Invalid state \"" << m_state << "\"" << endmsg;
835 return StatusCode::FAILURE;
836 }
837 if ( !m_processingMgr ) {
839 log << MSG::FATAL << "No event processing manager specified. Check option: " << m_eventLoopMgr.name() << endmsg;
840 return StatusCode::FAILURE;
841 }
842 return m_processingMgr->nextEvent( maxevt );
843}
844
846
848
850 log << MSG::INFO << "Already Initialized!" << endmsg;
851 return StatusCode::SUCCESS;
852 }
854 log << MSG::FATAL << "stop: Invalid state \"" << m_state << "\"" << endmsg;
855 return StatusCode::FAILURE;
856 }
858
859 // Stop independently managed Algorithms
860 return algManager()
861 ->stop()
862 //--------------------------------------------------------------------------
863 // Stop the list of top Services
864 //--------------------------------------------------------------------------
865 .andThen( [&]() { return svcManager()->stop(); } )
866 .andThen( [&]() { return m_messageSvc.as<IService>()->sysStop(); } )
867 .andThen( [&]() { return m_svcLocator->service( "JobOptionsSvc" )->sysStop(); } )
868 //--------------------------------------------------------------------------
869 // Final steps: Inform user and change internal state
870 //--------------------------------------------------------------------------
871 .andThen( [&]() {
872 log << MSG::INFO << "Application Manager Stopped successfully" << endmsg;
874 } );
875}
876
877//============================================================================
878// IAppMgrUI implementation: ApplicationMgr::finalize()
879//============================================================================
883 log << MSG::INFO << "Already Finalized" << endmsg;
884 return StatusCode::SUCCESS;
885 }
887 log << MSG::FATAL << "finalize: Invalid state \"" << m_state << "\"" << endmsg;
888 return StatusCode::FAILURE;
889 }
891
892 // disable message suppression in finalize
893 m_svcLocator->service<IProperty>( "MessageSvc" )
894 ->setProperty( Gaudi::Property<bool>( "enableSuppression", false ) )
895 .ignore();
896
897 // Finalize independently managed Algorithms
899 if ( sc.isFailure() ) {
900 log << MSG::WARNING << "Failed to finalize an algorithm." << endmsg;
902 }
903
904 // Finalize all Services
905 sc = svcManager()->finalize();
906 if ( sc.isFailure() ) {
907 log << MSG::WARNING << "Failed to finalize a service." << endmsg;
909 }
910
911 // svcManager()->removeService( (IService*) m_processingMgr.get() );
912 // svcManager()->removeService( (IService*) m_runable.get() );
913
914 if ( sc.isSuccess() ) {
915 log << MSG::INFO << "Application Manager Finalized successfully" << endmsg;
916 } else {
917 log << MSG::ERROR << "Application Manager failed to finalize" << endmsg;
918 }
919
921 return sc;
922}
923
926
928 log << MSG::INFO << "Already Offline" << endmsg;
929 return StatusCode::SUCCESS;
930 }
932 log << MSG::FATAL << "terminate: Invalid state \"" << m_state << "\"" << endmsg;
933 return StatusCode::FAILURE;
934 }
935 // release all Services
937
939 log << MSG::INFO << "Application Manager Terminated successfully" << endmsg;
941 log << MSG::INFO << "Application Manager Terminated successfully with a user requested ScheduledStop" << endmsg;
942 } else {
943 log << MSG::ERROR << "Application Manager Terminated with error code " << m_returnCode.value() << endmsg;
944 }
945
946 {
947 auto& opts = m_svcLocator->getOptsSvc();
948 // Force a disable the auditing of finalize for MessageSvc
949 opts.set( "MessageSvc.AuditFinalize", "false" );
950 // Force a disable the auditing of finalize for JobOptionsSvc
951 opts.set( "JobOptionsSvc.AuditFinalize", "false" );
952 }
953
954 // if we have overriden it, restore the original ROOT error handler
955 if ( s_originalRootErrorHandler ) {
956 SetErrorHandler( s_originalRootErrorHandler );
957 s_originalRootErrorHandler = nullptr;
958 }
959 // make sure ROOTErrorHandlerAdapter (if in use) does not try to use the MessageSvc we are about to delete
960 s_messageSvcInstance = nullptr;
961 // finalize MessageSvc
962 auto svc = m_messageSvc.as<IService>();
963 if ( !svc ) {
964 log << MSG::ERROR << "Could not get the IService interface of the MessageSvc" << endmsg;
965 } else {
966 svc->sysFinalize().ignore();
967 svcManager()->removeService( svc ).ignore();
968 }
969
970 // finalize JobOptionsSvc
971 svc = m_svcLocator->service( "JobOptionsSvc" );
972 if ( !svc ) {
973 log << MSG::ERROR << "Could not get the IService interface of the JobOptionsSvc" << endmsg;
974 } else {
975 svc->sysFinalize().ignore();
976 svcManager()->removeService( svc ).ignore();
977 }
978
980 return StatusCode::SUCCESS;
981}
982
985
986 switch ( state ) {
987
989 switch ( m_state ) {
991 return StatusCode::SUCCESS;
992 break;
994 return terminate();
995 break;
996 default: // Gaudi::StateMachine::INITIALIZED or Gaudi::StateMachine::RUNNING
998 if ( sc.isSuccess() ) { return terminate(); }
999 break;
1000 }
1001 break;
1002
1004 switch ( m_state ) {
1006 return StatusCode::SUCCESS;
1007 break;
1009 return configure();
1010 break;
1012 return finalize();
1013 break;
1014 default: // Gaudi::StateMachine::RUNNING
1016 if ( sc.isSuccess() ) { return finalize(); }
1017 break;
1018 }
1019 break;
1020
1022 switch ( m_state ) {
1024 return StatusCode::SUCCESS;
1025 break;
1027 return initialize();
1028 break;
1030 return stop();
1031 break;
1032 default: // Gaudi::StateMachine::OFFLINE
1034 if ( sc.isSuccess() ) { return initialize(); }
1035 break;
1036 }
1037 break;
1038
1040 switch ( m_state ) {
1042 return StatusCode::SUCCESS;
1043 break;
1045 return start();
1046 break;
1047 default: // Gaudi::StateMachine::OFFLINE or Gaudi::StateMachine::CONFIGURED
1049 if ( sc.isSuccess() ) { return start(); }
1050 break;
1051 }
1052 break;
1053 }
1054
1055 // If I get here, there has been a problem in the recursion
1056
1057 if ( ignoreFailures ) {
1058 // force the new state
1059 m_state = state;
1060 return StatusCode::SUCCESS;
1061 }
1062
1063 return sc;
1064}
1065
1068
1070 if ( sc.isSuccess() ) {
1072 if ( m_runable != 0 ) { // loop over the events
1073 sc = m_runable->run();
1074 if ( !sc.isSuccess() ) { log << MSG::FATAL << "Application execution failed. Ending the job." << endmsg; }
1075 } else {
1076 log << MSG::FATAL << "Application has no runable object. Check option:" << m_runableType.name() << endmsg;
1077 }
1078 }
1079 if ( sc.isSuccess() ) { // try to close cleanly
1081 }
1082 // either the runable failed of the stut-down
1083 if ( sc.isFailure() ) { // try to close anyway (but keep the StatusCode unchanged)
1085 }
1086 return sc;
1087}
1088
1091 if ( m_processingMgr ) { return m_processingMgr->executeEvent( std::move( ctx ) ); }
1092 }
1094 log << MSG::FATAL << "executeEvent: Invalid state \"" << FSMState() << "\"" << endmsg;
1095 return StatusCode::FAILURE;
1096}
1097
1102
1106
1107std::optional<Gaudi::Interfaces::IQueueingEventProcessor::ResultType> ApplicationMgr::pop() {
1109}
1110
1114 }
1115 std::stringstream ss;
1116 ss << "createEventContext: Invalid state \"" << FSMState() << '"';
1117 throw GaudiException( ss.str(), name(), StatusCode::FAILURE );
1118}
1119
1123 if ( m_processingMgr ) { return m_processingMgr->executeRun( evtmax ); }
1124 log << MSG::WARNING << "No EventLoop Manager specified " << endmsg;
1125 return StatusCode::SUCCESS;
1126 }
1127 log << MSG::FATAL << "executeRun: Invalid state \"" << FSMState() << "\"" << endmsg;
1128 return StatusCode::FAILURE;
1129}
1130
1134 if ( m_processingMgr ) { return m_processingMgr->stopRun(); }
1135 log << MSG::WARNING << "No EventLoop Manager specified " << endmsg;
1136 return StatusCode::SUCCESS;
1137 }
1138 log << MSG::FATAL << "stopRun: Invalid state \"" << FSMState() << "\"" << endmsg;
1139 return StatusCode::FAILURE;
1140}
1141const std::string& ApplicationMgr::name() const { return m_name; }
1142
1145
1149 StatusCode sc;
1151 throw GaudiException( "Cannot reinitialize application if not INITIALIZED or RUNNING",
1152 "ApplicationMgr::reinitialize", StatusCode::FAILURE );
1153 }
1155 sc = svcManager()->reinitialize();
1156 if ( sc.isFailure() ) retval = sc;
1157 sc = algManager()->reinitialize();
1158 if ( sc.isFailure() ) retval = sc;
1159
1161 if ( sc.isFailure() ) retval = sc;
1162 sc = m_svcLocator->service( "JobOptionsSvc" )->sysReinitialize();
1163 if ( sc.isFailure() ) retval = sc;
1164
1165 log << MSG::INFO << "Application Manager Reinitialized successfully" << endmsg;
1166
1167 return retval;
1168}
1169
1172 StatusCode sc;
1174 throw GaudiException( "Cannot restart application if not RUNNING", "ApplicationMgr::restart", StatusCode::FAILURE );
1175 }
1176
1177 sc = svcManager()->restart();
1178 if ( sc.isFailure() ) retval = sc;
1179 sc = algManager()->restart();
1180 if ( sc.isFailure() ) retval = sc;
1181
1183 if ( sc.isFailure() ) retval = sc;
1184 sc = m_svcLocator->service( "JobOptionsSvc" )->sysRestart();
1185 if ( sc.isFailure() ) retval = sc;
1186
1187 return retval;
1188}
1189
1191 if ( m_processingMgr ) {
1192 auto props = m_processingMgr.as<IProperty>();
1193 if ( props ) props->setProperty( p ).ignore();
1194 }
1195}
1196
1198 if ( !( decodeCreateSvcNameList() ).isSuccess() ) {
1199 throw GaudiException( "Failed to create ext services", "MinimalEventLoopMgr::createSvcNameListHandler",
1201 }
1202}
1205 const auto& theNames = m_createSvcNameList.value();
1206 auto it = theNames.begin();
1207 auto et = theNames.end();
1208 while ( result.isSuccess() && it != et ) {
1209 Gaudi::Utils::TypeNameString item( *it++ );
1210 if ( ( result = svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
1212 log << MSG::ERROR << "decodeCreateSvcNameList: Cannot create service " << item.type() << "/" << item.name()
1213 << endmsg;
1214 } else {
1215 ON_DEBUG {
1217 log << MSG::DEBUG << "decodeCreateSvcNameList: Created service " << item.type() << "/" << item.name() << endmsg;
1218 }
1219 }
1220 }
1221 return result;
1222}
1223
1225 if ( !( decodeExtSvcNameList() ).isSuccess() ) {
1226 throw GaudiException( "Failed to declare ext services", "MinimalEventLoopMgr::extSvcNameListHandler",
1228 }
1229}
1230
1233
1234 const auto& theNames = m_extSvcNameList.value();
1235
1236 auto it = theNames.begin();
1237 auto et = theNames.end();
1238 while ( result.isSuccess() && it != et ) {
1239 Gaudi::Utils::TypeNameString item( *it++ );
1240 if ( m_extSvcCreates ) {
1241 if ( ( result = svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
1243 log << MSG::ERROR << "decodeExtSvcNameList: Cannot create service " << item.type() << "/" << item.name()
1244 << endmsg;
1245 }
1246 } else {
1247 if ( ( result = svcManager()->declareSvcType( item.name(), item.type() ) ).isFailure() ) {
1249 log << MSG::ERROR << "decodeExtSvcNameList: Cannot declare service " << item.type() << "/" << item.name()
1250 << endmsg;
1251 }
1252 }
1253 }
1254 return result;
1255}
1256
1258 if ( !( decodeDllNameList() ).isSuccess() ) {
1259 throw GaudiException( "Failed to load DLLs.", "MinimalEventLoopMgr::dllNameListHandler", StatusCode::FAILURE );
1260 }
1261}
1262
1264
1267
1268 // Clean up multiple entries from DLL list
1270 std::map<std::string, unsigned int> dllInList, duplicateList;
1271 {
1272 for ( const auto& it : m_dllNameList ) {
1273 if ( 0 == dllInList[it] ) {
1274 newList.push_back( it ); // first instance of this module
1275 } else {
1276 ++duplicateList[it];
1277 } // module listed multiple times
1278 ++dllInList[it]; // increment count for this module
1279 }
1280 }
1281 // m_dllNameList = newList; // update primary list to new, filtered list (do not use the
1282 // property itself otherwise we get called again infinitely)
1283 // List modules that were in there twice..
1284 ON_DEBUG if ( !duplicateList.empty() ) {
1285 log << MSG::DEBUG << "Removed duplicate entries for modules : ";
1286 for ( auto it = duplicateList.begin(); it != duplicateList.end(); ++it ) {
1287 log << it->first << "(" << 1 + it->second << ")";
1288 if ( it != --duplicateList.end() ) log << ", ";
1289 }
1290 log << endmsg;
1291 }
1292
1293 const std::vector<std::string>& theNames = newList;
1294
1295 // only load the new dlls or previously failed dlls
1296 ON_DEBUG log << MSG::DEBUG << "Loading declared DLL's" << endmsg;
1297
1298 std::vector<std::string> successNames, failNames;
1299 for ( const auto& it : theNames ) {
1300 if ( std::find( m_okDlls.rbegin(), m_okDlls.rend(), it ) == m_okDlls.rend() ) {
1301 // found a new module name
1302 StatusCode status = m_classManager->loadModule( it );
1303 if ( status.isFailure() ) {
1304 failNames.push_back( it );
1305 result = StatusCode::FAILURE;
1306 } else {
1307 successNames.push_back( it );
1308 }
1309 }
1310 }
1311
1312 // report back to the user and store the names of the succesfully loaded dlls
1313 if ( !successNames.empty() ) {
1314 log << MSG::INFO << "Successfully loaded modules : ";
1315 for ( auto it = successNames.begin(); it != successNames.end(); it++ ) {
1316 log << ( *it );
1317 if ( ( it + 1 ) != successNames.end() ) log << ", ";
1318 // save name
1319 m_okDlls.push_back( *it );
1320 }
1321 log << endmsg;
1322 }
1323
1324 if ( result == StatusCode::FAILURE ) {
1325 log << MSG::WARNING << "Failed to load modules: ";
1326 for ( auto it = failNames.begin(); it != failNames.end(); it++ ) {
1327 log << ( *it );
1328 if ( ( it + 1 ) != failNames.end() ) log << ", ";
1329 }
1330 log << endmsg;
1331 }
1332 return result;
1333}
1334
1337 for ( auto& mgrItem : m_managers ) { mgrItem.second->outputLevelUpdate(); }
1338}
1339
1340namespace {
1342 void printAlgsSequencesHelper( SmartIF<IAlgManager>& algmgr, const std::string& algname, MsgStream& log,
1343 int indent ) {
1345 log << MSG::ALWAYS;
1346 for ( int i = 0; i < indent; ++i ) log << " ";
1347 log << algname << endmsg;
1348 auto prop = algmgr->algorithm<IProperty>( algname, false );
1349 if ( prop ) {
1350 // Try to get the property Members
1351 Gaudi::Property<std::vector<std::string>> p( "Members", {} );
1352 if ( prop->getProperty( &p ).isSuccess() ) {
1353 for ( auto& subalgname : p.value() ) { printAlgsSequencesHelper( algmgr, subalgname, log, indent + 1 ); }
1354 }
1355 } else {
1356 log << MSG::WARNING << "Cannot get properties of " << algname << endmsg;
1357 }
1358 }
1359} // namespace
1360
1363 log << MSG::ALWAYS << "****************************** Algorithm Sequence ****************************" << endmsg;
1364 for ( auto& algname : m_topAlgNameList ) { printAlgsSequencesHelper( algManager(), algname, log, 0 ); }
1365 log << MSG::ALWAYS << "******************************************************************************" << endmsg;
1366}
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition System.cpp:334
#define ON_VERBOSE
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition System.cpp:314
#define ON_DEBUG
Version of Gaudi, to be used as.
#define GAUDI_MAJOR_VERSION
Major version of Gaudi (the 41 of v41r0).
#define GAUDI_MINOR_VERSION
Minor version of Gaudi (the 0 of v41r0).
#define GAUDI_PATCH_VERSION
Patch version of Gaudi (the 0 of v41r0p0), 0 if the version has no patch number.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_OBJECT_FACTORY(x)
complex< _Tp > log(const complex< _Tp > &)
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &&__t) noexcept
constexpr _OI move(_II __first, _II __last, _OI __result)
constexpr _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp &__val)
constexpr const _Tp & min(const _Tp &__a, const _Tp &__b)
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
__string_type str() const
static constexpr _Tp max() noexcept
bool empty() const noexcept
bool empty() const noexcept
const_iterator end() const noexcept
const_iterator begin() const noexcept
constexpr void push_back(const value_type &__x)
constexpr const_reverse_iterator rend() const noexcept
constexpr const_iterator begin() const noexcept
constexpr bool empty() const noexcept
constexpr const_reverse_iterator rbegin() const noexcept
constexpr const_iterator end() const noexcept
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
AlgorithmManager(IInterface *iface)
default creator
AlgTypeAliasesMap & typeAliases()
The Application Manager class.
SmartIF< ISvcManager > m_svcManager
Cached pointer to the manager of services.
std::map< unsigned long, SmartIF< IComponentManager > > ManagersMap
Using for the map of component managers, the key is the "id" field of the basic InterfaceID of the ma...
Gaudi::Property< std::string > m_jobOptionsType
std::string m_name
Name.
SmartIF< IRunable > m_runable
Reference to the runable object.
Gaudi::Property< bool > m_printAlgsSequence
SmartIF< IQueueingEventProcessor > m_queueingProcessor
Reference to a queueing processing manager object.
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
SmartIF< IComponentManager > & getManager()
Gaudi::Property< std::vector< std::string > > m_svcMapping
Gaudi::Property< bool > m_useMessageSvcForROOTMessages
std::optional< Gaudi::Interfaces::IQueueingEventProcessor::ResultType > pop() override
Gaudi::Property< std::vector< std::string > > m_dllNameList
Gaudi::StateMachine::State m_targetState
Internal State.
Gaudi::Property< std::string > m_runableType
Gaudi::Property< bool > m_actHistory
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
std::vector< std::string > m_okDlls
names of successfully loaded dlls
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
Gaudi::Property< bool > m_propertiesPrint
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator (must be instantiated prior to any service!).
StatusCode run() override
ApplicationMgr(IInterface *=nullptr)
StatusCode finalize() override
Gaudi::Property< std::vector< std::string > > m_outStreamNameList
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
StatusCode nextEvent(int maxevt) override
Gaudi::Property< std::string > m_jobOptionsPath
Gaudi::Property< std::vector< std::string > > m_declaredManagers
Property to declare the list of known managers.
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
StatusCode terminate() override
StatusCode initialize() override
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Gaudi::Property< int > m_SIExit
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
StatusCode sysStop() override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
Gaudi::Property< std::vector< std::string > > m_svcOptMapping
Gaudi::Property< bool > m_enableROOTThreadSafety
SmartIF< IAlgManager > & algManager()
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void*)
void const * i_cast(const InterfaceID &iid) const override
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< bool > m_auditTools
Defaults for auditors.
Gaudi::Monitoring::Hub m_monitoringHub
SmartIF< IAlgManager > m_algManager
Cached pointer to the manager of algorithms.
Gaudi::Property< std::string > m_evtsel
Gaudi::Property< std::string > m_eventLoopMgr
const std::string & name() const override
Gaudi::Property< int > m_evtMax
StatusCode sysRestart() override
Gaudi::Property< std::string > m_appVersion
StatusCode sysReinitialize() override
StatusCode decodeDllNameList()
Gaudi::Property< std::vector< std::string > > m_topAlgNameList
Gaudi::Property< bool > m_extSvcCreates
Gaudi::Property< std::vector< std::string > > m_createSvcNameList
Gaudi::Property< bool > m_auditSvcs
Gaudi::Property< std::map< std::string, std::string > > m_environment
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
Gaudi::Property< std::string > m_jobOptionsPreAction
StatusCode reinitialize() override
Gaudi::Property< bool > m_loopCheck
Gaudi::Property< std::string > m_appName
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::StateMachine::State targetFSMState() const override
Gaudi::Property< int > m_pluginDebugLevel
StatusCode restart() override
StatusCode stop() override
void printAlgsSequences()
Print the sequence of algorithms that have been loaded.
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
static auto i_delegateToEvtProc(SELF *self, PIMPL &member, std::string_view method_name, METHOD &&method, ARGS &&... args)
Helper to delegate calls to event processor implementation.
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
Gaudi::StateMachine::State FSMState() const override
StatusCode i_startup()
Internal startup routine.
StatusCode sysFinalize() override
Gaudi::StateMachine::State m_state
Internal State.
Gaudi::Property< std::string > m_histPersName
StatusCode start() override
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
StatusCode decodeExtSvcNameList()
Gaudi::Property< std::string > m_jobOptionsSvcType
Gaudi::Monitoring::Hub & monitoringHub() override
void push(EventContext &&ctx) override
void setServiceManager(ISvcManager *) override
StatusCode decodeCreateSvcNameList()
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< bool > m_auditAlgs
Gaudi::Property< int > m_outputLevel
ManagersMap m_managers
Map of known component managers.
bool empty() const override
StatusCode configure() override
StatusCode sysStart() override
StatusCode sysInitialize() override
Gaudi::Property< int > m_SIGo
void pluginDebugPropertyHandler(Gaudi::Details::PropertyBase &theProp)
SmartIF< ISvcManager > & svcManager()
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
Gaudi::Property< std::string > m_jobOptionsPostAction
Gaudi::Property< std::string > m_messageSvcType
StatusCode loadModule(const std::string &module, bool fireIncident=true) override
DLLClassManager(IInterface *iface)
This class represents an entry point to all the event specific data.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
const std::string name() const
property name
Implementation of property with value of concrete type.
Definition Property.h:35
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition Property.h:135
const ValueType & value() const
Definition Property.h:246
auto empty() const
Definition Property.h:272
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
Definition Time.cpp:155
static Time current()
Returns the current time.
Definition Time.cpp:41
Helper class to parse a string of format "type/name".
const std::string & type() const
const std::string & name() const
Define general base for Gaudi exception.
GaudiException(std::string Message, std::string Tag, StatusCode Code)
Constructor (1).
virtual EventContext createEventContext()=0
virtual StatusCode executeRun(int maxevt)=0
Process the maxevt events as a Run.
virtual StatusCode stopRun()=0
Schedule a stop of the current event processing.
virtual StatusCode nextEvent(int maxevt)=0
Process the next maxevt events.
virtual StatusCode executeEvent(EventContext &&ctx)=0
Process single event.
Definition of the basic interface.
Definition IInterface.h:225
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition IInterface.h:234
The IMessage is the interface implemented by the message service.
Definition IMessageSvc.h:34
virtual void reportMessage(const Message &msg, int outputLevel)=0
Report a message by sending a Message object to the message service.
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
virtual int outputLevel() const =0
Retrieve the current output level threshold.
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition IProperty.h:32
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition IProperty.h:38
virtual StatusCode run()=0
Run the class implementation.
General service interface definition.
Definition IService.h:26
virtual StatusCode sysStart()=0
Start Service.
virtual StatusCode sysRestart()=0
Re-start the Service.
virtual StatusCode sysStop()=0
Stop Service.
virtual StatusCode sysReinitialize()=0
Re-initialize the Service.
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Gaudi::Interfaces::IOptionsSvc & getOptsSvc()
Direct access to Gaudi::Interfaces::IOptionsSvc implementation.
The ISvcManager is the interface implemented by the Service Factory in the Application Manager to sup...
Definition ISvcManager.h:30
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.
virtual void setLoopCheckEnabled(bool en=true)=0
Set the value of the initialization loop check flag.
virtual SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype)=0
Creates and instance of a service type that has been declared beforehand and assigns it a name.
virtual StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
Interface ID class.
Definition IInterface.h:38
constexpr unsigned long id() const
get the interface identifier
Definition IInterface.h:47
The Message class.
Definition Message.h:25
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29
ServiceManager(IInterface *application)
default creator
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
TYPE * get() const
Get interface pointer.
Definition SmartIF.h:82
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition SmartIF.h:110
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:118
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:151
void ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:128
bool isSuccess() const
Definition StatusCode.h:302
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
constexpr int ScheduledStop
constexpr int FinalizationFailure
Error codes for operation failures.
constexpr int Success
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
@ NIL
Definition IMessageSvc.h:22
@ WARNING
Definition IMessageSvc.h:22
@ FATAL
Definition IMessageSvc.h:22
@ DEBUG
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22
@ ALWAYS
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22
@ VERBOSE
Definition IMessageSvc.h:22
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition System.cpp:334
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:254
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition System.cpp:341
GAUDI_API const std::string & hostName()
Host name.
Definition System.cpp:259
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition System.cpp:314
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
Definition System.cpp:425
virtual std::optional< ResultType > pop()=0
Get the next available result.
virtual bool empty() const =0
Tell if the processor has events in the queues.
virtual void push(EventContext &&ctx)=0
Schedule the processing of an event.
Central entity in a Gaudi application that manages monitoring objects (i.e.