pion-net  4.0.9
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
pion::PionBlob< CharType, AllocType > Class Template Reference

#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)
 
PionBloboperator= (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)
 
BlobDatagrab (void) const
 

Static Protected Member Functions

static BlobDatacreate (AllocType &blob_alloc, const std::size_t len)
 

Protected Attributes

BlobDatam_blob_ptr
 pointer to the BLOB metadata structure (payload follows the structure)
 

Detailed Description

template<typename CharType, typename AllocType>
class pion::PionBlob< CharType, AllocType >

PionBlob: a simple, reference-counting BLOB class that uses PionPoolAllocator for memory management

Definition at line 27 of file PionBlob.hpp.

Constructor & Destructor Documentation

template<typename CharType, typename AllocType>
pion::PionBlob< CharType, AllocType >::PionBlob ( const PionBlob< CharType, AllocType > &  blob)
inline

copy constructor

Parameters
blobgrabs reference from this existing blob

Definition at line 132 of file PionBlob.hpp.

template<typename CharType, typename AllocType>
pion::PionBlob< CharType, AllocType >::PionBlob ( const BlobParams p)
inline

constructs a BLOB using BlobParams

Parameters
pBlobParams contains all parameters used to initialize the BLOB

Definition at line 141 of file PionBlob.hpp.

References pion::PionBlob< CharType, AllocType >::create(), and pion::PionBlob< CharType, AllocType >::BlobData::get().

template<typename CharType, typename AllocType>
pion::PionBlob< CharType, AllocType >::PionBlob ( AllocType &  blob_alloc,
const CharType *  ptr,
const std::size_t  len 
)
inline

constructs a BLOB using existing memory buffer

Parameters
blob_allocallocator used for memory management
ptrpointer to a buffer of memory to copy into the BLOB
lensize in octets of the memory buffer to copy

Definition at line 155 of file PionBlob.hpp.

References pion::PionBlob< CharType, AllocType >::create(), and pion::PionBlob< CharType, AllocType >::BlobData::get().

template<typename CharType, typename AllocType>
pion::PionBlob< CharType, AllocType >::PionBlob ( AllocType &  blob_alloc,
const std::string &  str 
)
inline

constructs a BLOB using existing string

Parameters
blob_allocallocator used for memory management
strexisting std::string object to copy

Definition at line 168 of file PionBlob.hpp.

References pion::PionBlob< CharType, AllocType >::create(), and pion::PionBlob< CharType, AllocType >::BlobData::get().

Member Function Documentation

template<typename CharType, typename AllocType>
static BlobData* pion::PionBlob< CharType, AllocType >::create ( AllocType &  blob_alloc,
const std::size_t  len 
)
inlinestaticprotected

creates a new BLOB reference object

Parameters
lensize in octets to allocate for the BLOB
Returns
BlobData* pointer to the new BLOB data object (with reference incremented)

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().

template<typename CharType, typename AllocType>
BlobData* pion::PionBlob< CharType, AllocType >::grab ( void  ) const
inlineprotected

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=().

template<typename CharType, typename AllocType>
PionBlob& pion::PionBlob< CharType, AllocType >::operator= ( const PionBlob< CharType, AllocType > &  blob)
inline

assignment operator

Parameters
blobgrabs reference from this existing blob
Returns
reference to this BLOB

Definition at line 182 of file PionBlob.hpp.

References pion::PionBlob< CharType, AllocType >::grab(), and pion::PionBlob< CharType, AllocType >::release().

template<typename CharType, typename AllocType>
void pion::PionBlob< CharType, AllocType >::release ( void  )
inlineprotected
template<typename CharType, typename AllocType>
CharType* pion::PionBlob< CharType, AllocType >::reserve ( AllocType &  blob_alloc,
const std::size_t  len 
)
inline

reserves memory for a new blob without assigning memory

Parameters
blob_allocallocator used for memory management
lensize in octets of the new memory buffer to allocate
Returns
reference to the new BLOB payload (scope should expire before Blob is copied/shared)

Definition at line 232 of file PionBlob.hpp.

References pion::PionBlob< CharType, AllocType >::create(), pion::PionBlob< CharType, AllocType >::BlobData::get(), and pion::PionBlob< CharType, AllocType >::release().

template<typename CharType, typename AllocType>
void pion::PionBlob< CharType, AllocType >::set ( const BlobParams p)
inline

assigns BLOB to existing memory buffer via BlobParams

Parameters
pBlobParams 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(), and pion::PionBlob< CharType, AllocType >::release().

template<typename CharType, typename AllocType>
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

Parameters
blob_allocallocator used for memory management
ptrpointer to a buffer of memory to copy into the BLOB
lensize 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(), and pion::PionBlob< CharType, AllocType >::release().

template<typename CharType, typename AllocType>
void pion::PionBlob< CharType, AllocType >::set ( AllocType &  blob_alloc,
const std::string &  str 
)
inline

assigns BLOB to use an existing string

Parameters
blob_allocallocator used for memory management
strexisting 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(), and pion::PionBlob< CharType, AllocType >::release().


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