Reference to an instance. More...
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 () |
| Releases the reference counter pointer without destroying it. This is only allowed if the implementation uses 'std::shared_ptr'. | |
| const ImplType & | _internalInstance () const |
Static Public Member Functions | |
| static ThatClass | create (InstanceType *t) |
| Creates a reference from the instance t. | |
| template<typename PointerType, typename... Args> | |
| static Ref< InstanceType > | createRef (Args &&... args) |
| static ThatClass | createWithHandle (InstanceType *t, Internal::ExternalRef handle) |
| Creates a reference from an instance having an external reference. | |
| static ThatClass | _createNoDestroy (InstanceType *t) |
Private Types | |
| using | Base = RefImpl<InstanceType, Ref<InstanceType>, RefTraits<InstanceType>::TagId> |
| using | ImplType = Base::ImplType |
| using | ThatClass = Ref<InstanceType> |
| template<typename... _Args> | |
| using | _IsRefConstructible = typename std::enable_if<std::is_constructible<ImplType, _Args...>::value>::type |
Private Member Functions | |
| Ref (InstanceType *t) | |
| Ref (InstanceType *t, Internal::ExternalRef handle) | |
| Ref (InstanceType *t, bool no_destroy) | |
Static Private Member Functions | |
| static void | _destroyInstance (InstanceType *t) |
Private Attributes | |
| friend | Base |
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 |
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.
|
private |
Definition at line 332 of file arccore/src/base/arccore/base/Ref.h.
|
private |
Definition at line 326 of file arccore/src/base/arccore/base/Ref.h.
|
private |
Definition at line 327 of file arccore/src/base/arccore/base/Ref.h.
|
private |
Definition at line 328 of file arccore/src/base/arccore/base/Ref.h.
|
inlineexplicitprivate |
Definition at line 336 of file arccore/src/base/arccore/base/Ref.h.
|
inlineprivate |
Definition at line 339 of file arccore/src/base/arccore/base/Ref.h.
|
inlineprivate |
Definition at line 342 of file arccore/src/base/arccore/base/Ref.h.
|
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.
|
inlinestatic |
Definition at line 398 of file arccore/src/base/arccore/base/Ref.h.
|
inlinestaticprivate |
Definition at line 405 of file arccore/src/base/arccore/base/Ref.h.
|
inlinestatic |
Creates a reference from the instance t.
This method is internal to Arccore.
The instance t must have been created by the 'operator new' operator and will be destroyed by the 'operator delete' operator
Definition at line 375 of file arccore/src/base/arccore/base/Ref.h.
Referenced by Arcane::makeRef(), and Arcane::makeRefFromInstance().
|
inlinestatic |
Definition at line 382 of file arccore/src/base/arccore/base/Ref.h.
|
inlinestatic |
Creates a reference from an instance having an external reference.
Definition at line 393 of file arccore/src/base/arccore/base/Ref.h.
|
private |
Definition at line 329 of file arccore/src/base/arccore/base/Ref.h.