Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
31 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
32 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
34 #define DEBMSG ON_DEBUG debug()
35 #define VERMSG ON_VERBOSE verbose()
45 v.reserve( lst.size() );
46 for (
auto& i : lst ) {
47 if ( i.active )
v.push_back( i.service.get() );
64 for (
auto& svc :
m_listsvc ) svc.service->setServiceManager(
nullptr );
89 auto ip =
type.find(
"__" );
90 if ( ip != std::string::npos )
type.erase( ip,
type.length() );
94 fatal() <<
"No Service factory for " <<
type <<
" available." <<
endmsg;
99 fatal() <<
"Incompatible interface IService version for " <<
type <<
endmsg;
103 if (
name ==
"JobOptionsSvc" ) {
105 fatal() <<
typeName <<
" does not implement Gaudi::Interfaces::IOptionsSvc" <<
endmsg;
111 service->setServiceManager(
this );
121 auto it =
find( svc );
122 auto lck = std::scoped_lock{
m_gLock };
147 sc = svc->sysInitialize();
151 error() <<
"Unable to initialize service \"" <<
typeName.name() <<
"\"" <<
endmsg;
152 auto lck = std::scoped_lock{
m_gLock };
161 auto lck = std::scoped_lock{
m_gLock };
186 auto lk = std::scoped_lock{ this->
m_gLock };
197 auto lk2 = std::scoped_lock{ *imut };
203 error() <<
"Initialization loop detected when creating service \"" <<
name <<
"\"" <<
endmsg;
226 []( ListSvc::const_reference i ) {
return i.service.get(); } );
234 return find(
name ) != m_listsvc.end();
241 auto it =
find( svc );
276 for (
auto& it : activeSvc(
m_listsvc ) ) {
278 switch ( it->FSMState() ) {
284 sc = it->sysInitialize();
286 error() <<
"Unable to initialize Service: " <<
name <<
endmsg;
291 error() <<
"Service " <<
name <<
" not in the correct state to be initialized (" << it->FSMState() <<
")"
310 for (
auto& it : activeSvc(
m_listsvc ) ) {
312 switch ( it->FSMState() ) {
320 error() <<
"Unable to start Service: " <<
name <<
endmsg;
325 error() <<
"Service " <<
name <<
" not in the correct state to be started (" << it->FSMState() <<
")" <<
endmsg;
346 switch ( svc->FSMState() ) {
354 error() <<
"Unable to stop Service: " <<
name <<
endmsg;
359 DEBMSG <<
"Service " <<
name <<
" not in the correct state to be stopped (" << svc->FSMState() <<
")" <<
endmsg;
377 for (
auto& svc : activeSvc(
m_listsvc ) ) {
378 sc = svc->sysReinitialize();
380 error() <<
"Unable to re-initialize Service: " << svc->name() <<
endmsg;
398 for (
auto& svc : activeSvc(
m_listsvc ) ) {
399 sc = svc->sysRestart();
401 error() <<
"Unable to re-start Service: " << svc->name() <<
endmsg;
415 if ( pri_tool != 0 ) {
429 auto p_inc = service<IIncidentSvc>(
"IncidentSvc",
false );
431 p_inc->getListeners( postFinList, IncidentType::SvcPostFinalize );
450 if ( !svc->sysFinalize().isSuccess() ) {
451 warning() <<
"Finalization of service " <<
name <<
" failed" <<
endmsg;
458 if ( !postFinList.
empty() ) {
459 DEBMSG <<
"Will call SvcPostFinalize for " << postFinList.
size() <<
" clients" <<
endmsg;
460 Incident inc(
"ServiceManager", IncidentType::SvcPostFinalize );
461 for (
auto& itr : postFinList ) itr->handle( inc );
466 DEBMSG <<
"Looping over all active services..." <<
endmsg;
469 DEBMSG <<
"---- " << it->service->name() <<
" (refCount = " << it->service->refCount() <<
")" <<
endmsg;
470 if ( it->service->refCount() < 1 ) {
471 warning() <<
"Too low reference count for " << it->service->name() <<
" (should not go below 1 at this point)"
473 it->service->addRef();
516 <<
"===================== listing all services ===================\n"
517 <<
" prior ref name active\n";
522 log.flags( std::ios_base::right );
523 log << svc.priority <<
" ";
525 log << svc.service->refCount() <<
" ";
527 log.flags( std::ios_base::left );
528 log << svc.service->name() <<
" ";
533 log <<
"=================================================================\n";
540 const auto svc =
dynamic_cast<Service*
>( svcItem.service.get() );
Gaudi::StateMachine::State targetFSMState() const override
When we are in the middle of a transition, get the state where the transition is leading us.
bool loopCheckEnabled() const override
Get the value of the initialization loop check flag.
MSG::Level resetMessaging()
Reinitialize internal states.
StatusCode start() override
Start (from INITIALIZED to RUNNING).
::details::reverse_wrapper< T > reverse(T &&iterable)
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
~ServiceManager() override
virtual destructor
T back_inserter(T... args)
SmartIF< IService > service
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
SmartIF< IService > m_appSvc
Pointer to the application IService interface.
Helper class to parse a string of format "type/name".
StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY) override
implementation of ISvcManager::addService
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
StatusCode removeService(IService *svc) override
implementation of ISvcManager::removeService
SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
Returns a smart pointer to a service.
ListSvc m_listsvc
List of service maintained by ServiceManager This contains SmartIF<T> for all services – and because ...
StatusCode declareSvcType(std::string svcname, std::string svctype) override
implementation of ISvcManager::declareSvcType
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype) override
implementation of ISvcManager::createService NOTE: as this returns a &, we must guarantee that once c...
bool m_loopCheck
Check for service initialization loops.
ServiceManager(IInterface *application)
default creator
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
T forward_as_tuple(T... args)
std::map< std::string, std::recursive_mutex > m_lockMap
ListSvc::iterator find(std::string_view name)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
std::list< IService * > m_listOfPtrs
List of pointers to the know services used to implement getServices()
void setLoopCheckEnabled(bool en) override
Set the value of the initialization loop check flag.
T emplace_back(T... args)
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
constexpr static const auto SUCCESS
int getPriority(std::string_view name) const override
manage priorities of services
TYPE * get() const
Get interface pointer.
std::string typeName(const std::type_info &typ)
bool existsService(std::string_view name) const override
implementation of ISvcLocation::existsService
bool isValidInterface(IFace *i)
Templated function that throws an exception if the version if the interface implemented by the object...
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
std::recursive_mutex m_gLock
Mutex to synchronize shared service initialization between threads.
constexpr static const auto FAILURE
const std::list< IService * > & getServices() const override
Return the list of Services.
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
#define DECLARE_OBJECT_FACTORY(x)
Interface for a component that manages application configuration options.
MapType m_maptype
Map of service name and service type.
StatusCode setPriority(std::string_view name, int pri) override