25 template<
typename C>
static one test(
typename C::interface_type*);
26 template<
typename C>
static two test(...);
29 enum { value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
33 using is_interface_helper = std::is_same<T, typename T::interface_type>;
36 template<
typename T,
typename Enable =
void>
40 struct is_interface<T, typename std::enable_if<!has_interface_type<T>::value>::type> : std::false_type
45 struct is_interface<T, typename std::enable_if<has_interface_type<T>::value && !is_interface_helper<T>::value>::type> : std::false_type
50 struct is_interface<T, typename std::enable_if<has_interface_type<T>::value && is_interface_helper<T>::value>::type> : std::true_type
62 template <
typename C>
static two test(...);
65 enum { value =
sizeof(test<T>(
static_cast<tResult(T::*)(
const char*,
void*&)
>(
nullptr))) ==
sizeof(
char) };
69 template<
typename BaseClass,
typename Enable =
void>
78 inline tResult GetInterfaceStatic(
const char* ,
void*& )
83 inline tResult GetInterfaceStatic(
const char* ,
const void*& )
const
89 enum { dispatch =
false };
94 template<
typename BaseClass>
95 struct base_dispatcher<BaseClass, typename std::enable_if<!is_interface<BaseClass>::value && !has_get_interface<BaseClass>::value>::type> :
99 using BaseClass::BaseClass;
103 inline tResult GetInterfaceStatic(
const char* ,
void*& )
108 inline tResult GetInterfaceStatic(
const char* ,
const void*& )
const
116 template <
typename BaseClass>
117 struct base_dispatcher<BaseClass, typename std::enable_if<!is_interface<BaseClass>::value && has_get_interface<BaseClass>::value>::type> :
121 using BaseClass::BaseClass;
125 inline tResult GetInterfaceStatic(
const char* i_strIID,
void*& o_pInterface)
127 return BaseClass::GetInterface(i_strIID, o_pInterface);
130 inline tResult GetInterfaceStatic(
const char* i_strIID,
const void*& o_pInterface)
const
132 return BaseClass::GetInterface(i_strIID, o_pInterface);
137 template <
typename Interface>
138 struct base_dispatcher<Interface, typename std::enable_if<is_interface<Interface>::value>::type>:
142 using Interface::Interface;
146 inline tResult GetInterfaceStatic(
const char* i_strIID,
void*& o_pInterface)
148 if (util::cStringUtil::IsEqual(ucom::get_iid<Interface>(), i_strIID))
150 o_pInterface =
static_cast<Interface*
>(
this);
157 inline tResult GetInterfaceStatic(
const char* i_strIID,
const void*& o_pInterface)
const
159 if (util::cStringUtil::IsEqual(ucom::get_iid<Interface>(), i_strIID))
161 o_pInterface =
static_cast<const Interface*
>(
this);
171 template <
typename Base,
typename NextBase>
179 tResult GetInterface(
const char* i_strIID,
void*& o_pInterface)
189 tResult GetInterface(
const char* i_strIID,
const void*& o_pInterface)
const
200 #if defined(__GNUC__)
201 #pragma GCC diagnostic push
202 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
209 #if defined(__GNUC__)
210 #pragma GCC diagnostic pop
216 template <
typename Base,
typename NextBase>
227 template<
typename Base,
typename ...Interfaces>
233 tResult GetInterface(
const char* i_strIID,
void*& o_pInterface)
242 tResult GetInterface(
const char* i_strIID,
const void*& o_pInterface)
const
252 #if defined(__GNUC__)
253 #pragma GCC diagnostic push
254 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
261 #if defined(__GNUC__)
262 #pragma GCC diagnostic pop
267 template <
typename ...Bases>
273 template <
typename Base,
typename NextBase>
274 using derive_from_type =
typename std::conditional<std::is_same<NextBase, object_without_iobject<>>::value,
276 typename std::conditional<std::is_base_of<Base, NextBase>::value,
278 typename std::conditional<std::is_base_of<ucom::ant::IObject, Base>::value,
285 template <
typename Base,
typename NextBase>
293 template <
typename ...Bases>
299 template <
typename Base,
typename NextBase,
typename ...Bases>
301 std::conditional<!std::is_same<NextBase, Base>::value &&
302 std::is_base_of<NextBase, Base>::value,
304 parent_follows_child<Base, Bases...>>::type
309 template <
typename Base,
typename ...Bases>
311 public derive_from<Base, object_without_iobject<Bases...>>
317 "One or more of the template parameters are in the wrong order. "
318 "Make sure that derived classes are specified after their parents.");
394 template <
typename ...Bases>
399 virtual ~
object() =
default;
412 #if defined(__GNUC__)
413 #pragma GCC diagnostic push
414 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
421 #if defined(__GNUC__)
422 #pragma GCC diagnostic pop
427 template<
typename Base,
typename... Bases>
428 using object_base_type_helper =
429 typename std::conditional<std::is_base_of<object<>, Base>::value,
430 detail::derive_from<Base, detail::object_without_iobject<Bases...>>,
431 detail::derive_from<Base,
object<Bases...>>>::type;
434 template<
typename Base,
typename... Bases>
435 class object<Base, Bases...> :
public object_base_type_helper<Base, Bases...>
438 using object_base_type_helper<Base, Bases...>::object_base_type_helper;
443 "One or more of the template parameters are in the wrong order. "
444 "Make sure that derived classes are specified after their parents.");
#define UCOM_RESOLVE(...)
Resolve a path to a base class which is inherited multiple times.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
#define IS_OK(s)
Check if result is OK.
A common result class usable as return value throughout.
Base class for every interface type within the uCOM.
static tResult Get(Provider *i_pObj, const char *i_strIID, VoidType *&o_pInterface)
Get the interface with IID i_strIID exposed from i_pObj.
This template checks if the first base implements the requested interface, otherwise checks the next ...
This template checks if the first base implements the requested interface, otherwise checks the next ...
void Destroy() const
Possibly required override of IObject::Destroy() while destructor is still non-virtual.
This template checks if the first base implements the requested interface, otherwise checks the next ...
void Destroy() const
Possibly required override of IObject::Destroy() while destructor is still non-virtual.
template that checks whether a type has an accessible (protected or public) GetInterface method.
template that checks whether a type has an accessible interface_type property.
This template is used to prevent an ambiguous base of ucom::ant::IObject.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
void Destroy() const override
Switch from non-virtual destructor to virtual destructor.
tResult GetInterface(const char *i_strIID, const void *&o_pInterface) const override
Provides const correct interface querying.
tResult GetInterface(const char *i_strIID, void *&o_pInterface) override
Query interfaces on an object.
typename std::conditional< std::is_same< NextBase, object_without_iobject<> >::value, expose_additional_interfaces< Base >, typename std::conditional< std::is_base_of< Base, NextBase >::value, expose_additional_interfaces< NextBase, Base >, typename std::conditional< std::is_base_of< ucom::ant::IObject, Base >::value, derive_from_with_hierarchy< Base, NextBase >, derive_from_without_hierarchy< Base, NextBase > >::type >::type >::type derive_from_type
this intermediate type is used to keep binary compatibility
Namespace for entire ADTF SDK.
template that checks whether a type is an interface with an IID.
this template checks if parent interfaces are not specified before their children