fw4spl
core/fwServices/include/fwServices/macros.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "fwServices/IService.hpp"
10 #include "fwServices/ServiceFactoryRegistrar.hpp"
11 
13 
14 #include <boost/preprocessor/cat.hpp>
15 #include <boost/preprocessor/facilities/empty.hpp>
16 #include <boost/preprocessor/facilities/overload.hpp>
17 
18 namespace fwServices
19 {
20 
25 #define __FWSERVICES_REGISTER_MACRO( ServiceType, ServiceImpl ) \
26  class BOOST_PP_CAT ( ServiceTypeConceptCheck, __LINE__ ) \
27  { \
28  public: \
29  BOOST_CONCEPT_ASSERT((::fwCore::concepts::SharedPtrTypedef< ServiceType >)); \
30  }; \
31  class BOOST_PP_CAT ( ServiceImplConceptCheck, __LINE__ ) \
32  { \
33  public: \
34  BOOST_CONCEPT_ASSERT((::fwCore::concepts::SharedPtrTypedef< ServiceImpl >)); \
35  }; \
36  static ::fwServices::ServiceFactoryRegistrar< ServiceImpl > \
37  BOOST_PP_CAT( serviceRegistrar, __LINE__) ( #ServiceImpl, #ServiceType );
38 
39 #define __FWSERVICES_REGISTER_OBJECT_MACRO( ServiceImpl, ServiceObject ) \
40  class BOOST_PP_CAT ( ServiceObjectConceptCheck, __LINE__ ) \
41  { \
42  public: \
43  BOOST_CONCEPT_ASSERT((::fwCore::concepts::SharedPtrTypedef< ServiceObject >)); \
44  }; \
45  static ::fwServices::ServiceObjectFactoryRegistrar \
46  BOOST_PP_CAT( serviceObjectRegistrar, __LINE__) ( #ServiceImpl, #ServiceObject );
47 
49 
50 #define __FWSERVICES_REGISTER_MACRO_2(ServiceImpl, ServiceObject) \
51  __FWSERVICES_REGISTER_MACRO(ServiceImpl, ServiceObject)
52 
53 #define __FWSERVICES_REGISTER_MACRO_3(ServiceType, ServiceImpl, ServiceObject) \
54  __FWSERVICES_REGISTER_MACRO(ServiceType, ServiceImpl) \
55  __FWSERVICES_REGISTER_OBJECT_MACRO(ServiceImpl, ServiceObject)
56 
61 #if !BOOST_PP_VARIADICS_MSVC
62 
63 #define fwServicesRegisterMacro(...) BOOST_PP_OVERLOAD(__FWSERVICES_REGISTER_MACRO_, __VA_ARGS__)(__VA_ARGS__)
64 
65 #else
66 
67 #define fwServicesRegisterMacro(...) \
68  BOOST_PP_CAT(BOOST_PP_OVERLOAD(__FWSERVICES_REGISTER_MACRO_, __VA_ARGS__)(__VA_ARGS__), BOOST_PP_EMPTY())
69 
70 #endif
71 
72 #define fwServicesRegisterObjectMacro(ServiceImpl, ServiceObject) \
73  __FWSERVICES_REGISTER_OBJECT_MACRO(ServiceImpl, ServiceObject)
74 
76 
77 }
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
This file defines some fw4spl concept checks.