LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::ServiceRegistry Class Reference

#include "ServiceRegistry.h"

Public Member Functions

 ~ServiceRegistry () noexcept
 
 ServiceRegistry (ServiceRegistry const &)=delete
 
 ServiceRegistry (ServiceRegistry &&)=delete
 
ServiceRegistryoperator= (ServiceRegistry const &)=delete
 
ServiceRegistryoperator= (ServiceRegistry &&)=delete
 

Static Public Member Functions

template<typename T >
static bool isAvailable ()
 

Private Member Functions

 ServiceRegistry () noexcept
 
void setManager (ServicesManager *)
 
template<typename T >
T & get () const
 

Static Private Member Functions

static ServiceRegistryinstance () noexcept
 

Private Attributes

cet::exempt_ptr< ServicesManagermanager_ {nullptr}
 

Friends

class ServicesManager
 
template<typename T , art::ServiceScope >
class ServiceHandle
 

Detailed Description

Definition at line 12 of file ServiceRegistry.h.

Constructor & Destructor Documentation

art::ServiceRegistry::~ServiceRegistry ( )
defaultnoexcept
art::ServiceRegistry::ServiceRegistry ( ServiceRegistry const &  )
delete
art::ServiceRegistry::ServiceRegistry ( ServiceRegistry &&  )
delete
art::ServiceRegistry::ServiceRegistry ( )
privatedefaultnoexcept

Referenced by isAvailable().

Member Function Documentation

template<typename T >
T& art::ServiceRegistry::get ( ) const
inlineprivate

Definition at line 46 of file ServiceRegistry.h.

References manager_, and art::errors::ServiceNotFound.

Referenced by art::ServiceHandle< art::FileTransfer >::ServiceHandle().

47  {
48  if (!manager_) {
49  throw Exception(errors::ServiceNotFound, "Service")
50  << " no ServiceRegistry has been set for this thread";
51  }
52  return manager_->get<T>();
53  }
cet::exempt_ptr< ServicesManager > manager_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ServiceRegistry & art::ServiceRegistry::instance ( )
staticprivatenoexcept

Definition at line 10 of file ServiceRegistry.cc.

Referenced by isAvailable(), art::ServiceHandle< art::FileTransfer >::ServiceHandle(), and art::ServicesManager::ServicesManager().

11  {
12  static ServiceRegistry me;
13  return me;
14  }
ServiceRegistry() noexcept
template<typename T >
static bool art::ServiceRegistry::isAvailable ( )
inlinestatic

Definition at line 29 of file ServiceRegistry.h.

References instance(), manager_, art::errors::ServiceNotFound, ServiceRegistry(), and setManager().

30  {
31  if (auto& mgr = instance().manager_) {
32  return mgr->isAvailable<T>();
33  }
34  throw Exception(errors::ServiceNotFound, "Service")
35  << " no ServiceRegistry has been set for this thread";
36  }
static ServiceRegistry & instance() noexcept
cet::exempt_ptr< ServicesManager > manager_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ServiceRegistry& art::ServiceRegistry::operator= ( ServiceRegistry const &  )
delete
ServiceRegistry& art::ServiceRegistry::operator= ( ServiceRegistry &&  )
delete
void art::ServiceRegistry::setManager ( ServicesManager mgr)
private

Definition at line 17 of file ServiceRegistry.cc.

References manager_.

Referenced by isAvailable(), and art::ServicesManager::ServicesManager().

18  {
19  manager_ = mgr;
20  }
cet::exempt_ptr< ServicesManager > manager_

Friends And Related Function Documentation

template<typename T , art::ServiceScope >
friend class ServiceHandle
friend

Definition at line 18 of file ServiceRegistry.h.

friend class ServicesManager
friend

Definition at line 15 of file ServiceRegistry.h.

Member Data Documentation

cet::exempt_ptr<ServicesManager> art::ServiceRegistry::manager_ {nullptr}
private

Definition at line 55 of file ServiceRegistry.h.

Referenced by get(), isAvailable(), and setManager().


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