12#ifndef ARCCORE_BASE_REFDECLARATIONS_H
13#define ARCCORE_BASE_REFDECLARATIONS_H
43 static ARCCORE_EXPORT
void addReference(T* t);
44 static ARCCORE_EXPORT
void removeReference(T* t);
81constexpr int REF_TAG_SHARED_PTR = 0;
82constexpr int REF_TAG_REFERENCE_COUNTER = 1;
97 return REF_TAG_SHARED_PTR;
108template <
typename InstanceType>
117template <
typename InstanceType,
int TagType>
135 static void addReference(T* t)
137 if constexpr (
requires { t->_internalAddReference(); })
138 t->_internalAddReference();
142 static void removeReference(T* t)
144 if constexpr (
requires { t->_internalRemoveReference(); }) {
145 bool need_destroy = t->_internalRemoveReference();
150 t->removeReference();
180#define ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS() \
183 template <typename T> friend class ::Arccore::ExternalReferenceCounterAccessor; \
184 template <typename T> friend class Arcane::ReferenceCounterAccessor; \
188 using ReferenceCounterTagType = ::Arcane::ReferenceCounterTag; \
189 virtual ::Arcane::ReferenceCounterImpl* _internalReferenceCounter() = 0; \
190 virtual void _internalAddReference() = 0; \
191 [[nodiscard]] virtual bool _internalRemoveReference() = 0
216#define ARCCORE_DECLARE_REFERENCE_COUNTED_CLASS(class_name) \
220 struct RefTraits<class_name> \
222 static constexpr int TagId = ::Arcane::REF_TAG_REFERENCE_COUNTER; \
224 constexpr inline int arcaneImplGetRefTagId(class_name*) \
226 return ::Arcane::REF_TAG_REFERENCE_COUNTER; \
229 class ReferenceCounterAccessor<class_name> \
230 : public ExternalReferenceCounterAccessor<class_name> \
244using Arcane::ReferenceCounterTag;
Declarations of types for the 'base' component of Arccore.
Accessor for reference counter management methods.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
constexpr int arcaneImplGetRefTagId(void *)
Function to determine what type of reference counter a class uses.
Characteristics for managing reference counters.
Structure used to tag interfaces/classes that use an internal reference counter.