pion-net
4.0.9
|
#include <PionBlob.hpp>
Classes | |
struct | BlobData |
structure used to store BLOB metadata; payload starts immediately following this More... | |
struct | BlobParams |
data type used to initialize blobs in variants without copy construction More... | |
Public Member Functions | |
virtual | ~PionBlob () |
virtual destructor | |
PionBlob (void) | |
default constructor | |
PionBlob (const PionBlob &blob) | |
PionBlob (const BlobParams &p) | |
PionBlob (AllocType &blob_alloc, const CharType *ptr, const std::size_t len) | |
PionBlob (AllocType &blob_alloc, const std::string &str) | |
PionBlob & | operator= (const PionBlob &blob) |
void | set (const BlobParams &p) |
void | set (AllocType &blob_alloc, const CharType *ptr, const std::size_t len) |
void | set (AllocType &blob_alloc, const std::string &str) |
CharType * | reserve (AllocType &blob_alloc, const std::size_t len) |
const CharType * | get (void) const |
returns (const) reference to the BLOB payload | |
std::size_t | size (void) const |
returns size of the BLOB in octets | |
std::size_t | length (void) const |
returns length of the BLOB in octets (alias for size()) | |
bool | empty (void) const |
returns true if the BLOB is empty (undefined or size == 0) | |
long | use_count (void) const |
returns the number of reference to this BLOB (or 0 if this is null) | |
bool | unique (void) const |
returns true if this is a unique instance or if this is null | |
void | clear (void) |
alias for release() -> switch to empty state | |
void | reset (void) |
alias for release() -> switch to empty state | |
bool | operator== (const PionBlob &blob) const |
returns true if str is equal to this (BLOB matches string) | |
bool | operator== (const std::string &str) const |
returns true if str is equal to this (BLOB matches string) | |
bool | operator!= (const PionBlob &blob) const |
returns true if blob is not equal to this (two BLOBs do not match) | |
bool | operator!= (const std::string &str) const |
returns true if str is not equal to this (BLOB does not match string) | |
bool | operator< (const PionBlob &blob) const |
returns true if this is less than blob | |
bool | operator> (const PionBlob &blob) const |
returns true if this is greater than blob | |
bool | operator< (const std::string &str) const |
returns true if this is less than str | |
bool | operator> (const std::string &str) const |
returns true if this is greater than str | |
Protected Member Functions | |
void | release (void) |
BlobData * | grab (void) const |
Static Protected Member Functions | |
static BlobData * | create (AllocType &blob_alloc, const std::size_t len) |
Protected Attributes | |
BlobData * | m_blob_ptr |
pointer to the BLOB metadata structure (payload follows the structure) |
PionBlob: a simple, reference-counting BLOB class that uses PionPoolAllocator for memory management
Definition at line 27 of file PionBlob.hpp.
pion::PionBlob< CharType, AllocType >::PionBlob | ( | const PionBlob< CharType, AllocType > & | blob | ) | [inline] |
copy constructor
blob | grabs reference from this existing blob |
Definition at line 132 of file PionBlob.hpp.
pion::PionBlob< CharType, AllocType >::PionBlob | ( | const BlobParams & | p | ) | [inline] |
constructs a BLOB using BlobParams
p | BlobParams contains all parameters used to initialize the BLOB |
Definition at line 141 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), and pion::PionBlob< CharType, AllocType >::m_blob_ptr.
pion::PionBlob< CharType, AllocType >::PionBlob | ( | AllocType & | blob_alloc, |
const CharType * | ptr, | ||
const std::size_t | len | ||
) | [inline] |
constructs a BLOB using existing memory buffer
blob_alloc | allocator used for memory management |
ptr | pointer to a buffer of memory to copy into the BLOB |
len | size in octets of the memory buffer to copy |
Definition at line 155 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), and pion::PionBlob< CharType, AllocType >::m_blob_ptr.
pion::PionBlob< CharType, AllocType >::PionBlob | ( | AllocType & | blob_alloc, |
const std::string & | str | ||
) | [inline] |
constructs a BLOB using existing string
blob_alloc | allocator used for memory management |
str | existing std::string object to copy |
Definition at line 168 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), and pion::PionBlob< CharType, AllocType >::m_blob_ptr.
static BlobData* pion::PionBlob< CharType, AllocType >::create | ( | AllocType & | blob_alloc, |
const std::size_t | len | ||
) | [inline, static, protected] |
creates a new BLOB reference object
len | size in octets to allocate for the BLOB |
Definition at line 70 of file PionBlob.hpp.
Referenced by pion::PionBlob< CharType, AllocType >::PionBlob(), pion::PionBlob< CharType, AllocType >::reserve(), and pion::PionBlob< CharType, AllocType >::set().
BlobData* pion::PionBlob< CharType, AllocType >::grab | ( | void | ) | const [inline, protected] |
grabs & returns reference pointer to this BLOB (increments references)
Definition at line 93 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::BlobData::m_copies.
Referenced by pion::PionBlob< CharType, AllocType >::operator=().
PionBlob& pion::PionBlob< CharType, AllocType >::operator= | ( | const PionBlob< CharType, AllocType > & | blob | ) | [inline] |
assignment operator
blob | grabs reference from this existing blob |
Definition at line 182 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::grab(), pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::release().
void pion::PionBlob< CharType, AllocType >::release | ( | void | ) | [inline, protected] |
releases pointer to the BLOB metadata structure, and frees memory if no more references
Definition at line 79 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::BlobData::m_alloc_ptr, pion::PionBlob< CharType, AllocType >::m_blob_ptr, pion::PionBlob< CharType, AllocType >::BlobData::m_copies, and pion::PionBlob< CharType, AllocType >::BlobData::m_len.
Referenced by pion::PionBlob< CharType, AllocType >::clear(), pion::PionBlob< CharType, AllocType >::operator=(), pion::PionBlob< CharType, AllocType >::reserve(), pion::PionBlob< CharType, AllocType >::reset(), pion::PionBlob< CharType, AllocType >::set(), and pion::PionBlob< CharType, AllocType >::~PionBlob().
CharType* pion::PionBlob< CharType, AllocType >::reserve | ( | AllocType & | blob_alloc, |
const std::size_t | len | ||
) | [inline] |
reserves memory for a new blob without assigning memory
blob_alloc | allocator used for memory management |
len | size in octets of the new memory buffer to allocate |
Definition at line 232 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::release().
void pion::PionBlob< CharType, AllocType >::set | ( | const BlobParams & | p | ) | [inline] |
assigns BLOB to existing memory buffer via BlobParams
p | BlobParams contains all parameters used to initialize the BLOB |
Definition at line 193 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::release().
void pion::PionBlob< CharType, AllocType >::set | ( | AllocType & | blob_alloc, |
const CharType * | ptr, | ||
const std::size_t | len | ||
) | [inline] |
assigns BLOB to use an existing memory buffer
blob_alloc | allocator used for memory management |
ptr | pointer to a buffer of memory to copy into the BLOB |
len | size in octets of the memory buffer to copy |
Definition at line 206 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::release().
void pion::PionBlob< CharType, AllocType >::set | ( | AllocType & | blob_alloc, |
const std::string & | str | ||
) | [inline] |
assigns BLOB to use an existing string
blob_alloc | allocator used for memory management |
str | existing std::string object to copy |
Definition at line 218 of file PionBlob.hpp.
References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), pion::PionBlob< CharType, AllocType >::m_blob_ptr, and pion::PionBlob< CharType, AllocType >::release().