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;
110 auto lck = std::scoped_lock{
m_gLock };
112 service->setServiceManager(
this );
122 auto it =
find( svc );
123 auto lck = std::scoped_lock{
m_gLock };
148 sc = svc->sysInitialize();
152 error() <<
"Unable to initialize service \"" <<
typeName.name() <<
"\"" <<
endmsg;
153 auto lck = std::scoped_lock{
m_gLock };
162 auto lck = std::scoped_lock{
m_gLock };
187 auto lk = std::scoped_lock{ this->
m_gLock };
198 auto lk2 = std::scoped_lock{ *imut };
204 error() <<
"Initialization loop detected when creating service \"" <<
name <<
"\"" <<
endmsg;
227 []( ListSvc::const_reference i ) {
return i.service.get(); } );
235 return find(
name ) != m_listsvc.end();
242 auto it =
find( svc );
277 for (
auto& it : activeSvc(
m_listsvc ) ) {
279 switch ( it->FSMState() ) {
285 sc = it->sysInitialize();
287 error() <<
"Unable to initialize Service: " <<
name <<
endmsg;
292 error() <<
"Service " <<
name <<
" not in the correct state to be initialized (" << it->FSMState() <<
")"
311 for (
auto& it : activeSvc(
m_listsvc ) ) {
313 switch ( it->FSMState() ) {
321 error() <<
"Unable to start Service: " <<
name <<
endmsg;
326 error() <<
"Service " <<
name <<
" not in the correct state to be started (" << it->FSMState() <<
")" <<
endmsg;
347 switch ( svc->FSMState() ) {
355 error() <<
"Unable to stop Service: " <<
name <<
endmsg;
360 DEBMSG <<
"Service " <<
name <<
" not in the correct state to be stopped (" << svc->FSMState() <<
")" <<
endmsg;
378 for (
auto& svc : activeSvc(
m_listsvc ) ) {
379 sc = svc->sysReinitialize();
381 error() <<
"Unable to re-initialize Service: " << svc->name() <<
endmsg;
399 for (
auto& svc : activeSvc(
m_listsvc ) ) {
400 sc = svc->sysRestart();
402 error() <<
"Unable to re-start Service: " << svc->name() <<
endmsg;
416 if ( pri_tool != 0 ) {
430 auto p_inc = service<IIncidentSvc>(
"IncidentSvc",
false );
432 p_inc->getListeners( postFinList, IncidentType::SvcPostFinalize );
451 if ( !svc->sysFinalize().isSuccess() ) {
452 warning() <<
"Finalization of service " <<
name <<
" failed" <<
endmsg;
459 if ( !postFinList.
empty() ) {
460 DEBMSG <<
"Will call SvcPostFinalize for " << postFinList.
size() <<
" clients" <<
endmsg;
461 Incident inc(
"ServiceManager", IncidentType::SvcPostFinalize );
462 for (
auto& itr : postFinList ) itr->handle( inc );
467 DEBMSG <<
"Looping over all active services..." <<
endmsg;
470 DEBMSG <<
"---- " << it->service->name() <<
" (refCount = " << it->service->refCount() <<
")" <<
endmsg;
471 if ( it->service->refCount() < 1 ) {
472 warning() <<
"Too low reference count for " << it->service->name() <<
" (should not go below 1 at this point)"
474 it->service->addRef();
517 <<
"===================== listing all services ===================\n"
518 <<
" prior ref name active\n";
523 log.flags( std::ios_base::right );
524 log << svc.priority <<
" ";
526 log << svc.service->refCount() <<
" ";
528 log.flags( std::ios_base::left );
529 log << svc.service->name() <<
" ";
534 log <<
"=================================================================\n";
541 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