Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::AutoRef2< T > Class Template Reference

Encapsulation of a pointer with a reference counter. More...

#include </__w/arcaneframework.github.io/arcaneframework.github.io/framework/arccore/src/base/arccore/base/AutoRef2.h>

Collaboration diagram for Arcane::AutoRef2< T >:

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)

Detailed Description

template<class T>
class Arcane::AutoRef2< T >

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.

Member Typedef Documentation

◆ ThatClass

template<class T>
using Arcane::AutoRef2< T >::ThatClass = AutoRef2<T>

Definition at line 44 of file AutoRef2.h.

Constructor & Destructor Documentation

◆ AutoRef2() [1/3]

template<class T>
Arcane::AutoRef2< T >::AutoRef2 ( T * t)
inlineexplicit

Constructs an instance referencing t.

Definition at line 51 of file AutoRef2.h.

References _changeValue().

Here is the call graph for this function:

◆ AutoRef2() [2/3]

template<class T>
Arcane::AutoRef2< T >::AutoRef2 ( const ThatClass & from)
inline

Constructs a reference referencing from.

Definition at line 56 of file AutoRef2.h.

References _changeValue(), and m_value.

Here is the call graph for this function:

◆ AutoRef2() [3/3]

template<class T>
Arcane::AutoRef2< T >::AutoRef2 ( ThatClass && from)
inlinenoexcept

Constructs a reference referencing from.

Definition at line 61 of file AutoRef2.h.

◆ ~AutoRef2()

template<class T>
Arcane::AutoRef2< T >::~AutoRef2 ( )
inline

Destructor. Decrements the reference counter of the pointed object.

Definition at line 90 of file AutoRef2.h.

References _removeRef().

Here is the call graph for this function:

Member Function Documentation

◆ _addRef()

template<class T>
void Arcane::AutoRef2< T >::_addRef ( )
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().

Here is the caller graph for this function:

◆ _changeValue()

template<class T>
void Arcane::AutoRef2< T >::_changeValue ( T * new_value)
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=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _removeRef()

template<class T>
void Arcane::AutoRef2< T >::_removeRef ( )
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().

Here is the caller graph for this function:

◆ get()

template<class T>
T * Arcane::AutoRef2< T >::get ( ) const
inline

Returns the object referenced by the instance.

Definition at line 107 of file AutoRef2.h.

References m_value.

◆ isNull()

template<class T>
bool Arcane::AutoRef2< T >::isNull ( ) const
inline

Definition at line 109 of file AutoRef2.h.

◆ operator bool()

template<class T>
Arcane::AutoRef2< T >::operator bool ( ) const
inline

Definition at line 110 of file AutoRef2.h.

◆ operator*()

template<class T>
T & Arcane::AutoRef2< T >::operator* ( ) const
inline

Returns the object referenced by the instance.

Definition at line 100 of file AutoRef2.h.

References m_value.

◆ operator->()

template<class T>
T * Arcane::AutoRef2< T >::operator-> ( ) const
inline

Returns the object referenced by the instance.

Definition at line 93 of file AutoRef2.h.

References m_value.

◆ operator=() [1/3]

template<class T>
ThatClass & Arcane::AutoRef2< T >::operator= ( const ThatClass & from)
inline

Copy operator.

Definition at line 68 of file AutoRef2.h.

References _changeValue(), and m_value.

Here is the call graph for this function:

◆ operator=() [2/3]

template<class T>
ThatClass & Arcane::AutoRef2< T >::operator= ( T * new_value)
inline

Assigns the value new_value to the instance.

Definition at line 83 of file AutoRef2.h.

References _changeValue().

Here is the call graph for this function:

◆ operator=() [3/3]

template<class T>
ThatClass & Arcane::AutoRef2< T >::operator= ( ThatClass && from)
inlinenoexcept

Move operator.

Definition at line 74 of file AutoRef2.h.

References _removeRef(), and m_value.

Here is the call graph for this function:

◆ operator!=

template<class T>
bool operator!= ( const ThatClass & a,
const ThatClass & b )
friend

Definition at line 116 of file AutoRef2.h.

◆ operator==

template<class T>
bool operator== ( const ThatClass & a,
const ThatClass & b )
friend

Definition at line 112 of file AutoRef2.h.

Member Data Documentation

◆ m_value

template<class T>
T* Arcane::AutoRef2< T >::m_value = nullptr
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=().


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