ADTF
|
Implementation of a weak pointer for usage with iobject_ptr
and object_ptr
.
More...
Public Member Functions | |
weak_object_ptr () | |
Default constructor for empty construction. | |
~weak_object_ptr () | |
Destructs the weak_object_ptr. More... | |
weak_object_ptr (std::nullptr_t) | |
Construct the weak_ptr from a nullptr - for empty construction. | |
weak_object_ptr (const weak_object_ptr &i_oOther) | |
Copy constructor. More... | |
weak_object_ptr & | operator= (weak_object_ptr oOther) |
Assignment operator. More... | |
weak_object_ptr (weak_object_ptr &&oOther) | |
Move constructor. More... | |
template<typename U > | |
weak_object_ptr (const iobject_ptr< U > &i_pOther) | |
Copy construction from an iobject_ptr . More... | |
template<typename U > | |
weak_object_ptr & | operator= (const iobject_ptr< U > &i_pOther) |
Assignment from an iobject_ptr . More... | |
template<typename U > | |
tResult | Reset (const iobject_ptr< U > &i_oOther) |
Reset this weak_object_ptr<> with the content of another iobject_ptr<> More... | |
tResult | Reset (const iobject_ptr< T > &i_oOther) |
Reset this weak_object_ptr<> with the content of another iobject_ptr<> More... | |
void | Reset () |
Reset to an empty weak_ptr object. More... | |
void | Swap (weak_object_ptr &o_oOther) |
Swap content of *this with o_oOther (only shallow copies are performed!) More... | |
object_ptr< T > | Lock () const |
Create an object_ptr<> from *this weak pointer (thread safe). More... | |
Implementation of a weak pointer for usage with iobject_ptr
and object_ptr
.
This weak_ptr<>
implementation is almost exactly according to the standard. Some functionality required by the standard has been left out to focus on the main task - weak counting! For a detailed explanation of a weak pointer implementation, C++-11 reference websites may be consulted.
T | Type of the shared resource the weak reference counting is performed on. |
Definition at line 26 of file weak_object_ptr.h.
|
inline |
Destructs the weak_object_ptr.
Does not have any effect on the shared resource. The weak_count
is decreased by one.
Definition at line 67 of file weak_object_ptr.h.
|
inline |
Copy constructor.
Does not have any effect on the shared count.
[in] | i_oOther | weak_ptr to copy from. |
nullptr
, the weak count of the reference counting object gets increased by one. Definition at line 86 of file weak_object_ptr.h.
|
inline |
Move constructor.
[in] | oOther | weak_object_ptr object to create this from. Will be reset. |
Definition at line 109 of file weak_object_ptr.h.
References weak_object_ptr< T >::Swap().
|
inline |
Copy construction from an iobject_ptr
.
Does not have any effect on the shared count.
U | Type of managed resource - must be ucom_cast castable to object of type T |
[in] | i_pOther | Shared object pointer *this gets created from. |
Definition at line 123 of file weak_object_ptr.h.
|
inline |
Create an object_ptr<>
from *this weak pointer (thread safe).
Does not have any effect on the weak count.
object_ptr<>
referencing the shared resource. Empty object_ptr<>
otherwise. Definition at line 204 of file weak_object_ptr.h.
|
inline |
Assignment from an iobject_ptr
.
Does not have any effect on the shared count.
U | Type of managed resource - must be ucom_cast castable to object of type T |
[in] | i_pOther | Shared object pointer *this gets created from. |
Definition at line 138 of file weak_object_ptr.h.
References weak_object_ptr< T >::weak_object_ptr(), iobject_ptr_base< T >::Get(), and iobject_ptr_base< T >::GetObjPtrRef().
|
inline |
Assignment operator.
Does not have any effect on the shared count.
[in] | oOther | Other weak_object_ptr<> to create this from. Call-by-value is intentional to make use of the copy-swap-idiom and the copy elision. |
nullptr
, the weak count of the reference counting object gets increased by one. Definition at line 99 of file weak_object_ptr.h.
References weak_object_ptr< T >::Swap().
|
inline |
Reset to an empty weak_ptr
object.
Definition at line 179 of file weak_object_ptr.h.
References weak_object_ptr< T >::weak_object_ptr().
|
inline |
Reset this weak_object_ptr<> with the content of another iobject_ptr<>
[in] | i_oOther | Contains the shared object to reset this type with |
i_oOther
manages a valid shared resource, the weak count gets increased by one for this resource ERR_NOERROR | Everything went fine |
Definition at line 168 of file weak_object_ptr.h.
|
inline |
Reset this weak_object_ptr<> with the content of another iobject_ptr<>
[in] | i_oOther | Contains the shared object to reset this type with |
i_oOther
manages a valid shared resource, the weak count gets increased by one for this resource ERR_NOERROR | Everything went fine |
ERR_NO_INTERFACE | Managed resource owned by i_oOther does not expose interface type T . *this is reset to nullptr |
Definition at line 155 of file weak_object_ptr.h.
References iobject_ptr_base< T >::Get().
|
inline |
Swap content of *this with o_oOther
(only shallow copies are performed!)
[in,out] | o_oOther | Other object_ptr object whose content is swapped with *this. |
Definition at line 189 of file weak_object_ptr.h.
Referenced by weak_object_ptr< T >::weak_object_ptr(), and weak_object_ptr< T >::operator=().