9 #ifndef CReferencedMemBlock_H 10 #define CReferencedMemBlock_H 36 void resize(
size_t mem_block_size);
42 throw std::runtime_error(
43 "Trying to access to an uninitialized memory block");
45 throw std::runtime_error(
46 "Trying to access to a memory block of size 0");
47 return reinterpret_cast<T*
>(&((*m_data)[0]));
53 throw std::runtime_error(
54 "Trying to access to an uninitialized memory block");
56 throw std::runtime_error(
57 "Trying to access to a memory block of size 0");
58 return reinterpret_cast<const T*
>(&((*m_data)[0]));
64 return *getAsPtr<T>();
69 return *getAsPtr<T>();
77 std::shared_ptr<std::vector<char>>
m_data;
const T * getAsPtr() const
Represents a memory block (via "void*") that can be shared between several objects through copy opera...
void resize(size_t mem_block_size)
Resize the shared memory block.
void clear()
Frees the underlying memory block.
std::shared_ptr< std::vector< char > > m_data
unsigned int alias_count() const
CReferencedMemBlock(size_t mem_block_size=0)
Constructor with an optional size of the memory block.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual ~CReferencedMemBlock()
Destructor, calls dereference_once.