1 #ifndef GAUDIKERNEL_IMPLEMENTS_H
2 #define GAUDIKERNEL_IMPLEMENTS_H
4 #include "GaudiKernel/IInterface.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>
139 typedef typename extend_interfaces_base::ext_iids interfaces;
149 template <
typename I1,
typename I2>
156 typedef typename extend_interfaces_base::ext_iids interfaces;
166 template <
typename I1,
typename I2,
typename I3>
173 typedef typename extend_interfaces_base::ext_iids interfaces;
183 template <
typename I1,
typename I2,
typename I3,
typename I4>
190 typedef typename extend_interfaces_base::ext_iids interfaces;
198 #undef _refcounting_implementation_
199 #undef _helper_common_implementation_
Base class to be used to extend an interface.
Base class to be used to extend an interface.
Helper class for the cast used in the MPL for_each algorithm in the implementation of queryInterface...
Base class used to implement the interfaces.
#define _helper_common_implementation_(N)
Base class used to implement the interfaces.
Base class to be used to extend an interface.
Base class used to implement the interfaces.
Base class to be used to extend an interface.
Base class used to implement the interfaces.
Helper class for the cast used in the MPL for_each algorithm in the implementation of query_interface...