trikRuntime
trikKernel::DifferentOwnerPointer< T > Class Template Reference

Smart pointer that can hold two different kinds of pointers: where ownership belongs to someone else and where ownership belongs to this object (some mix of shared pointer and weak pointer). More...

#include <differentOwnerPointer.h>

Public Member Functions

 DifferentOwnerPointer (const DifferentOwnerPointer< T > &other)
 Copy constructor. Preserves ownership semantics of a copied object. More...
 
 DifferentOwnerPointer (T &foreignObject)
 Constructor which takes a reference to object owned by someone else, so we need only to store the reference on it. More...
 
 DifferentOwnerPointer (const QSharedPointer< T > &sharedObject)
 Constructor which takes shared pointer to object and makes DifferentOwnerPointer behave like shared pointer (it is preferred way to pass ownership from object to object to prevent memory leaks if exception will be thrown somewhere before ownership is passed). More...
 
 DifferentOwnerPointer (T *const ownObject)
 Constructor which takes raw pointer and takes ownership over it. More...
 
T * operator-> ()
 Operator that allows to access members of stored object. More...
 
T & operator* ()
 Provides reference to stored object. More...
 
T * data () const
 Returns raw pointer to an object, does not transfer ownership. More...
 
DifferentOwnerPointer< T > & operator= (const DifferentOwnerPointer< T > &other)=default
 Assignment operator to provide value semantics. More...
 

Detailed Description

template<typename T>
class trikKernel::DifferentOwnerPointer< T >

Smart pointer that can hold two different kinds of pointers: where ownership belongs to someone else and where ownership belongs to this object (some mix of shared pointer and weak pointer).

Different constructors provide different behavior.

Constructor & Destructor Documentation

template<typename T>
trikKernel::DifferentOwnerPointer< T >::DifferentOwnerPointer ( const DifferentOwnerPointer< T > &  other)
inline

Copy constructor. Preserves ownership semantics of a copied object.

template<typename T>
trikKernel::DifferentOwnerPointer< T >::DifferentOwnerPointer ( T &  foreignObject)
inlineexplicit

Constructor which takes a reference to object owned by someone else, so we need only to store the reference on it.

template<typename T>
trikKernel::DifferentOwnerPointer< T >::DifferentOwnerPointer ( const QSharedPointer< T > &  sharedObject)
inlineexplicit

Constructor which takes shared pointer to object and makes DifferentOwnerPointer behave like shared pointer (it is preferred way to pass ownership from object to object to prevent memory leaks if exception will be thrown somewhere before ownership is passed).

template<typename T>
trikKernel::DifferentOwnerPointer< T >::DifferentOwnerPointer ( T *const  ownObject)
inlineexplicit

Constructor which takes raw pointer and takes ownership over it.

Member Function Documentation

template<typename T>
T* trikKernel::DifferentOwnerPointer< T >::data ( ) const
inline

Returns raw pointer to an object, does not transfer ownership.

template<typename T>
T& trikKernel::DifferentOwnerPointer< T >::operator* ( )
inline

Provides reference to stored object.

template<typename T>
T* trikKernel::DifferentOwnerPointer< T >::operator-> ( )
inline

Operator that allows to access members of stored object.

template<typename T>
DifferentOwnerPointer<T>& trikKernel::DifferentOwnerPointer< T >::operator= ( const DifferentOwnerPointer< T > &  other)
inlinedefault

Assignment operator to provide value semantics.


The documentation for this class was generated from the following file: