LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::ServiceRegistry Class Reference

#include "ServiceRegistry.h"

Classes

class  Operate
 

Public Types

using ParameterSets = std::vector< fhicl::ParameterSet >
 

Static Public Member Functions

template<typename T >
static bool isAvailable ()
 
static ServiceToken createSet (ParameterSets const &, ActivityRegistry &)
 

Private Member Functions

 ServiceRegistry (ServiceRegistry const &)=delete
 
ServiceRegistryoperator= (ServiceRegistry const &)=delete
 
ServiceToken presentToken () const
 
ServiceToken setContext (ServiceToken const &iNewToken)
 
void unsetContext (ServiceToken const &iOldToken)
 
template<typename T , typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val != ServiceScope::PER_SCHEDULE>>
T & get () const
 
template<typename T , typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val == ServiceScope::PER_SCHEDULE>>
T & get (ScheduleID sID) const
 
 ServiceRegistry ()=default
 

Static Private Member Functions

static ServiceRegistryinstance ()
 

Private Attributes

cet::LibraryManager lm_ {Suffixes::service()}
 
std::shared_ptr< ServicesManagermanager_ {nullptr}
 

Friends

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

Detailed Description

Definition at line 26 of file ServiceRegistry.h.

Member Typedef Documentation

Definition at line 65 of file ServiceRegistry.h.

Constructor & Destructor Documentation

art::ServiceRegistry::ServiceRegistry ( ServiceRegistry const &  )
privatedelete
art::ServiceRegistry::ServiceRegistry ( )
privatedefault

Referenced by get().

Member Function Documentation

ServiceToken ServiceRegistry::createSet ( ParameterSets const &  iPS,
ActivityRegistry reg 
)
static

Definition at line 35 of file ServiceRegistry.cc.

References instance(), and lm_.

Referenced by art::ServiceDirector::ServiceDirector().

36 {
37  auto result = std::make_shared<ServicesManager>(
38  iPS, ServiceRegistry::instance().lm_, reg);
39  return ServiceToken{result};
40 }
static ServiceRegistry & instance()
cet::LibraryManager lm_
template<typename T , typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val != ServiceScope::PER_SCHEDULE>>
T& art::ServiceRegistry::get ( ) const
inlineprivate

Definition at line 83 of file ServiceRegistry.h.

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

Referenced by art::ServiceHandle< art::FileTransfer >::ServiceHandle(), and art::ServiceHandle< T, art::ServiceScope::PER_SCHEDULE >::ServiceHandle().

84  {
85  if (!manager_) {
87  << " no ServiceRegistry has been set for this thread";
88  }
89  return manager_->get<T>();
90  }
std::shared_ptr< ServicesManager > manager_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T , typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val == ServiceScope::PER_SCHEDULE>>
T& art::ServiceRegistry::get ( ScheduleID  sID) const
inlineprivate

Definition at line 96 of file ServiceRegistry.h.

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

97  {
98  if (!manager_) {
100  << " no ServiceRegistry has been set for this thread";
101  }
102  return manager_->get<T>(sID);
103  }
std::shared_ptr< ServicesManager > manager_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
static bool art::ServiceRegistry::isAvailable ( )
inlinestatic

Definition at line 55 of file ServiceRegistry.h.

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

56  {
57  if (auto& mgr = instance().manager_) {
58  return mgr->isAvailable<T>();
59  }
60 
62  << " no ServiceRegistry has been set for this thread";
63  }
static ServiceRegistry & instance()
std::shared_ptr< ServicesManager > manager_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ServiceRegistry& art::ServiceRegistry::operator= ( ServiceRegistry const &  )
privatedelete
ServiceToken ServiceRegistry::presentToken ( ) const
private

Definition at line 29 of file ServiceRegistry.cc.

References manager_.

30 {
31  return ServiceToken{manager_};
32 }
std::shared_ptr< ServicesManager > manager_
ServiceToken ServiceRegistry::setContext ( ServiceToken const &  iNewToken)
private

Definition at line 15 of file ServiceRegistry.cc.

References art::ServiceToken::manager_, and manager_.

Referenced by art::ServiceRegistry::Operate::Operate().

16 {
17  ServiceToken result{manager_};
18  manager_ = iNewToken.manager_;
19  return result;
20 }
std::shared_ptr< ServicesManager > manager_
void ServiceRegistry::unsetContext ( ServiceToken const &  iOldToken)
private

Definition at line 23 of file ServiceRegistry.cc.

References art::ServiceToken::manager_, and manager_.

Referenced by art::ServiceRegistry::Operate::~Operate().

24 {
25  manager_ = iOldToken.manager_;
26 }
std::shared_ptr< ServicesManager > manager_

Friends And Related Function Documentation

friend class Operate
friend

Definition at line 49 of file ServiceRegistry.h.

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

Definition at line 51 of file ServiceRegistry.h.

Member Data Documentation

cet::LibraryManager art::ServiceRegistry::lm_ {Suffixes::service()}
private

Definition at line 108 of file ServiceRegistry.h.

Referenced by createSet().

std::shared_ptr<ServicesManager> art::ServiceRegistry::manager_ {nullptr}
private

Definition at line 109 of file ServiceRegistry.h.

Referenced by get(), isAvailable(), presentToken(), setContext(), and unsetContext().


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