1 #ifndef GAUDIKERNEL_IMPLEMENTS_H
2 #define GAUDIKERNEL_IMPLEMENTS_H
23 template <
typename IID>
24 inline void operator() (IID) {
25 if ((!ptr) && target.versionMatch(IID::interfaceID())) {
26 ptr =
const_cast<void*
>(
reinterpret_cast<const void*
>(
static_cast<const typename IID::iface_type*
>(instance)));
35 std::vector<std::string> &
v;
38 template <
typename IID>
39 inline void operator() (IID) { v.push_back(IID::name()); }
44 #define _refcounting_implementation_ \
47 virtual unsigned long addRef() { return ++m_refCount; } \
49 virtual unsigned long release() { \
51 const unsigned long count = (m_refCount) ? --m_refCount : m_refCount; \
52 if(count == 0) delete this; \
56 virtual unsigned long refCount() const { return m_refCount; } \
59 unsigned long m_refCount; \
63 #define _helper_common_implementation_(N) \
66 virtual void *i_cast(const InterfaceID &tid) const { \
68 interfaceMatch<implements##N> matcher(this,tid,ptr); \
69 mpl::for_each<interfaces>(matcher); \
73 virtual StatusCode queryInterface(const InterfaceID &ti, void** pp){ \
74 if (!pp) return StatusCode::FAILURE; \
76 interfaceMatch<implements##N> matcher(this,ti,*pp); \
77 mpl::for_each<interfaces>(matcher); \
79 return StatusCode::FAILURE; \
82 return StatusCode::SUCCESS; \
85 virtual std::vector<std::string> getInterfaceNames() const { \
86 std::vector<std::string> v; \
87 AppendInterfaceName appender(v); \
88 mpl::for_each<interfaces>(appender); \
92 implements##N():m_refCount(0) {} \
94 implements##N(const implements##N &):m_refCount(0) {} \
96 implements##N& operator=(const implements##N &) { return *this; } \
98 virtual ~implements##N() {} \
99 _refcounting_implementation_
101 #define _helper_common_implementation_(N) \
104 virtual void *i_cast(const InterfaceID &tid) const { \
108 virtual StatusCode queryInterface(const InterfaceID &ti, void** pp){ \
109 if (!pp) return StatusCode::FAILURE; \
111 return StatusCode::SUCCESS; \
114 virtual std::vector<std::string> getInterfaceNames() const { \
115 std::vector<std::string> v; \
119 implements##N():m_refCount(0) {} \
121 implements##N(const implements##N &):m_refCount(0) {} \
123 implements##N& operator=(const implements##N &) { return *this; } \
125 virtual ~implements##N() {} \
126 _refcounting_implementation_
132 template <
typename I1>
149 template <
typename I1,
typename I2>
166 template <
typename I1,
typename I2,
typename I3>
183 template <
typename I1,
typename I2,
typename I3,
typename I4>
198 #undef _refcounting_implementation_
199 #undef _helper_common_implementation_
Base class to be used to extend an interface.
extend_interfaces_base::ext_iids interfaces
MPL set of all the implemented interfaces.
Base class to be used to extend an interface.
mpl::fold< typename IAuditor::iid::iids::type, typename IProperty::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
MPL set of interfaces extended by this one.
Helper class for the cast used in the MPL for_each algorithm in the implementation of queryInterface...
const T * instance
Value of this.
Base class used to implement the interfaces.
Base class used to implement the interfaces.
Base class to be used to extend an interface.
extend_interfaces4< I1, I2, I3, I4 > extend_interfaces_base
Typedef to the base of this class.
std::vector< std::string > & v
vector to be filled.
AppendInterfaceName(std::vector< std::string > &_v)
void *& ptr
Pointer to be filled.
interfaceMatch(const T *_instance, const InterfaceID &_tid, void *&_ptr)
extend_interfaces1< I1 > extend_interfaces_base
Typedef to the base of this class.
Base class used to implement the interfaces.
#define _helper_common_implementation_(N)
implements3 base_class
Typedef to this class.
extend_interfaces_base::ext_iids interfaces
MPL set of all the implemented interfaces.
IInterface::iid::iids::type ext_iids
MPL set of interfaces extended by this one.
implements1 base_class
Typedef to this class.
mpl::fold< typename IAppMgrUI::iid::iids::type, typename mpl::fold< typename IEventProcessor::iid::iids::type, typename mpl::fold< typename IService::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
MPL set of interfaces extended by this one.
const InterfaceID & target
InterfaceID for the requested interface.
extend_interfaces_base::ext_iids interfaces
MPL set of all the implemented interfaces.
extend_interfaces_base::ext_iids interfaces
MPL set of all the implemented interfaces.
implements2 base_class
Typedef to this class.
Base class to be used to extend an interface.
extend_interfaces3< I1, I2, I3 > extend_interfaces_base
Typedef to the base of this class.
Base class used to implement the interfaces.
implements4 base_class
Typedef to this class.
Helper class for the cast used in the MPL for_each algorithm in the implementation of query_interface...
mpl::fold< typename IService::iid::iids::type, typename mpl::fold< typename IProperty::iid::iids::type, typename IStateful::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type ext_iids
MPL set of interfaces extended by this one.
extend_interfaces2< I1, I2 > extend_interfaces_base
Typedef to the base of this class.