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

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

#include <arcane/utils/AutoRef.h>

Inheritance diagram for Arcane::AutoRefT< T >:
Collaboration diagram for Arcane::AutoRefT< T >:

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.

Detailed Description

template<class T>
class Arcane::AutoRefT< 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 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.

Definition at line 41 of file AutoRef.h.

Member Typedef Documentation

◆ BaseClass

template<class T>
using Arcane::AutoRefT< T >::BaseClass = PtrT<T>

Base class type.

Definition at line 47 of file AutoRef.h.

Constructor & Destructor Documentation

◆ AutoRefT() [1/2]

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

Constructs an instance referencing t.

Definition at line 57 of file AutoRef.h.

References _changeValue().

Here is the call graph for this function:

◆ AutoRefT() [2/2]

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

Constructs a reference referencing from.

Definition at line 64 of file AutoRef.h.

References _changeValue(), AutoRefT(), and m_value.

Here is the call graph for this function:

◆ ~AutoRefT()

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

Destructor. Decrements the reference counter of the pointed object.

Definition at line 85 of file AutoRef.h.

References _removeRef().

Here is the call graph for this function:

Member Function Documentation

◆ _addRef()

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

Here is the caller graph for this function:

◆ _changeValue()

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

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

◆ _removeRef()

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

Here is the caller graph for this function:

◆ operator=() [1/2]

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

Copy operator.

Definition at line 71 of file AutoRef.h.

References _changeValue(), AutoRefT(), and m_value.

Here is the call graph for this function:

◆ operator=() [2/2]

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

Assigns the value new_value to the instance.

Definition at line 78 of file AutoRef.h.

References _changeValue(), and AutoRefT().

Here is the call graph for this function:

Member Data Documentation

◆ m_value

template<class T>
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=().


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