12#ifndef ARCCORE_BASE_REFDECLARATIONS_H
13#define ARCCORE_BASE_REFDECLARATIONS_H
46 static ARCCORE_EXPORT
void addReference(T* t);
47 static ARCCORE_EXPORT
void removeReference(T* t);
84constexpr int REF_TAG_SHARED_PTR = 0;
85constexpr int REF_TAG_REFERENCE_COUNTER = 1;
100 return REF_TAG_SHARED_PTR;
111template <
typename InstanceType>
120template <
typename InstanceType,
int TagType>
138 static void addReference(T* t)
140 if constexpr (
requires { t->_internalAddReference(); })
141 t->_internalAddReference();
145 static void removeReference(T* t)
147 if constexpr (
requires { t->_internalRemoveReference(); }) {
148 bool need_destroy = t->_internalRemoveReference();
153 t->removeReference();
183#define ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS() \
186 template <typename T> friend class ::Arccore::ExternalReferenceCounterAccessor; \
187 template <typename T> friend class Arcane::ReferenceCounterAccessor; \
191 using ReferenceCounterTagType = ::Arcane::ReferenceCounterTag; \
192 virtual ::Arcane::ReferenceCounterImpl* _internalReferenceCounter() = 0; \
193 virtual void _internalAddReference() = 0; \
194 [[nodiscard]] virtual bool _internalRemoveReference() = 0
219#define ARCCORE_DECLARE_REFERENCE_COUNTED_CLASS(class_name) \
223 struct RefTraits<class_name> \
225 static constexpr int TagId = ::Arcane::REF_TAG_REFERENCE_COUNTER; \
227 constexpr inline int arcaneImplGetRefTagId(class_name*) \
229 return ::Arcane::REF_TAG_REFERENCE_COUNTER; \
232 class ReferenceCounterAccessor<class_name> \
233 : public ExternalReferenceCounterAccessor<class_name> \
247using 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.