Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
xsens::JanitorRCDeallocation< T, DeallocationPolicy > Class Template Reference

Reference counting janitor class. More...

#include <xsens_janitors.h>

Public Types

typedef T ElementType
 A type definition for an element type. More...
 
typedef void(* PostDeallocateFunc) ()
 A function prototype for a post deallocation function. More...
 
typedef JanitorRCDeallocation< T, DeallocationPolicy > ThisType
 A type definition for this type. More...
 

Public Member Functions

void disable (void)
 Disables the reference counting. More...
 
void enable (void)
 Enables the reference counting. More...
 
ElementTypeget () const throw ()
 
 JanitorRCDeallocation (const ThisType &j, bool enabled=true)
 Constructor with this type. More...
 
 JanitorRCDeallocation (ElementType *target=0, bool enabled=true)
 Constructor with an element type. More...
 
ElementTypeoperator* () const
 
ElementTypeoperator-> () const
 
JanitorRCDeallocationoperator= (const JanitorRCDeallocation &rhs)
 Copy the data from rhs. More...
 
void reset (ElementType *p=0) throw ()
 Swaps an element type with this type. More...
 
void swap (JanitorRCDeallocation &other) throw ()
 Swaps the current object's variables with an other object's variables. More...
 
virtual ~JanitorRCDeallocation ()
 Destructor. More...
 

Private Member Functions

void addRef (void)
 Adds a reference to a reference counter. More...
 
void removeRef (void)
 Removes a reference from a reference counter. More...
 

Private Attributes

bool m_enabled
 
int * m_refCounter
 
ElementTypem_target
 

Friends

void swap (JanitorRCDeallocation &first, JanitorRCDeallocation &second)
 Swaps the two object's variables. More...
 

Detailed Description

template<class T, template< class > class DeallocationPolicy>
class xsens::JanitorRCDeallocation< T, DeallocationPolicy >

Reference counting janitor class.

This class can be used to make sure that the associated pointer is deleted/freed when the last janitor for it leaves scope.

Definition at line 1001 of file xsens_janitors.h.

Member Typedef Documentation

◆ ElementType

template<class T , template< class > class DeallocationPolicy>
typedef T xsens::JanitorRCDeallocation< T, DeallocationPolicy >::ElementType

A type definition for an element type.

Definition at line 1005 of file xsens_janitors.h.

◆ PostDeallocateFunc

template<class T , template< class > class DeallocationPolicy>
typedef void(* xsens::JanitorRCDeallocation< T, DeallocationPolicy >::PostDeallocateFunc) ()

A function prototype for a post deallocation function.

Definition at line 1006 of file xsens_janitors.h.

◆ ThisType

template<class T , template< class > class DeallocationPolicy>
typedef JanitorRCDeallocation<T, DeallocationPolicy> xsens::JanitorRCDeallocation< T, DeallocationPolicy >::ThisType

A type definition for this type.

Definition at line 1004 of file xsens_janitors.h.

Constructor & Destructor Documentation

◆ JanitorRCDeallocation() [1/2]

template<class T , template< class > class DeallocationPolicy>
xsens::JanitorRCDeallocation< T, DeallocationPolicy >::JanitorRCDeallocation ( ElementType target = 0,
bool  enabled = true 
)
inline

Constructor with an element type.

Definition at line 1010 of file xsens_janitors.h.

◆ JanitorRCDeallocation() [2/2]

template<class T , template< class > class DeallocationPolicy>
xsens::JanitorRCDeallocation< T, DeallocationPolicy >::JanitorRCDeallocation ( const ThisType j,
bool  enabled = true 
)
inline

Constructor with this type.

Definition at line 1020 of file xsens_janitors.h.

◆ ~JanitorRCDeallocation()

template<class T , template< class > class DeallocationPolicy>
virtual xsens::JanitorRCDeallocation< T, DeallocationPolicy >::~JanitorRCDeallocation ( )
inlinevirtual

