OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::RCWeak< RCImpl > Class Template Reference

Reference count base class for objects tracked by RCPtr. Like RC, but also allows weak pointers and release notification callables. More...

#include <rc.hpp>

Collaboration diagram for openvpn::RCWeak< RCImpl >:
[legend]

Classes

struct  Controller
 Controller structure for our ptr/weakptr implementation. More...
 
struct  ControllerRef
 Adapter object for RCWeak::Controller <—> RCPtr. More...
 

Public Types

typedef RCPtr< RCWeakPtr
 
typedef RCWeakPtr< RCWeakWPtr
 

Public Member Functions

 RCWeak () noexcept
 
virtual ~RCWeak ()=default
 
 RCWeak (const RCWeak &)=delete
 
RCWeakoperator= (const RCWeak &)=delete
 

Private Attributes

ControllerRef refcount_
 Adapter instance that allows RCPtr to properly interact with RCWeak.
 

Friends

template<typename T >
class RCWeakPtr
 
template<typename R >
void intrusive_ptr_add_ref (R *rcptr) noexcept
 Helper to increment a ref count.
 
template<typename R >
void intrusive_ptr_release (R *rcptr) noexcept
 Helper to decrement a ref count.
 

Detailed Description

template<typename RCImpl>
class openvpn::RCWeak< RCImpl >

Reference count base class for objects tracked by RCPtr. Like RC, but also allows weak pointers and release notification callables.

Template Parameters
RCImplThe ref count implementation that will be used - thread_safe_refcount or thread_unsafe_refcount

Implements basic reference counting functionality for objects plus weak pointer capability.

The purpose of RCWeak is to provide a base class that other classes can inherit from to enable reference counting and automatic memory management. It takes a template parameter RCImpl which specifies the actual reference count implementation class that will be used, either thread_safe_refcount or thread_unsafe_refcount.

RCWeak provides a common base class for enabling reference counting on other classes via inheritance. It delegates the actual reference count tracking to the RCImpl implementation specified as a template parameter. It also disables copy but enables move.

Nested classes are used to facilitate the requirements of weak pointers and those classes are documented seperately. The member functions just delegate to the refcount_ object that's injected via template, with the previously mentionend nested classes changing the way ref counts work as required.

See also
RCWeak::Controller for more details
RCWeak::ControllerRef for more details

Definition at line 1089 of file rc.hpp.

Member Typedef Documentation

◆ Ptr

template<typename RCImpl >
typedef RCPtr<RCWeak> openvpn::RCWeak< RCImpl >::Ptr

Definition at line 1108 of file rc.hpp.

◆ WPtr

template<typename RCImpl >
typedef RCWeakPtr<RCWeak> openvpn::RCWeak< RCImpl >::WPtr

Definition at line 1109 of file rc.hpp.

Constructor & Destructor Documentation

◆ RCWeak() [1/2]

template<typename RCImpl >
openvpn::RCWeak< RCImpl >::RCWeak ( )
inlinenoexcept

Definition at line 1111 of file rc.hpp.

◆ ~RCWeak()

template<typename RCImpl >
virtual openvpn::RCWeak< RCImpl >::~RCWeak ( )
virtualdefault

◆ RCWeak() [2/2]

template<typename RCImpl >
openvpn::RCWeak< RCImpl >::RCWeak ( const RCWeak< RCImpl > &  )
delete

Member Function Documentation

◆ operator=()

template<typename RCImpl >
RCWeak & openvpn::RCWeak< RCImpl >::operator= ( const RCWeak< RCImpl > &  )
delete

Friends And Related Symbol Documentation

◆ intrusive_ptr_add_ref

template<typename RCImpl >
template<typename R >
void intrusive_ptr_add_ref ( R *  rcptr)
friend

Helper to increment a ref count.

Template Parameters
Rtype that has an incrementable member refcount_
Parameters
rcptrpointer to instance of R
Todo:
consider removing debug cout

Helper function template to implement incrementing of a member 'refcount_' of a type R; acts as an adapter layer to implement this funtionality as well as some conditionally built debug logging.

Definition at line 1400 of file rc.hpp.

◆ intrusive_ptr_release

template<typename RCImpl >
template<typename R >
void intrusive_ptr_release ( R *  rcptr)
friend

Helper to decrement a ref count.

Template Parameters
Rtype that has an decrementable member refcount_
Parameters
rcptrpointer to instance of R
Todo:
consider removing debug cout

Helper function template to implement decrementing of a member 'refcount_' of a type R; acts as an adapter layer to implement this funtionality as well as some conditionally built debug logging and a conditionally built notify hook.

Definition at line 1418 of file rc.hpp.

◆ RCWeakPtr

template<typename RCImpl >
template<typename T >
friend class RCWeakPtr
friend

Definition at line 1092 of file rc.hpp.

Member Data Documentation

◆ refcount_

template<typename RCImpl >
ControllerRef openvpn::RCWeak< RCImpl >::refcount_
private

Adapter instance that allows RCPtr to properly interact with RCWeak.

Definition at line 1145 of file rc.hpp.


The documentation for this class was generated from the following file: