ADTF  3.13.2
object_ptr< T >

Object pointer implementation used for reference counting on objects of type IObject. More...

Inheritance diagram for object_ptr< T >:
[legend]

Public Member Functions

 object_ptr ()
 Default constructor - the object_ptr<T> is created empty.
 
virtual ~object_ptr ()=default
 default destruction
 
 object_ptr (std::nullptr_t)
 nullptr_t construction - the object_ptr<T> is created empty
 
 object_ptr (const object_ptr &i_oOther)
 Copy constructor. More...
 
 object_ptr (const iobject_ptr< T > &i_oOther)
 Copy constructor for base type. More...
 
template<typename U >
 object_ptr (const iobject_ptr< U > &i_oOther)
 Copy constructor for iobject_ptr containing a different type. More...
 
template<typename U >
 object_ptr (const iobject_ptr< U > &i_oOther, T *pSharedObject)
 Aliasing constructor for iobject_ptr containing a different type. More...
 
 object_ptr (object_ptr &&i_oOther)
 Move constructor. More...
 
template<typename U >
 object_ptr (const weak_object_ptr< U > &i_pWeak)
 Construct from weak_object_ptr<> More...
 
object_ptroperator= (object_ptr i_oOther)
 Assignment operator. More...
 
template<typename U >
object_ptroperator= (const object_ptr< U > &i_oOther)
 Assignment operator for object_ptr containing a different type. More...
 
T & operator* () const
 Operator* overload to treat object_ptr<> types like real pointers. More...
 
 operator tBool () const
 Conversion to bool. More...
 
tVoid Reset ()
 Reset this object_ptr. More...
 
tVoid Swap (object_ptr &o_oOther)
 Swap content of *this with o_oOther (only shallow copies are performed!) More...
 
virtual T * Get () const
 Get pointer to shared object. More...
 
virtual T * operator-> () const
 Operator-> overload to treat object_ptr<> types like real pointers. More...
 
virtual tResult Reset (const iobject_ptr< T > &i_oOther)
 Reset this object_ptr<> with the content of another iobject_ptr<> More...
 

Detailed Description

template<typename T>
class adtf::ucom::ant::object_ptr< T >

Object pointer implementation used for reference counting on objects of type IObject.

To pass reference counted objects between binary boundaries the iobject_ptr is provided. This object_ptr implements the interface of iobject_ptr and can thus be used to manage pointers to concrete implementations of IObject types. In particular two implicit conversions of object_ptr<T> are available: The first one being to iobject_ptr<T> due to its inheritance. The second one being to iobject_ptr<IObject>& or const iobject_ptr<IObject> to address the frequent calls to excatly these types in provided interfaces.

Template Parameters
TConcrete type derived from IObject. If the type doesn't implement ADTF_IID(), no implicit conversion to the non const version of base type iobject_ptr<IObject> is available.
Note
The only way to instantiate an object_ptr with a concrete object of type T is to use free function make_object_ptr().

Definition at line 157 of file object_ptr.h.

Constructor & Destructor Documentation

◆ object_ptr() [1/6]

object_ptr ( const object_ptr< T > &  i_oOther)
inline

Copy constructor.

Parameters
[in]i_oOtherobject_ptr to create this from. Reference count is increased by one

Definition at line 245 of file object_ptr.h.

◆ object_ptr() [2/6]

object_ptr ( const iobject_ptr< T > &  i_oOther)
inline

Copy constructor for base type.

Parameters
[in]i_oOtheriobject_ptr to create this from. Reference count is increased by one

Definition at line 254 of file object_ptr.h.

◆ object_ptr() [3/6]

object_ptr ( const iobject_ptr< U > &  i_oOther)
inline

Copy constructor for iobject_ptr containing a different type.

Template Parameters
UContained type of i_oOther that must be castable using ucom_cast<> to type T
Parameters
[in]i_oOtheriobject_ptr to create this from. Reference count will be increased by one

Definition at line 265 of file object_ptr.h.

◆ object_ptr() [4/6]

object_ptr ( const iobject_ptr< U > &  i_oOther,
T *  pSharedObject 
)
inline

