Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
Hg::MsgBuffer< BufferedStaticStoragePolicy > Class Template Reference

(Static) MsgBuffer Template Definition. This class is a specialization of the template MsgBuffer, and uses a static_storage_policy. More...

#include <static_msg_buffer.h>

Public Member Functions

 MsgBuffer ()
 Default Constructor.
 
void assign (const_pointer pBuffer, size_t n)
 Assigns the contents of an incoming raw memory buffer to the message buffer. More...
 
size_t capacity () const
 Return the number of bytes reserved for use by this buffer. More...
 
void clear ()
 Releases any resources associated with this object.
 
const_pointer data () const
 Provides access to the packed memory buffer. More...
 
bool empty () const
 Indicates if memory is currently managed by this buffer. More...
 
template<typename T >
size_t get_data (T &value, std::ptrdiff_t pos) const
 Parameterized function that returns data from a specified offset in the buffer. More...
 
size_t get_range (void *pBuffer, size_t length, size_t pos) const
 Parameterized function that reads a range of data from the buffer. More...
 
std::ptrdiff_t offset () const
 Returns the offset used to access the buffer. More...
 
void offset (std::ptrdiff_t new_offset)
 Assigns a new base offset for memory access to this object. More...
 
void resize (size_t n)
 Resizes the buffer to contain n elements. This function is not supported for this fixed size buffer. More...
 
template<typename T >
size_t set_data (const T &value, size_t pos)
 Parameterized function that writes data to a specified offset in the buffer. More...
 
template<typename InputIt >
size_t set_range (InputIt first, InputIt last, size_t pos)
 Parameterized function that writes a range of data to the buffer. More...
 
size_t size () const
 Reports the current size of the buffer in use. More...
 
void zero ()
 Zeroes the contents of the buffer if they have been assigned.
 

Detailed Description

template<>
class Hg::MsgBuffer< BufferedStaticStoragePolicy >

(Static) MsgBuffer Template Definition. This class is a specialization of the template MsgBuffer, and uses a static_storage_policy.

Definition at line 24 of file static_msg_buffer.h.

Member Function Documentation

void Hg::MsgBuffer< BufferedStaticStoragePolicy >::assign ( const_pointer  pBuffer,
size_t  n 
)
inline

Assigns the contents of an incoming raw memory buffer to the message buffer.

Parameters
pBufferA memory buffer whose contents will be assigned to this message object. The values of the buffer are copied into the message.
nThe number of bytes held in p_buffer.

Definition at line 140 of file static_msg_buffer.h.

size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::capacity ( ) const
inline

Return the number of bytes reserved for use by this buffer.

Returns
The allocated buffer size is returned. This packet buffer must be valid for a non-zero value to be returned.

Definition at line 67 of file static_msg_buffer.h.

const_pointer Hg::MsgBuffer< BufferedStaticStoragePolicy >::data ( ) const
inline

Provides access to the packed memory buffer.

Returns
Returns a constant pointer to the buffer that contains the packed memory. 0 is returned if there is no memory associated with the buffer.

Definition at line 119 of file static_msg_buffer.h.

bool Hg::MsgBuffer< BufferedStaticStoragePolicy >::empty ( ) const
inline

Indicates if memory is currently managed by this buffer.

Returns
true - The buffer is empty. false- There is memory allocated and managed by this buffer.

Definition at line 55 of file static_msg_buffer.h.

template<typename T >
size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::get_data ( T &  value,
std::ptrdiff_t  pos 
) const
inline

Parameterized function that returns data from a specified offset in the buffer.

Template Parameters
T[typename] The parameterized type to be returned to the caller.
Parameters
valueAccepts the value read from the packet buffer.
posThe offset from the beginning of the buffer to read the output value.
Returns
The number of bytes read from the buffer is returned. It is possible for a successful case to return 0.

Definition at line 184 of file static_msg_buffer.h.

size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::get_range ( void *  pBuffer,
size_t  length,
size_t  pos 
) const
inline

Parameterized function that reads a range of data from the buffer.

Template Parameters
T[typename] The parameterized type to be read by the caller.
Parameters
pBufferPointer to the first element in the array to be written into.
lengthThe number of bytes to read in. pBuffer must contain at least length number of bytes.
posThe offset from the beginning of the buffer to read the input value.
Returns
The number of bytes read from the buffer is returned. It is possible for a successful case to return 0.

Definition at line 230 of file static_msg_buffer.h.

std::ptrdiff_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::offset ( ) const
inline

Returns the offset used to access the buffer.

Returns the offset used to access the buffer relative to the first index in the buffer. The default offset is zero. Alternate offsets are allowed to facilitate nested packet structures as well as dynamically formatted structures.

Returns
A number of bytes greater than 0 is returned.

Definition at line 156 of file static_msg_buffer.h.

void Hg::MsgBuffer< BufferedStaticStoragePolicy >::offset ( std::ptrdiff_t  new_offset)
inline

Assigns a new base offset for memory access to this object.

Parameters
new_offsetThe offset from the beginning of the supplied buffer.

Definition at line 166 of file static_msg_buffer.h.

void Hg::MsgBuffer< BufferedStaticStoragePolicy >::resize ( size_t  n)
inline

Resizes the buffer to contain n elements. This function is not supported for this fixed size buffer.

Parameters
nThe number of elements to allocate for the buffer.
valOptional value to be copied into each element allocated.

Definition at line 101 of file static_msg_buffer.h.

template<typename T >
size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::set_data ( const T &  value,
size_t  pos 
)
inline

Parameterized function that writes data to a specified offset in the buffer.

Template Parameters
T[typename] The parameterized type to be written by the caller.
Parameters
valueContains the value to write to the packet buffer.
posThe offset from the beginning of the buffer to write the input value.
Returns
The number of bytes written to the buffer is returned. It is possible for a successful case to return 0.

Definition at line 274 of file static_msg_buffer.h.

template<typename InputIt >
size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::set_range ( InputIt  first,
InputIt  last,
size_t  pos 
)
inline

Parameterized function that writes a range of data to the buffer.

Template Parameters
T[typename] The parameterized type to be written by the caller.
Parameters
firstContains the first item to write to the buffer.
lastContains the item one past the last item to write. This item may point to an element that is not valid to de-reference. Similar to C+++ Standard Library.

Last must be greater than than the first time, and they must be part of the same range of elements otherwise the behavior is undefined.

Parameters
posThe offset from the beginning of the buffer to write the input value.
Returns
The number of bytes written to the buffer is returned. It is possible for a successful case to return 0.

Definition at line 325 of file static_msg_buffer.h.

size_t Hg::MsgBuffer< BufferedStaticStoragePolicy >::size ( ) const
inline

Reports the current size of the buffer in use.

Returns
The number of bytes in use in the allocated buffer. If there is no internal buffer, 0 is returned.

Definition at line 78 of file static_msg_buffer.h.


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