ADTF  3.18.2
ReferenceCountedObject< Interface, Implementation >

Default implementation of a reference counter. More...

Inheritance diagram for ReferenceCountedObject< Interface, Implementation >:
[legend]

Public Member Functions

template<typename... Args>
 ReferenceCountedObject (Args &&... args)
 CTOR constructing the managed resource and the reference counter to an initial value of zero. More...
 
virtual void addReference () const
 Increase the reference count by 1.
 
virtual void removeReference () const
 Decrease the reference count by 1, deleting *this if it was the last reference.
 
virtual const Interface & getObject () const
 Get a reference to the handled object's interface - provided for const correctness. More...
 
virtual Interface & getObject ()
 Get a reference to the handled object's interface. More...
 

Private Member Functions

 ReferenceCountedObject (const ReferenceCountedObject &)
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &)
 

Private Attributes

std::atomic< std::int32_t > _reference_count
 Reference to count atomically.
 
Implementation _resource
 Resource to manage.
 

Additional Inherited Members

- Protected Member Functions inherited from ReferenceCountedObjectInterface< Interface >
 ~ReferenceCountedObjectInterface ()
 DTOR.
 

Detailed Description

template<typename Interface, typename Implementation>
class a_util::result::detail::ReferenceCountedObject< Interface, Implementation >

Default implementation of a reference counter.

Template Parameters
InterfaceThe interface of the resource to handle
ImplementationThe type implementing the Interface type

Definition at line 33 of file reference_counted_object.h.

Constructor & Destructor Documentation

◆ ReferenceCountedObject()

ReferenceCountedObject ( Args &&...  args)
inline

CTOR constructing the managed resource and the reference counter to an initial value of zero.

Template Parameters
ArgsArgument types of the resource's constructor
Parameters
[in]argsValues to forward to the resource's constructor

Definition at line 45 of file reference_counted_object.h.

Member Function Documentation

◆ getObject() [1/2]

virtual Interface& getObject ( )
inlinevirtual

Get a reference to the handled object's interface.

Returns
Reference to the handled object

Implements ReferenceCountedObjectInterface< Interface >.

Definition at line 79 of file reference_counted_object.h.

References ReferenceCountedObject< Interface, Implementation >::_resource.

◆ getObject() [2/2]

virtual const Interface& getObject ( ) const
inlinevirtual

Get a reference to the handled object's interface - provided for const correctness.

Returns
Const reference to the handled object

Implements ReferenceCountedObjectInterface< Interface >.

Definition at line 70 of file reference_counted_object.h.

References ReferenceCountedObject< Interface, Implementation >::_resource.