ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
object_ptr_intf.h
Go to the documentation of this file.
1
7#pragma once
8
10#include <a_utils/core/result.h>
11
12#include <cstddef>
13#include <type_traits>
14
15namespace adtf
16{
17namespace ucom
18{
19namespace ant
20{
21
22template<typename T> class iobject_ptr;
23
25namespace detail
26{
27
31template<typename TSize>
32class DOEXPORT iobject_ptr_ref
33{
34protected: // types
35 typedef TSize size_type;
36
37protected: // construction/destruction
39 ~iobject_ptr_ref() = default;
40
41public:
42 virtual void IncreaseUseCount() = 0;
43 virtual void DecreaseUseCount() = 0;
44
45 virtual void IncreaseWeakCount() = 0;
46 virtual void DecreaseWeakCount() = 0;
47
48 virtual bool IncreaseUseCountNonZero() = 0;
49}; // class iobject_ptr_ref
50
51} // namespace detail
53
58template<typename T>
59class DOEXPORT iobject_ptr_base
60{
61public: // types
62 typedef T element_type;
63
64protected: // construction/destruction
66 ~iobject_ptr_base() = default;
67
68public: // observer
73 virtual T* Get() const = 0;
74
85 virtual tResult Reset(const iobject_ptr<T>& i_oOther) = 0;
86
91 virtual T* operator->() const = 0;
92
93 virtual detail::iobject_ptr_ref<size_t>* GetObjPtrRef() const = 0;
94
95}; // class iobject_ptr_base<>
96
101template<typename T>
102class DOEXPORT iobject_ptr : public iobject_ptr_base<T>
103{
104protected: // construction/destruction
106 ~iobject_ptr() = default;
107
108public:
110
115 virtual operator const iobject_ptr<const T>&() const = 0;
116}; // class iobject_ptr<T>
117
124template<typename T>
125class DOEXPORT iobject_ptr<const T> : public iobject_ptr_base<const T>
126{
127protected: // construction/destruction
129 ~iobject_ptr() = default;
130
131public:
132 typedef const IObject object_type;
133}; // class iobject_ptr<const T>
134
135// #################################################################################################
136// ############################### Comparison Operators ############################################
137// #################################################################################################
138
147template<typename T, typename U>
148bool operator==(const iobject_ptr<T>& i_oLHS, const U* i_pRHS)
149{
150 return i_oLHS.Get() == i_pRHS;
151}
152
161template<typename T, typename U>
162bool operator==(const T* i_pLHS, const iobject_ptr<U>& i_oRHS)
163{ // call previous defined operator
164 return operator==(i_oRHS, i_pLHS);
165}
166
175template<typename T, typename U>
176bool operator!=(const iobject_ptr<T>& i_oLHS, const U* i_pRHS)
177{
178 return !operator==(i_oLHS, i_pRHS);
179}
180
189template<typename T, typename U>
190bool operator!=(const T* i_pLHS, const iobject_ptr<U>& i_oRHS)
191{
192 return !operator==(i_pLHS, i_oRHS);
193}
194
203template<typename T, typename U>
204bool operator==(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
205{
206 return i_oLHS.Get() == i_oRHS.Get();
207}
208
217template<typename T, typename U>
218bool operator!=(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
219{
220 return !operator==(i_oLHS, i_oRHS);
221}
222
231template<typename T, typename U>
232bool operator<(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
233{
234 typedef typename std::common_type<T*, U*>::type common_pointer_type;
235 return std::less<common_pointer_type>()(i_oLHS.Get(), i_oRHS.Get());
236}
237
246template<typename T, typename U>
247bool operator>(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
248{
249 return operator<(i_oRHS, i_oLHS);
250}
251
260template<typename T, typename U>
261bool operator<=(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
262{
263 return !operator>(i_oLHS, i_oRHS);
264}
265
274template<typename T, typename U>
275bool operator>=(const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS)
276{
277 return !operator<(i_oLHS, i_oRHS);
278}
279
286template<typename T>
287bool operator==(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
288{
289 return !i_oLHS.Get();
290}
291
298template<typename T>
299bool operator==(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
300{
301 return i_oRHS == nullptr;
302}
303
310template<typename T>
311bool operator!=(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
312{
313 return nullptr != i_oLHS.Get();
314}
315
322template<typename T>
323bool operator!=(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
324{
325 return i_oRHS != nullptr;
326}
327
334template<typename T>
335bool operator<(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
336{
337 return std::less<T*>()(i_oLHS.Get(), nullptr);
338}
339
346template<typename T>
347bool operator<(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
348{
349 return std::less<T*>()(nullptr, i_oRHS.Get());
350}
351
358template<typename T>
359bool operator<=(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
360{
361 return !operator<(nullptr, i_oLHS);
362}
363
370template<typename T>
371bool operator<=(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
372{
373 return !operator<(i_oRHS, nullptr);
374}
375
382template<typename T>
383bool operator>(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
384{
385 return operator<(nullptr, i_oLHS);
386}
387
394template<typename T>
395bool operator>(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
396{
397 return operator<(i_oRHS, nullptr);
398}
399
406template<typename T>
407bool operator>=(const iobject_ptr<T>& i_oLHS, std::nullptr_t)
408{
409 return !operator<(i_oLHS, nullptr);
410}
411
418template<typename T>
419bool operator>=(std::nullptr_t, const iobject_ptr<T>& i_oRHS)
420{
421 return !operator<(nullptr, i_oRHS);
422}
423
424} // namespace ant
425
427template<class T>
429
430} // namespace ucom
431} // namespace adtf
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Base class for every interface type within the uCOM.
Definition object_intf.h:33
const IObject object_type
Provided for single point of const correct type access.
Base class for iobject_ptr<T> defining their commonly used interface methods.
virtual T * Get() const =0
Get raw pointer to shared object.
virtual T * operator->() const =0
Operator-> overload to treat object_ptr<> types like real pointers.
~iobject_ptr_base()=default
Destructor.
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
T element_type
Contained type to manage an object of.
Base object pointer to realize binary compatible reference counting in interface methods.
~iobject_ptr()=default
Destructor.
Namespace for all internally used uCOM functionality implemented.
Namespace for all functionality provided since v3.0.
bool operator<=(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Less-than-or-equal operator for forward_iterator.
bool operator>=(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Greater-than-or-equal operator for forward_iterator.
bool operator!=(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Inequality operator for forward_iterator.
bool operator==(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Equality operator for forward_iterator.
bool operator<(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Less-than operator for forward_iterator.
bool operator>(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Greater-than operator for forward_iterator.
Namespace for the ADTF uCOM3 SDK.
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.