Bayeux  3.4.1
Core Foundation library for SuperNEMO
service_manager-inl.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-06-07
4  * Last modified : 2015-12-03
5  */
6 
7 #ifndef DATATOOLS_SERVICE_MANAGER_INL_H
8 #define DATATOOLS_SERVICE_MANAGER_INL_H
9 
10 namespace datatools {
11 
12  //----------------------------------------------------------------------
13  // class service_manager template method implementations.
14 
15  template <class T>
16  bool service_manager::is_a(const std::string& name_) const
17  {
18  const base_service & serv = get_service(name_);
19  const std::type_info& ti = typeid(T);
20  const std::type_info& tf = typeid(serv);
21  return (ti == tf);
22  }
23 
24  template<class T>
25  T& service_manager::grab(const std::string& name_)
26  {
27  return dynamic_cast<T&>(grab_service(name_));
28  }
29 
30  template<class T>
31  const T& service_manager::get(const std::string& name_) const
32  {
33  service_manager* sm = const_cast<service_manager*>(this);
34  return const_cast<T&>(sm->grab<T>(name_));
35  }
36 
37  template <class ServiceClass>
38  void service_manager::register_service_type(const std::string& id_)
39  {
40  _factory_register_.registration(id_, boost::factory<ServiceClass*>());
41  return;
42  }
43 
44 } // end of namespace datatools
45 
46 #endif // DATATOOLS_SERVICE_MANAGER_INL_H
47 
48 // Local Variables: --
49 // mode: c++ --
50 // c-file-style: "gnu" --
51 // tab-width: 2 --
52 // End: --
const T & get(const std::string &name_) const
Definition: service_manager-inl.h:31
The base service class.
Definition: base_service.h:68
T & grab(const std::string &name_)
Definition: service_manager-inl.h:25
base_service & grab_service(const std::string &name_)
void register_service_type(const std::string &id_)
Register a service factory.
Definition: service_manager-inl.h:38
bool is_a(const std::string &name_) const
Definition: service_manager-inl.h:16
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
const base_service & get_service(const std::string &name_) const
Service management class.
Definition: service_manager.h:57