MsgBuffer Template Definition. This abstracts the behavior of the buffer with respect to the Byte-Order of the message.
More...
#include <msg_buffer.h>
|
| MsgBuffer () |
| Default Constructor.
|
|
| MsgBuffer (size_t n) |
| Fill Constructor. More...
|
|
| MsgBuffer (const MsgBuffer &rhs) |
| Copy Constructor. More...
|
|
| ~MsgBuffer () |
| Destructor.
|
|
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.
|
|
MsgBuffer | clone () const |
| Creates a full copy of the message buffer. More...
|
|
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...
|
|
MsgBuffer & | operator= (const MsgBuffer &rhs) |
| Assignment Operator. More...
|
|
void | resize (size_t n) |
| Resizes the buffer to contain n elements. 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.
|
|
template<typename StorageT>
class Hg::MsgBuffer< StorageT >
MsgBuffer Template Definition. This abstracts the behavior of the buffer with respect to the Byte-Order of the message.
- Template Parameters
-
StorageT | [typename] The storage_t that manages the type of object used in the underlying buffer for the packet data. This policy also provides the capabilities to read/write to the buffer. |
Definition at line 34 of file msg_buffer.h.
template<typename StorageT>
Fill Constructor.
- Parameters
-
n | The number of bytes to allocate for the buffer. |
val | The value to fill each item in the allocated buffer if supplied. |
Definition at line 63 of file msg_buffer.h.
template<typename StorageT>
Copy Constructor.
- Parameters
-
rhs | The input object to be copied. |
- Note
- This object's copy constructor only performs a shallow copy of the message buffer. Use the clone operation to make a separate copy of the buffer.
Definition at line 85 of file msg_buffer.h.
template<typename StorageT>
void Hg::MsgBuffer< StorageT >::assign |
( |
const_pointer |
pBuffer, |
|
|
size_t |
n |
|
) |
| |
|
inline |
Assigns the contents of an incoming raw memory buffer to the message buffer.
- Parameters
-
pBuffer | A memory buffer whose contents will be assigned to this message object. The values of the buffer are copied into the message. |
n | The number of bytes held in p_buffer. |
Definition at line 209 of file msg_buffer.h.
template<typename StorageT>
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 132 of file msg_buffer.h.
template<typename StorageT>
Creates a full copy of the message buffer.
- Returns
- A deep copy of this objects packet buffer.
- Note
- clone performs a buffer allocation according to the storage policy provided to the MsgBuffer. Therefore a new memory buffer is created for the cloned copy to exist within.
Definition at line 451 of file msg_buffer.h.
template<typename StorageT>
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 183 of file msg_buffer.h.
template<typename StorageT>
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 121 of file msg_buffer.h.
template<typename StorageT>
template<typename T >
size_t Hg::MsgBuffer< StorageT >::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
-
value | Accepts the value read from the packet buffer. |
pos | The 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 264 of file msg_buffer.h.
template<typename StorageT>
size_t Hg::MsgBuffer< StorageT >::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
-
pBuffer | Pointer to the first element in the array to be written into. |
length | The number of bytes to read in. pBuffer must contain at least length number of bytes. |
pos | The 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 310 of file msg_buffer.h.
template<typename StorageT>
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 236 of file msg_buffer.h.
template<typename StorageT>
void Hg::MsgBuffer< StorageT >::offset |
( |
std::ptrdiff_t |
new_offset | ) |
|
|
inline |
Assigns a new base offset for memory access to this object.
- Parameters
-
new_offset | The offset from the beginning of the supplied buffer. |
Definition at line 246 of file msg_buffer.h.
template<typename StorageT>
Assignment Operator.
- Parameters
-
rhs | (right-hand side) The input object to be copied. |
- Note
- This object's copy constructor only performs a shallow copy of the message buffer. Use the clone operation to make a separate copy of the buffer.
Definition at line 108 of file msg_buffer.h.
template<typename StorageT>
Resizes the buffer to contain n elements.
- Parameters
-
n | The number of elements to allocate for the buffer. |
val | Optional value to be copied into each element allocated. |
Definition at line 165 of file msg_buffer.h.
template<typename StorageT>
template<typename T >
size_t Hg::MsgBuffer< StorageT >::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
-
value | Contains the value to write to the packet buffer. |
pos | The 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 354 of file msg_buffer.h.
template<typename StorageT>
template<typename InputIt >
size_t Hg::MsgBuffer< StorageT >::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
-
first | Contains the first item to write to the buffer. |
last | Contains 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
-
pos | The 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 405 of file msg_buffer.h.
template<typename StorageT>
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 143 of file msg_buffer.h.
The documentation for this class was generated from the following file: