fw4spl
ServiceFactoryRegistrar.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWSERVICES_SERVICEFACTORYREGISTRAR_HPP__
8 #define __FWSERVICES_SERVICEFACTORYREGISTRAR_HPP__
9 
10 #include "fwServices/factory/new.hpp"
11 #include "fwServices/registry/ServiceFactory.hpp"
12 
13 namespace fwServices
14 {
15 
20 template<class SRV_IMPL>
22 {
23 public:
24 
25  ServiceFactoryRegistrar(const std::string& simpl, const std::string& stype)
26  {
28  factory->addServiceFactory( &::fwServices::factory::New< SRV_IMPL >, simpl, stype);
29  }
30 
31  ServiceFactoryRegistrar(const std::string& simpl, const std::string& stype, const std::string& oimpl)
32  {
34  factory->addServiceFactory( &::fwServices::factory::New< SRV_IMPL >, simpl, stype);
35  factory->addObjectFactory( simpl, oimpl);
36  }
37 };
38 
43 {
44 public:
45 
46  ServiceObjectFactoryRegistrar(const std::string& simpl, const std::string& oimpl)
47  {
49  factory->addObjectFactory( simpl, oimpl);
50  }
51 };
52 
53 } //end namespace fwServices
54 
55 
56 #endif // __FWSERVICES_SERVICEFACTORYREGISTRAR_HPP__
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
Contains fwAtomsFilter::factory utilities.
Helper for registering a service Creates internally the service factory and adds it to the FactoryReg...
static FWSERVICES_API ServiceFactory::sptr getDefault()
Return the unique Instance, create it if required at first access.
Helper for associating an object to a service implementation.