Encapsulation of a pointer with a reference counter. More...
#include <arcane/utils/AutoRef.h>
Public Types | |
| using | BaseClass = PtrT<T> |
| Base class type. | |
Public Member Functions | |
| AutoRefT ()=default | |
| Constructs an instance without a reference. | |
| AutoRefT (T *t) | |
| Constructs an instance referencing t. | |
| AutoRefT (const AutoRefT< T > &from) | |
| Constructs a reference referencing from. | |
| AutoRefT< T > & | operator= (const AutoRefT< T > &from) |
| Copy operator. | |
| AutoRefT< T > & | operator= (T *new_value) |
| Assigns the value new_value to the instance. | |
| ~AutoRefT () | |
| Destructor. Decrements the reference counter of the pointed object. | |
| Public Member Functions inherited from Arcane::PtrT< T > | |
| PtrT ()=default | |
| Constructs an instance without a reference. | |
| PtrT (T *t) | |
| Constructs an instance referring to t. | |
| T * | operator-> () const |
| Returns the object referenced by the instance. | |
| T & | operator* () const |
| Returns the object referenced by the instance. | |
| T * | get () const |
| Returns the object referenced by the instance. | |
| bool | isNull () const |
Public Attributes | |
| T * | m_value |
| Pointer to the referenced object. | |
Private Member Functions | |
| void | _addRef () |
| Adds a reference to the encapsulated object if not null. | |
| void | _removeRef () |
| Removes a reference to the encapsulated object if not null. | |
| void | _changeValue (T *new_value) |
| Changes the referenced object to new_value. | |
Additional Inherited Members | |
| Protected Member Functions inherited from Arcane::PtrT< T > | |
| PtrT< T > & | operator= (const PtrT< T > &from) |
| Copy operator. | |
| template<typename T2> | |
| PtrT< T > & | operator= (const PtrT< T2 > &from) |
| PtrT< T > & | operator= (T *new_value) |
| Assigns the value new_value to the instance. | |
| PtrT (const PtrT< T > &from) | |
| Constructs a reference referring to from. | |
| template<typename T2> | |
| PtrT (const PtrT< T2 > &from) | |
| Constructs a reference referring to from. | |
| Protected Attributes inherited from Arcane::PtrT< T > | |
| T * | m_value = nullptr |
| Pointer to the referenced object. | |
Encapsulation of a pointer with a reference counter.
This class encapsulates a pointer of a type that implements the methods of the abstract class ISharedReference (the template parameter does not need to derive from this class) and increments (_addRef()) or decrements (_removeRef()) the reference counter of the pointed element during successive assignments. This class does not perform any action based on the value of the reference counter; the eventual destruction of the object when the reference counter reaches zero is handled by the object itself.
| using Arcane::AutoRefT< T >::BaseClass = PtrT<T> |
|
inlineexplicit |
Constructs an instance referencing t.
Definition at line 57 of file AutoRef.h.
References _changeValue().
|
inline |
Constructs a reference referencing from.
Definition at line 64 of file AutoRef.h.
References _changeValue(), AutoRefT(), and m_value.
|
inline |
Destructor. Decrements the reference counter of the pointed object.
Definition at line 85 of file AutoRef.h.
References _removeRef().
|
inlineprivate |
Adds a reference to the encapsulated object if not null.
Definition at line 90 of file AutoRef.h.
References m_value.
Referenced by _changeValue().
|
inlineprivate |
Changes the referenced object to new_value.
Definition at line 104 of file AutoRef.h.
References _addRef(), _removeRef(), and m_value.
Referenced by AutoRefT(), AutoRefT(), operator=(), and operator=().
|
inlineprivate |
Removes a reference to the encapsulated object if not null.
Definition at line 97 of file AutoRef.h.
References m_value.
Referenced by _changeValue(), and ~AutoRefT().
|
inline |
Copy operator.
Definition at line 71 of file AutoRef.h.
References _changeValue(), AutoRefT(), and m_value.
|
inline |
Assigns the value new_value to the instance.
Definition at line 78 of file AutoRef.h.
References _changeValue(), and AutoRefT().
| T* Arcane::PtrT< T >::m_value |
Pointer to the referenced object.
Definition at line 128 of file Ptr.h.
Referenced by _addRef(), _changeValue(), _removeRef(), AutoRefT(), and operator=().