15 #ifndef A_UTIL_UTIL_RESULT_IMPL_REFERENCE_COUNTED_OBJECT_HEADER_INCLUDED
16 #define A_UTIL_UTIL_RESULT_IMPL_REFERENCE_COUNTED_OBJECT_HEADER_INCLUDED
32 template <
typename Interface,
typename Implementation>
44 template <
typename... Args>
103 template <
typename Interface,
typename Implementation>
120 template <
typename... Args>
Default implementation of a reference counter.
virtual void removeReference() const
Decrease the reference count by 1, deleting *this if it was the last reference.
std::atomic< std::int32_t > _reference_count
Reference to count atomically.
virtual void addReference() const
Increase the reference count by 1.
virtual Interface & getObject()
Get a reference to the handled object's interface.
ReferenceCountedObject(Args &&... args)
CTOR constructing the managed resource and the reference counter to an initial value of zero.
virtual const Interface & getObject() const
Get a reference to the handled object's interface - provided for const correctness.
Implementation _resource
Resource to manage.
An internal stable interface to ensure binary compatibility of reference counting.
Default implementation of a non-counting reference counter.
const Interface & getObject() const override
Get a reference to the handled object's interface - provided for const correctness.
void addReference() const override
Noop.
UncountedObject()=default
Default CTOR.
Interface & getObject() override
Get a reference to the handled object's interface.
virtual ~UncountedObject()=default
Default DTOR, provided to be consistent with rule-of-five.
UncountedObject(Args &&... args)
CTOR constructing the managed resource.
void removeReference() const override
Noop.
Implementation _resource
Resource to manage.
Serves as the root component, with common functionality documented in core functionality.
Private API for ReferenceCountedObjectInterface type.