19 #ifndef IGNITION_COMMON_DETAIL_SPECIALIZEDPLUGIN_HH_ 20 #define IGNITION_COMMON_DETAIL_SPECIALIZEDPLUGIN_HH_ 28 #ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS 29 bool usedSpecializedInterfaceAccess;
38 template <
class SpecInterface>
41 template <
class Interface>
44 return this->PrivateQueryInterface(type<Interface>());
48 template <
class SpecInterface>
49 template <
class Interface>
52 return this->PrivateQueryInterface(type<Interface>());
56 template <
class SpecInterface>
57 template <
class Interface>
61 Interface *ptr = this->QueryInterface<Interface>();
69 template <
class SpecInterface>
70 template <
class Interface>
74 const Interface *ptr = this->QueryInterface<Interface>();
82 template <
class SpecInterface>
83 template <
class Interface>
86 return this->PrivateHasInterface(type<Interface>());
90 template <
class SpecInterface>
91 template <
class Interface>
95 return this->Plugin::QueryInterface<Interface>();
99 template <
class SpecInterface>
103 #ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS 104 usedSpecializedInterfaceAccess =
true;
106 return static_cast<SpecInterface*
>(
107 this->privateSpecializedInterfaceIterator->second);
111 template <
class SpecInterface>
112 template <
class Interface>
116 return this->Plugin::QueryInterface<Interface>();
120 template <
class SpecInterface>
124 #ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS 125 usedSpecializedInterfaceAccess =
true;
127 return static_cast<SpecInterface*
>(
128 this->privateSpecializedInterfaceIterator->second);
132 template <
class SpecInterface>
133 template <
class Interface>
135 type<Interface>)
const 137 return this->Plugin::HasInterface<Interface>();
141 template <
class SpecInterface>
143 type<SpecInterface>)
const 145 #ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS 146 usedSpecializedInterfaceAccess =
true;
148 return (
nullptr != this->privateSpecializedInterfaceIterator->second);
152 template <
class SpecInterface>
154 : privateSpecializedInterfaceIterator(
155 this->PrivateGetOrCreateIterator(
156 SpecInterface::IGNCOMMONInterfaceName))
169 template <
typename Interface,
bool specialized>
170 struct SelectSpecalizerIfAvailableImpl
178 template <
typename Interface>
179 struct SelectSpecalizerIfAvailableImpl<Interface, false>
181 using Specializer =
Plugin;
188 template <
typename Interface,
typename Specialization>
189 struct SelectSpecalizerIfAvailable
191 using Specializer =
typename SelectSpecalizerIfAvailableImpl<Interface,
203 template <
class Base1,
class Base2>
204 class ComposePlugin :
public virtual Base1,
public virtual Base2
207 public:
virtual ~ComposePlugin() =
default;
215 using Specialization = ComposePlugin<Base1, Base2>;
226 #define DETAIL_IGN_COMMON_COMPOSEPLUGIN_DISPATCH( \ 227 ReturnType, Function, Suffix, CastTo, Args) \ 230 ReturnType Function Suffix \ 232 using Specializer = typename detail::SelectSpecalizerIfAvailable< \ 233 T, Specialization>::Specializer; \ 234 return static_cast<CastTo*>(this)->template Function <T> Args; \ 239 T*, QueryInterface, (), Specializer, ())
242 const T*, QueryInterface, () const, const Specializer, ())
245 std::shared_ptr<T>, QueryInterfaceSharedPtr, (), Specializer, ())
248 std::shared_ptr<const T>, QueryInterfaceSharedPtr,
249 () const, const Specializer, ())
252 bool, HasInterface, () const, const Specializer, ())
256 template <class...> friend class
ignition::common::SpecializedPlugin;
257 template <class, class> friend class ComposePlugin;
259 private: ComposePlugin() = default;
265 template <class SpecInterface1, class... OtherSpecInterfaces>
266 class SpecializedPlugin<SpecInterface1, OtherSpecInterfaces...> :
267 public virtual detail::ComposePlugin<
268 SpecializedPlugin<SpecInterface1>,
269 SpecializedPlugin<OtherSpecInterfaces...> >
273 template <
class,
class>
friend class detail::ComposePlugin;
277 public:
virtual ~SpecializedPlugin() =
default;
280 private: SpecializedPlugin() =
default;
friend class SpecializedPlugin
Definition: detail/SpecializedPlugin.hh:272
friend class TemplatePluginPtr
Definition: detail/SpecializedPlugin.hh:274
bool HasInterface() const
Returns true if this Plugin has the specified type of interface. Note that this function only works w...
Definition: detail/Plugin.hh:105
Interface * QueryInterface()
Get an interface of the specified type. Note that this function only works when the Interface type is...
Definition: detail/Plugin.hh:32
Definition: SpecializedPlugin.hh:34
#define DETAIL_IGN_COMMON_COMPOSEPLUGIN_DISPATCH(ReturnType, Function, Suffix, CastTo, Args)
Implement functions whose only roles are to dispatch their functionalities between two base classes...
Definition: detail/SpecializedPlugin.hh:226
Forward declarations for the common classes.
std::shared_ptr< Interface > QueryInterfaceSharedPtr()
Get the requested interface as a std::shared_ptr. Note that this function only works when the Interfa...
Definition: detail/Plugin.hh:65