Destructor.

Definition at line 1030 of file xsens_janitors.h.

Member Function Documentation

◆ addRef()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::addRef ( void  )
inlineprivate

Adds a reference to a reference counter.

Note
If there was no reference counter, then it will create a new one

Definition at line 1121 of file xsens_janitors.h.

◆ disable()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::disable ( void  )
inline

Disables the reference counting.

Definition at line 1066 of file xsens_janitors.h.

◆ enable()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::enable ( void  )
inline

Enables the reference counting.

Definition at line 1073 of file xsens_janitors.h.

◆ get()

template<class T , template< class > class DeallocationPolicy>
ElementType* xsens::JanitorRCDeallocation< T, DeallocationPolicy >::get ( ) const
throw (
)
inline
Returns
A pointer to an element type

Definition at line 1080 of file xsens_janitors.h.

◆ operator*()

template<class T , template< class > class DeallocationPolicy>
ElementType& xsens::JanitorRCDeallocation< T, DeallocationPolicy >::operator* ( ) const
inline
Returns
A reference to the data. This does not detach/copy the data.

Definition at line 1059 of file xsens_janitors.h.

◆ operator->()

template<class T , template< class > class DeallocationPolicy>
ElementType* xsens::JanitorRCDeallocation< T, DeallocationPolicy >::operator-> ( ) const
inline
Returns
A const pointer to the data. This does not detach/copy the data.

Definition at line 1052 of file xsens_janitors.h.

◆ operator=()

template<class T , template< class > class DeallocationPolicy>
JanitorRCDeallocation& xsens::JanitorRCDeallocation< T, DeallocationPolicy >::operator= ( const JanitorRCDeallocation< T, DeallocationPolicy > &  rhs)
inline

Copy the data from rhs.

Parameters
rhsThe janitor deallication class
Returns
this

Definition at line 1039 of file xsens_janitors.h.

◆ removeRef()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::removeRef ( void  )
inlineprivate

Removes a reference from a reference counter.

Note
If the reference counter has less than one reference, it will delete itself and deallocate an element type

Definition at line 1134 of file xsens_janitors.h.

◆ reset()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::reset ( ElementType p = 0)
throw (
)
inline

Swaps an element type with this type.

If no argument is passed the object will be reset

Parameters
pThe pointer to an element type

Definition at line 1110 of file xsens_janitors.h.

◆ swap()

template<class T , template< class > class DeallocationPolicy>
void xsens::JanitorRCDeallocation< T, DeallocationPolicy >::swap ( JanitorRCDeallocation< T, DeallocationPolicy > &  other)
throw (
)
inline

Swaps the current object's variables with an other object's variables.

Parameters
otherThe reference to an other object

Definition at line 1088 of file xsens_janitors.h.

Friends And Related Function Documentation

◆ swap

template<class T , template< class > class DeallocationPolicy>
void swap ( JanitorRCDeallocation< T, DeallocationPolicy > &  first,
JanitorRCDeallocation< T, DeallocationPolicy > &  second 
)
friend

Swaps the two object's variables.

Parameters
firstThe reference to the first object
secondThe reference to the second object

Definition at line 1100 of file xsens_janitors.h.

Member Data Documentation

◆ m_enabled

template<class T , template< class > class DeallocationPolicy>
bool xsens::JanitorRCDeallocation< T, DeallocationPolicy >::m_enabled
private

Definition at line 1150 of file xsens_janitors.h.

◆ m_refCounter

template<class T , template< class > class DeallocationPolicy>
int* xsens::JanitorRCDeallocation< T, DeallocationPolicy >::m_refCounter
private

Definition at line 1149 of file xsens_janitors.h.

◆ m_target

template<class T , template< class > class DeallocationPolicy>
ElementType* xsens::JanitorRCDeallocation< T, DeallocationPolicy >::m_target
private

Definition at line 1148 of file xsens_janitors.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:23