23template<
typename StorageType>
24class object_ptr_storage
31 constexpr object_ptr_storage(::std::nullptr_t)
noexcept: object_ptr_storage()
35 object_ptr_storage(iobject_ptr_ref<size_t>* pControlBlock,
36 StorageType* pSharedObject,
37 bool bFromWeak =
false)
noexcept:
44 if (!
m_pRefer->IncreaseUseCountNonZero())
57 object_ptr_storage(
const object_ptr_storage& oOther)
noexcept:
58 object_ptr_storage(oOther.GetObjPtrRef(), oOther.GetStorageObject())
63 typename ConstCompatible = ::std::enable_if_t<::std::is_const_v<StorageType> || !::std::is_const_v<U>>>
70 typename ConstCompatible = ::std::enable_if_t<std::is_const_v<StorageType> || !::std::is_const_v<U>>>
77 object_ptr_storage(oOther.GetObjPtrRef(), oOther.Get())
84 object_ptr_storage(i_oOther.GetObjPtrRef(), pSharedObject)
93 constexpr detail::iobject_ptr_ref<size_t>* GetObjPtrRef() const noexcept
98 constexpr StorageType* GetStorageObject() const noexcept
103 object_ptr_storage& operator=(
const object_ptr_storage& oOther)
105 object_ptr_storage oHelper(oOther);
110 object_ptr_storage& operator=(object_ptr_storage&& oOther)
127 pOrphanedBlock->DecreaseUseCount();
131 void Swap(object_ptr_storage& oOther)
noexcept
24class object_ptr_storage {
…};
143template<
typename StorageType>
145template<
typename StorageType>
147template<
typename T,
typename StorageType>
149template<
typename T,
typename StorageType>
152template<
typename T,
typename StorageType>
153using object_ptr_base =
154 typename ::std::conditional_t<::std::is_same_v<std::remove_const_t<T>,
IObject>,
155 ::std::conditional_t<::std::is_const_v<T>,
158 ::std::conditional_t<::std::is_const_v<T>,
162template<
typename T,
typename StorageType>
165 static_assert(!::std::is_volatile_v<T> && !::std::is_reference_v<T>);
166 static_assert(!::std::is_volatile_v<StorageType> && !::std::is_reference_v<StorageType>);
167 static_assert(::std::is_const_v<T> || !::std::is_const_v<StorageType>,
168 "Can't enable non-const interface for a const storage type");
171 template<
typename... Args>
172 object_ptr_delegate_base(Args&&... args)
noexcept: m_oDelegate(::std::forward<Args>(args)...)
176 object_ptr_delegate_base(
const object_ptr_delegate_base& oOther)
noexcept:
177 object_ptr_delegate_base(oOther, oOther.GetStorageObject())
181 object_ptr_delegate_base(object_ptr_delegate_base&& oOther)
noexcept: object_ptr_delegate_base()
186 ~object_ptr_delegate_base() =
default;
188 constexpr detail::iobject_ptr_ref<size_t>* GetObjPtrRef()
const noexcept final override
190 return m_oDelegate.GetObjPtrRef();
193 constexpr StorageType* GetStorageObject()
const noexcept
195 return m_oDelegate.GetStorageObject();
198 T*
Get() const final
override
200 if constexpr (::std::is_same_v<T, StorageType>)
202 return GetStorageObject();
198 T*
Get() const final
override {
…}
215 T& operator*() const noexcept
220 void Swap(object_ptr_delegate_base& oOther)
noexcept
222 m_oDelegate.Swap(oOther.m_oDelegate);
238 else if constexpr (::std::is_same_v<T, StorageType>)
240 object_ptr_base<T, StorageType> oHelper(oOther);
244 else if constexpr (::std::is_same_v<std::remove_const_t<T>,
IObject> &&
245 ::std::is_const_v<StorageType> == ::std::is_const_v<T> &&
246 has_interface_info_type<::std::remove_const_t<StorageType>>::value)
255 object_ptr_base<T, StorageType> oHelper(oOther, pObject);
267 m_oDelegate = oOther.m_oDelegate;
271 object_ptr_delegate_base& operator=(object_ptr_delegate_base&& oOther)
273 m_oDelegate = ::std::move(oOther.m_oDelegate);
277 constexpr explicit operator bool() const noexcept
279 return (GetStorageObject() !=
nullptr);
283 ::std::conditional_t<::std::is_same_v<std::remove_const_t<T>,
IObject>,
284 std::conditional_t<!::std::is_const_v<T> && !::std::is_const_v<StorageType>,
285 object_ptr_const_iobject_delegate<StorageType>,
286 object_ptr_storage<StorageType>>,
287 std::conditional_t<::std::is_const_v<T> || ::std::is_const_v<StorageType>,
288 ::std::conditional_t<::std::is_const_v<StorageType>,
289 object_ptr_const_iobject_delegate<StorageType>,
290 object_ptr_iobject_delegate<StorageType>>,
291 object_ptr_const_delegate<const T, StorageType>>>
295template<
typename StorageType>
299 using object_ptr_delegate_base<
const IObject, StorageType>::object_ptr_delegate_base;
302template<
typename StorageType>
305 using base = object_ptr_delegate_base<IObject, StorageType>;
311 return base::m_oDelegate;
315template<
typename T,
typename StorageType>
318 static_assert(::std::is_const_v<T> && !::std::is_same_v<T, const IObject>);
320 using base = object_ptr_delegate_base<T, StorageType>;
326 return base::m_oDelegate;
329 template<
typename U,
typename = ::std::enable_if_t<::std::is_same_v<U, IObject> && !::std::is_const_v<StorageType>>>
332 return base::m_oDelegate;
336 typename = std::enable_if_t<(::std::is_same_v<U, const IObject> && ::std::is_const_v<StorageType>) ||
337 (::std::is_same_v<U, IObject> && !::std::is_const_v<StorageType>)>>
340 return base::m_oDelegate;
344template<
typename T,
typename StorageType>
347 static_assert(!::std::is_const_v<T> && !::std::is_same_v<T, IObject>);
348 using base = object_ptr_delegate_base<T, StorageType>;
354 return base::m_oDelegate;
359 return base::m_oDelegate;
364 return base::m_oDelegate;
369 return base::m_oDelegate;
378 using base = detail::object_ptr_base<T, T>;
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
#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.
Base class for every interface type within the uCOM.
tResult Reset(const iobject_ptr< T > &oOther) noexcept final override
Reset this object_ptr<> with the content of another iobject_ptr<>
T * operator->() const noexcept final override
Operator-> overload to treat object_ptr<> types like real pointers.
T * Get() const final override
Get raw pointer to shared object.
detail::iobject_ptr_ref< size_t > * m_pRefer
Refer to control the weak counting.
object_ptr_storage(const iobject_ptr< U > &i_oOther, StorageType *pSharedObject) noexcept
Aliasing constructor.
StorageType * m_pObject
The managed object.
Base object pointer to realize binary compatible reference counting in interface methods.
Implementation of a weak pointer for usage with iobject_ptr and object_ptr.
T * m_pObject
The managed object.
detail::iobject_ptr_ref< size_type > * m_pRefer
Refer to control the weak counting.
tVoid swap(A_UTILS_NS::d_ptr< _PARENT, _PRIVATE_D > &i_oLHS, A_UTILS_NS::d_ptr< _PARENT, _PRIVATE_D > &i_oRHS)
std::swap specialization for AUTILSDPtr for perfect fit on ADL
Namespace for all internally used uCOM functionality implemented.
Namespace for all functionality provided since v3.0.
const char * get_iid()
Get the interface id (IID) of the Interface type.
InterfacePointerType ucom_cast(ObjectPointerType i_pObject)
Used to cast arbitrary interface types within the UCOM.
Namespace for the ADTF uCOM3 SDK.
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
ant::IObject IObject
Alias always bringing the latest version of ant::IObject into scope.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
#define RETURN_IF_THROWS(s)
if the expression throws an exception, returns a tResult containing the exception information.