7 #ifndef BASE_D_POINTER_H
8 #define BASE_D_POINTER_H
20 template <
class _PARENT,
class _PRIVATE_D>
25 _PARENT*
_p =
nullptr;
63 return (_PRIVATE_D*)(
this);
70 inline _PRIVATE_D*
Get_d()
const
72 return (_PRIVATE_D*)(
this);
78 inline operator _PRIVATE_D*()
const
80 return (_PRIVATE_D*)(
this);
115 template <
class _PARENT,
class _PRIVATE_D>
153 if (
this != &o_oOther)
189 return (_PRIVATE_D*)(
_dRef);
195 operator _PRIVATE_D*()
const
219 const auto _dRefTmp =
_dRef;
221 o_oOther.
_dRef = _dRefTmp;
236 template<
typename _PARENT,
typename _PRIVATE_D>
256 #define A_UTILS_D_CLASS(__dclassname_, __pclassname_) \
258 class __dclassname_; \
259 A_UTILS_NS::d_ptr<__pclassname_, __dclassname_> _d; \
260 friend class __dclassname_;
270 #define A_UTILS_D(__pclassname_) A_UTILS_D_CLASS(__pclassname_ ## Private, __pclassname_)
277 #define A_UTILS_D_CREATE_CLASS(__classname_) \
278 _d = new __classname_(); \
286 #define A_UTILS_D_CREATE(__classname_) A_UTILS_D_CREATE_CLASS(__classname_ ## Private)
293 #define A_UTILS_DECLARE_LOCAL_D(__classname_) __classname_ ## Private* _D = _d.Get_d()
300 #define A_UTILS_P_DECLARE_CLASS(__d_classname_, __p_classname_) class __p_classname_::__d_classname_ : public A_UTILS_NS::d_ptr_impl<__p_classname_, __p_classname_::__d_classname_>
306 #define A_UTILS_P_DECLARE( __p_classname_) A_UTILS_P_DECLARE_CLASS(__p_classname_ ## Private, __p_classname_)
312 #define A_UTILS_P_CLASS( __p_classname_) __p_classname_::__p_classname_ ## Private
319 #define A_UTILS_P_DECLARE_CLASS_PRE(__d_classname_, __p_classname_) \
320 A_UTILS_P_DECLARE_CLASS(__d_classname_, __p_classname_)\
322 friend class __p_classname_; \
324 __d_classname_(){}; \
325 virtual ~__d_classname_(){}; \
333 #define A_UTILS_P_DECLARE_PRE(__p_classname_) A_UTILS_P_DECLARE_CLASS_PRE(__p_classname_ ## Private, __p_classname_)
void tVoid
The tVoid is always the definition for the void (non-type).
Template to implement the Private class of the global d_pointer definitions.
virtual tVoid Create_d()
Virtual function call to overwrite it something needs to be done on creation time.
virtual tVoid Release_d()
Virtual function call to overwrite it something needs to be done before destroying the object.
_PARENT * _p
the reference to the parent class
d_ptr_impl(d_ptr_impl &&)=delete
moving forbidden
_PRIVATE_D * operator->() const
Overwrites the pointer operator to return the Private class reference.
d_ptr_impl(const d_ptr_impl &)=delete
copying forbidden
_PRIVATE_D * Get_d() const
Gets the Private class reference.
virtual ~d_ptr_impl()
destructor
tVoid Set_p(_PARENT *_pInst)
Sets the parent Reference.
d_ptr_impl()=default
Default constructor.
Template class for the d-pointer Reference class withing the Parent Class.
_PRIVATE_D * operator->() const
Pointer operator enable access to the internal pointer.
tVoid Swap(self_type &o_oOther)
Swap *this d_ptr with another one.
internal_type * _dRef
The internal pointer to the private class.
_PRIVATE_D * Get_d() const
Gets the internal pointer.
d_ptr()=default
Default constructor.
d_ptr_impl< _PARENT, _PRIVATE_D > internal_type
internally held type
virtual ~d_ptr()
Destructor.
self_type * operator=(_PRIVATE_D *_dInst)
Assignment operator allows to set the internal pointer value.
d_ptr< _PARENT, _PRIVATE_D > self_type
self type
tVoid Set_p(_PARENT *_pInst)
Sets the internal pointer.
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
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.