Encapsulation of a pointer with a reference counter. More...
Public Types | |
| using | ThatClass = AutoRef2<T> |
Public Member Functions | |
| AutoRef2 ()=default | |
| Constructs an instance without a reference. | |
| AutoRef2 (T *t) | |
| Constructs an instance referencing t. | |
| AutoRef2 (const ThatClass &from) | |
| Constructs a reference referencing from. | |
| AutoRef2 (ThatClass &&from) noexcept | |
| Constructs a reference referencing from. | |
| ThatClass & | operator= (const ThatClass &from) |
| Copy operator. | |
| ThatClass & | operator= (ThatClass &&from) noexcept |
| Move operator. | |
| ThatClass & | operator= (T *new_value) |
| Assigns the value new_value to the instance. | |
| ~AutoRef2 () | |
| Destructor. Decrements the reference counter of the pointed object. | |
| 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 |
| operator bool () const | |
Private Member Functions | |
| void | _addRef () |
| Adds a reference to the encapsulated object if not null. | |
| void | _removeRef () noexcept |
| Removes a reference to the encapsulated object if not null. | |
| void | _changeValue (T *new_value) |
| Changes the referenced object to new_value. | |
Private Attributes | |
| T * | m_value = nullptr |
| Pointer to the referenced object. | |
Friends | |
| bool | operator== (const ThatClass &a, const ThatClass &b) |
| bool | operator!= (const ThatClass &a, const ThatClass &b) |
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 performs no action based on the reference counter value; the eventual destruction of the object when the reference counter reaches zero is handled by the object itself.
Definition at line 40 of file AutoRef2.h.
| using Arcane::AutoRef2< T >::ThatClass = AutoRef2<T> |
Definition at line 44 of file AutoRef2.h.
|
inlineexplicit |
Constructs an instance referencing t.
Definition at line 51 of file AutoRef2.h.
References _changeValue().
|
inline |
Constructs a reference referencing from.
Definition at line 56 of file AutoRef2.h.
References _changeValue(), and m_value.
|
inlinenoexcept |
Constructs a reference referencing from.
Definition at line 61 of file AutoRef2.h.
|
inline |
Destructor. Decrements the reference counter of the pointed object.
Definition at line 90 of file AutoRef2.h.
References _removeRef().
|
inlineprivate |
Adds a reference to the encapsulated object if not null.
Definition at line 124 of file AutoRef2.h.
References m_value.
Referenced by _changeValue().
|
inlineprivate |
Changes the referenced object to new_value.
Definition at line 136 of file AutoRef2.h.
References _addRef(), _removeRef(), and m_value.
Referenced by AutoRef2(), AutoRef2(), operator=(), and operator=().
|
inlineprivatenoexcept |
Removes a reference to the encapsulated object if not null.
Definition at line 130 of file AutoRef2.h.
References m_value.
Referenced by _changeValue(), operator=(), and ~AutoRef2().
|
inline |
Returns the object referenced by the instance.
Definition at line 107 of file AutoRef2.h.
References m_value.
|
inline |
Definition at line 109 of file AutoRef2.h.
|
inline |
Definition at line 110 of file AutoRef2.h.
|
inline |
Returns the object referenced by the instance.
Definition at line 100 of file AutoRef2.h.
References m_value.
|
inline |
Returns the object referenced by the instance.
Definition at line 93 of file AutoRef2.h.
References m_value.
|
inline |
Copy operator.
Definition at line 68 of file AutoRef2.h.
References _changeValue(), and m_value.
|
inline |
Assigns the value new_value to the instance.
Definition at line 83 of file AutoRef2.h.
References _changeValue().
|
inlinenoexcept |
Move operator.
Definition at line 74 of file AutoRef2.h.
References _removeRef(), and m_value.
|
friend |
Definition at line 116 of file AutoRef2.h.
|
friend |
Definition at line 112 of file AutoRef2.h.
|
private |
Pointer to the referenced object.
Definition at line 147 of file AutoRef2.h.
Referenced by _addRef(), _changeValue(), _removeRef(), AutoRef2(), get(), operator*(), operator->(), operator=(), and operator=().