Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Protected Attributes
mrpt::utils::CReferencedMemBlock Class Reference

Detailed Description

Represents a memory block (via "void*") that can be shared between several objects through copy operator (=).

It keeps the reference count and only when it comes to zero, the memory block is really freed. Behaves like std::shared_ptr<>.

Definition at line 26 of file CReferencedMemBlock.h.

#include <mrpt/utils/CReferencedMemBlock.h>

Public Member Functions

 CReferencedMemBlock (size_t mem_block_size=0)
 Constructor with an optional size of the memory block. More...
 
virtual ~CReferencedMemBlock ()
 Destructor, calls dereference_once. More...
 
void resize (size_t mem_block_size)
 Resize the shared memory block. More...
 
template<class T >
T * getAsPtr ()
 
template<class T >
const T * getAsPtr () const
 
template<class T >
T & getAs ()
 
template<class T >
const T & getAs () const
 
unsigned int alias_count () const
 
void clear ()
 Frees the underlying memory block. More...
 

Protected Attributes

std::shared_ptr< std::vector< char > > m_data
 

Constructor & Destructor Documentation

◆ CReferencedMemBlock()

CReferencedMemBlock::CReferencedMemBlock ( size_t  mem_block_size = 0)

Constructor with an optional size of the memory block.

Definition at line 16 of file CReferencedMemBlock.cpp.

◆ ~CReferencedMemBlock()

CReferencedMemBlock::~CReferencedMemBlock ( )
virtual

Destructor, calls dereference_once.

Definition at line 21 of file CReferencedMemBlock.cpp.

Member Function Documentation

◆ alias_count()

unsigned int CReferencedMemBlock::alias_count ( ) const

Definition at line 27 of file CReferencedMemBlock.cpp.

References m_data.

◆ clear()

void CReferencedMemBlock::clear ( )

Frees the underlying memory block.

Definition at line 32 of file CReferencedMemBlock.cpp.

References m_data.

◆ getAs() [1/2]

template<class T >
T& mrpt::utils::CReferencedMemBlock::getAs ( )
inline

Definition at line 62 of file CReferencedMemBlock.h.

◆ getAs() [2/2]

template<class T >
const T& mrpt::utils::CReferencedMemBlock::getAs ( ) const
inline

Definition at line 67 of file CReferencedMemBlock.h.

◆ getAsPtr() [1/2]

template<class T >
T* mrpt::utils::CReferencedMemBlock::getAsPtr ( )
inline

Definition at line 39 of file CReferencedMemBlock.h.

References m_data.

◆ getAsPtr() [2/2]

template<class T >
const T* mrpt::utils::CReferencedMemBlock::getAsPtr ( ) const
inline

Definition at line 50 of file CReferencedMemBlock.h.

References m_data.

◆ resize()

void CReferencedMemBlock::resize ( size_t  mem_block_size)

Resize the shared memory block.

Definition at line 22 of file CReferencedMemBlock.cpp.

References m_data.

Member Data Documentation

◆ m_data

std::shared_ptr<std::vector<char> > mrpt::utils::CReferencedMemBlock::m_data
protected

Definition at line 77 of file CReferencedMemBlock.h.

Referenced by alias_count(), clear(), getAsPtr(), and resize().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019