Aliasing constructor for iobject_ptr containing a different type.

Template Parameters
UContained type of i_oOther that must be castable using ucom_cast<> to type T
Parameters
[in]i_oOtheriobject_ptr to create this from. Reference count will be increased by one
[in]pSharedObjectPointer to the actual shared object

Definition at line 277 of file object_ptr.h.

◆ object_ptr() [5/6]

object_ptr ( object_ptr< T > &&  i_oOther)
inline

Move constructor.

Parameters
[in]i_oOtherobject_ptr to create this from. Will be reset.

Definition at line 286 of file object_ptr.h.

◆ object_ptr() [6/6]

object_ptr ( const weak_object_ptr< U > &  i_pWeak)
inline

Construct from weak_object_ptr<>

Template Parameters
UType of the managed resource by the weak_ptr. Must be implicitely castable to type T.
Parameters
[in]i_pWeakweak pointer object to create *this from.
Postcondition
If i_pWeak holds a valid reference to the shared resource, the shared count is increased by one. There is no effect on the weak count.

Definition at line 300 of file object_ptr.h.

Member Function Documentation

◆ Get()

◆ operator tBool()

operator tBool ( ) const
inlineexplicit

Conversion to bool.

Returns
this->Get() != nullptr

Definition at line 345 of file object_ptr.h.

◆ operator*()

T& operator* ( ) const
inline

Operator* overload to treat object_ptr<> types like real pointers.

Returns
Reference to the contained shared object.

Definition at line 336 of file object_ptr.h.

◆ operator->()

virtual T* operator-> ( ) const
inlinevirtual

Operator-> overload to treat object_ptr<> types like real pointers.

Returns
Pointer to shared object

Definition at line 385 of file object_ptr.h.

◆ operator=() [1/2]

object_ptr& operator= ( object_ptr< T >  i_oOther)
inline

Assignment operator.

Parameters
[in]i_oOtherOther object_ptr<> to create this from. Call-by-value is intentional to make use of the copy-swap-idiom and the copy elision.
Postcondition
If pointer to the shared object is not nullptr, the shared count of the reference counting object gets increased by one.
Returns
Reference to *this.

Definition at line 313 of file object_ptr.h.

◆ operator=() [2/2]

object_ptr& operator= ( const object_ptr< U > &  i_oOther)
inline

Assignment operator for object_ptr containing a different type.

Template Parameters
UContained type of i_oOther that must be castable using ucom_cast<> to type T
Parameters
[in]i_oOtherobject_ptr to create this from. Reference count will be increased by one
Returns
Reference to *this.

Definition at line 326 of file object_ptr.h.

◆ Reset() [1/2]

tVoid Reset ( )
inline

Reset this object_ptr.

Postcondition
!static_cast<tBool>(*this);
If one object was managed, the reference count for this object gets decreased by one.
Returns
Nothing

Definition at line 356 of file object_ptr.h.

Referenced by cSampleWriter::EndStreaming(), adtf::services::ant::get_recorder(), sample_data< T >::Reset(), cStreamItem::SetSample(), and cStreamItem::SetStreamType().

◆ Reset() [2/2]

virtual tResult Reset ( const iobject_ptr< T > &  i_oOther)
inlinevirtual

Reset this object_ptr<> with the content of another iobject_ptr<>

Parameters
[in]i_oOtherContains the shared object to reset this type with
Postcondition
Reference counter increases by one. If another object is already managed, the reference count for this object gets decreased by one.
Return values
ERR_NOERROREverything went fine

Definition at line 397 of file object_ptr.h.

◆ Swap()

tVoid Swap ( object_ptr< T > &  o_oOther)
inline

Swap content of *this with o_oOther (only shallow copies are performed!)

Parameters
[in,out]o_oOtherOther object_ptr object whose content is swapped with *this.
Returns
Nothing

Definition at line 366 of file object_ptr.h.

Referenced by object_ptr< const adtf::streaming::ant::IStreamType >::object_ptr(), and object_ptr< const adtf::streaming::ant::IStreamType >::operator=().


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Tue Nov 16 2021 by doxygen 1.8.14)