7 #include <nx/sdk/i_ref_countable.h> 8 #include <nx/sdk/helpers/lib_context.h> 48 return m_refCountHolderDelegate ? m_refCountHolderDelegate->addRef() : ++m_refCount;
56 if (m_refCountHolderDelegate)
59 const int newRefCounter = --m_refCount;
60 if (newRefCounter == 0)
61 delete m_refCountable;
67 if (m_refCountHolderDelegate)
68 return m_refCountHolderDelegate->refCount();
73 mutable std::atomic<int> m_refCount{1};
74 const IRefCountable*
const m_refCountable =
nullptr;
75 const RefCountableHolder*
const m_refCountHolderDelegate =
nullptr;
83 template<
class RefCountableInterface>
94 if (
const auto refCountableRegistry = libContext().refCountableRegistry())
95 refCountableRegistry->notifyDestroyed(
this, refCount());
98 virtual int addRef()
const override {
return m_refCountableHolder.addRef(); }
99 virtual int releaseRef()
const override {
return m_refCountableHolder.
releaseRef(); }
101 int refCount()
const {
return m_refCountableHolder.refCount(); }
104 RefCountable(): m_refCountableHolder(static_cast<const IRefCountable*>(
this))
106 if (
const auto refCountableRegistry = libContext().refCountableRegistry())
107 refCountableRegistry->notifyCreated(
this, refCount());
RefCountableHolder(const RefCountableHolder *delegate)
Definition: ref_countable.h:44
RefCountableHolder(const IRefCountable *refCountable)
Definition: ref_countable.h:39
int releaseRef() const
Definition: ref_countable.h:54
Definition: apple_utils.h:6
Definition: ref_countable.h:24
Definition: i_ref_countable.h:49
Definition: ref_countable.h:84