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 27 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 | |
stlplus::smart_ptr< std::vector< char > > | m_data |
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.
|
virtual |
Destructor, calls dereference_once.
Definition at line 21 of file CReferencedMemBlock.cpp.
unsigned int CReferencedMemBlock::alias_count | ( | ) | const |
Definition at line 30 of file CReferencedMemBlock.cpp.
References m_data.
void CReferencedMemBlock::clear | ( | ) |
Frees the underlying memory block.
Definition at line 35 of file CReferencedMemBlock.cpp.
References m_data.
|
inline |
Definition at line 52 of file CReferencedMemBlock.h.
|
inline |
Definition at line 53 of file CReferencedMemBlock.h.
|
inline |
Definition at line 39 of file CReferencedMemBlock.h.
|
inline |
Definition at line 45 of file CReferencedMemBlock.h.
void CReferencedMemBlock::resize | ( | size_t | mem_block_size | ) |
Resize the shared memory block.
Definition at line 25 of file CReferencedMemBlock.cpp.
References m_data.
|
protected |
Definition at line 59 of file CReferencedMemBlock.h.
Referenced by alias_count(), clear(), and resize().
Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019 |