8 #ifndef _ADTF_UCOM_ANT_UCOM_CAST_INCLUDES_HEADER_
9 #define _ADTF_UCOM_ANT_UCOM_CAST_INCLUDES_HEADER_
28 template<
typename QueriedInterfaceType,
bool>
29 struct ucom_cast_to_implicit_cast
38 template<
typename ObjectType>
39 static QueriedInterfaceType* perform_cast(ObjectType* i_pObject)
42 typedef typename std::conditional<std::is_const<QueriedInterfaceType>::value,
45 typedef typename std::conditional<std::is_const<QueriedInterfaceType>::value,
48 typedef typename std::conditional<std::is_const<QueriedInterfaceType>::value,
50 void*>::type void_pointer;
53 if (
nullptr != i_pObject)
56 QueriedInterfaceType* nRet =
nullptr;
57 const char*
const strIID = get_iid<QueriedInterfaceType*>();
58 base_pointer
const pBase = ucom_cast_to_implicit_cast<interface_type, true>::perform_cast(i_pObject);
59 if ( pBase->GetInterface(strIID,
reinterpret_cast<void_pointer&
>(nRet)).IsOk() )
73 template<
typename QueriedInterfaceType>
74 struct ucom_cast_to_implicit_cast<QueriedInterfaceType, true>
85 template<
typename ObjectType>
86 static typename std::enable_if<detail::has_hierarchy_type<ObjectType>::value,
87 QueriedInterfaceType>::type*
88 perform_cast(ObjectType* i_pObject)
91 return ucom_resolve<QueriedInterfaceType>(i_pObject);
102 template<
typename ObjectType>
103 static typename std::enable_if<!detail::has_hierarchy_type<ObjectType>::value,
104 QueriedInterfaceType>::type*
105 perform_cast(ObjectType* i_pObject)
125 template<
typename InterfacePo
interType,
typename ObjectPo
interType>
126 InterfacePointerType
ucom_cast(ObjectPointerType i_pObject)
128 typedef typename std::remove_pointer<ObjectPointerType>::type object_type;
129 typedef typename std::remove_pointer<InterfacePointerType>::type interface_type;
132 static_assert(std::is_pointer<ObjectPointerType>::value,
133 "ucom_cast<> failed. \"i_pObject\" is not a pointer");
135 std::is_base_of<
IObject,
typename std::remove_const<object_type>::type>::value,
136 "ucom_cast<> failed. \"i_pObject\" does not point to a type derived from IObject");
139 return detail::ucom_cast_to_implicit_cast
141 typename std::conditional
143 std::is_const<object_type>::value,
144 const interface_type,
147 std::is_base_of<interface_type, object_type>::value
148 >::perform_cast(i_pObject);
Base class for every interface type within the uCOM.
InterfacePointerType ucom_cast(ObjectPointerType i_pObject)
Used to cast arbitrary interface types within the UCOM.
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.
Namespace for entire ADTF SDK.