ADTF
object_ptr_intf.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_UCOM_ANT_OBJECT_PTR_INTERFACE_HEADER_
8 #define _ADTF_UCOM_ANT_OBJECT_PTR_INTERFACE_HEADER_
9 
10 namespace adtf
11 {
12 namespace ucom
13 {
14 namespace ant
15 {
16 
21 template<typename T>
22 class DOEXPORT iobject_ptr_base
23 {
24 public: //types
25  typedef T element_type;
26 
27 protected: //construction/destruction
29  ~iobject_ptr_base() = default;
30 
31 public: //observer
36  virtual T* Get() const = 0;
37 
48  virtual tResult Reset(const iobject_ptr<T>& i_oOther) = 0;
49 
54  virtual T* operator->() const = 0;
55 
56 private:
57  template<typename> friend class object_ptr;
58  template<typename> friend class weak_object_ptr;
59  template<typename, typename> friend class detail::delegate_object_ptr_resetter;
60 
65  virtual detail::iobject_ptr_ref<size_t>* GetObjPtrRef() const = 0;
66 };//class iobject_ptr_base<>
67 
72 template<typename T>
73 class DOEXPORT iobject_ptr : public iobject_ptr_base<T>
74 {
75 protected: //construction/destruction
77  ~iobject_ptr() = default;
78 
79 public:
80  typedef IObject object_type;
81 
86  virtual operator const iobject_ptr<const T>& () const = 0;
87 };//class iobject_ptr<T>
88 
95 template<typename T>
96 class DOEXPORT iobject_ptr<const T> : public iobject_ptr_base<const T>
97 {
98 protected: //construction/destruction
100  ~iobject_ptr() = default;
101 
102 public:
103  typedef const IObject object_type;
104 };//class iobject_ptr<const T>
105 
106 //#################################################################################################
107 //############################### Comparison Operators ############################################
108 //#################################################################################################
109 
118 template <typename T, typename U>
119 bool operator==(const iobject_ptr<T>& i_oLHS, const U* i_pRHS)
120 {
121  return i_oLHS.Get() == i_pRHS;
122 }
123 
132 template <typename T, typename U>
133 bool operator==(const T* i_pLHS, const iobject_ptr<U>& i_oRHS)
134 { //call previous defined operator
135  return operator==(i_oRHS, i_pLHS);
136 }
137 
146 template< typename T, typename U>
147 bool operator!=(const iobject_ptr<T>& i_oLHS, const U* i_pRHS)
148 {
149  return !operator==(i_oLHS, i_pRHS);
150 }
151 
160 template< typename T, typename U>
161 bool operator!=(const T* i_pLHS, const iobject_ptr<U>& i_oRHS)
162 {
163  return !operator==(i_pLHS, i_oRHS);
164 }
165 
174 template < typename T, typename U >
175 bool operator==( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
176 {
177  return i_oLHS.Get() == i_oRHS.Get();
178 }
179 
188 template< typename T, typename U >
189 bool operator!=( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
190 {
191  return !operator==(i_oLHS, i_oRHS);
192 }
193 
202 template< typename T, typename U >
203 bool operator<( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
204 {
205  typedef typename std::common_type<T*, U*>::type common_pointer_type;
206  return std::less<common_pointer_type>()(i_oLHS.Get(), i_oRHS.Get());
207 }
208 
217 template< typename T, typename U >
218 bool operator>( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
219 {
220  return operator<(i_oRHS, i_oLHS);
221 }
222 
231 template< typename T, typename U >
232 bool operator<=( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
233 {
234  return !operator>(i_oLHS, i_oRHS);
235 }
236 
245 template< typename T, typename U >
246 bool operator>=( const iobject_ptr<T>& i_oLHS, const iobject_ptr<U>& i_oRHS )
247 {
248  return !operator<(i_oLHS, i_oRHS);
249 }
250 
257 template< typename T >
258 bool operator==( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
259 {
260  return !i_oLHS.Get();
261 }
262 
269 template< typename T >
270 bool operator==( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
271 {
272  return i_oRHS == nullptr;
273 }
274 
281 template< typename T >
282 bool operator!=( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
283 {
284  return nullptr != i_oLHS.Get();
285 }
286 
293 template< typename T >
294 bool operator!=( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
295 {
296  return i_oRHS != nullptr;
297 }
298 
305 template< typename T >
306 bool operator<( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
307 {
308  return std::less<T*>()(i_oLHS.Get(), nullptr);
309 }
310 
317 template< typename T >
318 bool operator<( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
319 {
320  return std::less<T*>()(nullptr, i_oRHS.Get());
321 }
322 
329 template< typename T >
330 bool operator<=( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
331 {
332  return !operator<(nullptr, i_oLHS);
333 }
334 
341 template< typename T >
342 bool operator<=( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
343 {
344  return !operator<(i_oRHS, nullptr);
345 }
346 
353 template< typename T >
354 bool operator>( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
355 {
356  return operator<(nullptr, i_oLHS);
357 }
358 
365 template< typename T >
366 bool operator>( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
367 {
368  return operator<(i_oRHS, nullptr);
369 }
370 
377 template< typename T >
378 bool operator>=( const iobject_ptr<T>& i_oLHS, std::nullptr_t )
379 {
380  return !operator<(i_oLHS, nullptr);
381 }
382 
389 template< typename T >
390 bool operator>=( std::nullptr_t, const iobject_ptr<T>& i_oRHS )
391 {
392  return !operator<(nullptr, i_oRHS);
393 }
394 
395 }//ns ant
396 
398 template<class T>
400 
401 }//ns ucom
402 }//ns adtf
403 
404 #endif //_ADTF_UCOM_ANT_OBJECT_PTR_INTERFACE_HEADER_
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
Base object pointer to realize binary compatible reference counting in interface methods.
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 detail::iobject_ptr_ref< size_t > * GetObjPtrRef() const =0
Get the reference counter.
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.
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
~iobject_ptr()=default
Destructor.
IObject object_type
Provided for single point of const correct type access.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Implementation of a weak pointer for usage with iobject_ptr and object_ptr.
bool operator>(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Greater-than 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-or-equal operator for forward_iterator.
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
Inequality operator for forward_iterator.
bool operator==(const forward_iterator< T > &oLHS, const forward_iterator< T > &oRHS) noexcept
Equality operator for forward_iterator.
Namespace for entire ADTF SDK.