Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::Ref< InstanceType > Class Template Reference

Reference to an instance. More...

#include <arccore/base/Ref.h>

Public Member Functions

template<typename T>
 Ref (const Ref< T > &rhs) noexcept
 Constructs a reference from another reference of a compatible type.
 Ref (const ThatClass &rhs)=default
ThatClass & operator= (const ThatClass &rhs)=default
Public Member Functions inherited from Arcane::RefImpl< InstanceType, Ref< InstanceType >, RefTraits< InstanceType >::TagId >
 RefImpl (const Ref< T > &rhs) noexcept
 Constructs a reference from another reference of a compatible type.
 RefImpl (const ThatClass &rhs)=default
ThatClass & operator= (const ThatClass &rhs)=default
 operator bool () const
InstanceType * get () const
 Associated instance or nullptr if none.
bool isNull () const
 Indicates if the counter references a non-null instance.
InstanceType * operator-> () const
void reset ()
 Positions the instance to the null pointer.
InstanceType * _release ()
const ImplType & _internalInstance () const

Static Public Member Functions

static ThatClass create (InstanceType *t)
template<typename PointerType, typename... Args>
static Ref< InstanceType > createRef (Args &&... args)
static ThatClass createWithHandle (InstanceType *t, Internal::ExternalRef handle)
static ThatClass _createNoDestroy (InstanceType *t)

Additional Inherited Members

Public Types inherited from Arcane::RefImpl< InstanceType, Ref< InstanceType >, RefTraits< InstanceType >::TagId >
using ThatClass
using ImplType
Static Public Attributes inherited from Arcane::RefImpl< InstanceType, Ref< InstanceType >, RefTraits< InstanceType >::TagId >
static constexpr int RefType

Detailed Description

template<typename InstanceType>
class Arcane::Ref< InstanceType >

Reference to an instance.

This class uses a reference counter to manage the lifetime of a C++ instance. It works similarly to std::shared_ptr.

When the last instance of this class is destroyed, the referenced instance is destroyed. The way the associated instance is destroyed is specified when creating the first reference via a call to one of the methods create() or createWithHandle().

There are two possible implementations for counting references. By default, 'std::shared_ptr' is used. It is also possible to use an internal reference counter in the class, which allows compatibility with the ReferenceCounter class and also allows retrieving a reference from the instance itself. This second implementation is accessible by specializing the type RefTraits so that it defines a ReferenceCounterTagType equal to ReferenceCounterTag.

Definition at line 323 of file arccore/src/base/arccore/base/Ref.h.

Constructor & Destructor Documentation

◆ Ref()

template<typename InstanceType>
template<typename T>
Arcane::Ref< InstanceType >::Ref ( const Ref< T > & rhs)
inlinenoexcept

Constructs a reference from another reference of a compatible type.

Conversion is allowed if an instance of 'ImplType' can be constructed from an instance of Ref<T>::ImplType.

Definition at line 356 of file arccore/src/base/arccore/base/Ref.h.

Member Function Documentation

◆ _createNoDestroy()

template<typename InstanceType>
ThatClass Arcane::Ref< InstanceType >::_createNoDestroy ( InstanceType * t)
inlinestatic

Definition at line 398 of file arccore/src/base/arccore/base/Ref.h.

◆ create()

template<typename InstanceType>
ThatClass Arcane::Ref< InstanceType >::create ( InstanceType * t)
inlinestatic

Definition at line 375 of file arccore/src/base/arccore/base/Ref.h.

◆ createRef()

template<typename InstanceType>
template<typename PointerType, typename... Args>
Ref< InstanceType > Arcane::Ref< InstanceType >::createRef ( Args &&... args)
inlinestatic

Definition at line 382 of file arccore/src/base/arccore/base/Ref.h.

◆ createWithHandle()

template<typename InstanceType>
ThatClass Arcane::Ref< InstanceType >::createWithHandle ( InstanceType * t,
Internal::ExternalRef< InstanceType > handle )
inlinestatic

Definition at line 393 of file arccore/src/base/arccore/base/Ref.h.


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