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

Storage Policy implementation for contiguous memory buffers. More...

#include <storage_policy.h>

Inherits integral_constant< bool, IsBufferedT >.

Static Public Member Functions

static s_pointer allocate (size_t size)
 Allocates a new storage buffer for this policy. More...
 
static void deallocate (s_pointer &spBuffer)
 Releases memory buffers allocated through this policy. More...
 
static bool read (const_pointer pBuffer, void *pStorage, size_t size, std::ptrdiff_t offset)
 Performs a storage read operation for this policy. More...
 
static bool write (pointer pBuffer, const void *pStorage, size_t size, std::ptrdiff_t offset)
 Performs a storage write operation for this policy. More...
 

Detailed Description

template<bool IsBufferedT>
struct Hg::StoragePolicy< IsBufferedT >

Storage Policy implementation for contiguous memory buffers.

Template Parameters
IsBufferedTIndicates if the StoragePolicy desires data to be buffered, or accessed on demand.

Note: The policy itself is not responsible, and does not buffer the data. It is an indication to users of the policy, for how the best way to access the storage memory.

For example, storage policies developed to interface directly with hardware mapped memory access would indicate not to be buffered. However, a network packet buffer, which can vary in size between calls would indicate buffering is preferred.

Definition at line 69 of file storage_policy.h.

Member Function Documentation

template<bool IsBufferedT>
static s_pointer Hg::StoragePolicy< IsBufferedT >::allocate ( size_t  size)
inlinestatic

Allocates a new storage buffer for this policy.

Parameters
sizeThe number of bytes requested for the allocation.
Returns
A shared_ptr that contains the allocated container object. If the allocation failed, the return value will be invalid.

Definition at line 87 of file storage_policy.h.

template<bool IsBufferedT>
static void Hg::StoragePolicy< IsBufferedT >::deallocate ( s_pointer &  spBuffer)
inlinestatic

Releases memory buffers allocated through this policy.

Parameters
sizeThe number of bytes requested for the allocation.

Definition at line 99 of file storage_policy.h.

template<bool IsBufferedT>
static bool Hg::StoragePolicy< IsBufferedT >::read ( const_pointer  pBuffer,
void *  pStorage,
size_t  size,
std::ptrdiff_t  offset 
)
inlinestatic

Performs a storage read operation for this policy.

Parameters
sp_bufferA shared pointer to a buffer previously allocated by this storage policies Allocate member function.
p_storageThe source memory buffer to read from.
sizeThe number of elements read from the buffer.
offsetA starting offset from the beginning of the specified read/write buffer.
Returns
This function will always return true. Other policy implementations may need to indicate failure.

Definition at line 121 of file storage_policy.h.

template<bool IsBufferedT>
static bool Hg::StoragePolicy< IsBufferedT >::write ( pointer  pBuffer,
const void *  pStorage,
size_t  size,
std::ptrdiff_t  offset 
)
inlinestatic

Performs a storage write operation for this policy.

Parameters
sp_bufferA shared pointer to a buffer previously allocated by this storage policies Allocate member function.
p_storageThe source memory buffer to supply the data written into sp_buffer;
sizeThe number of elements write into the buffer.
offsetA starting offset from the beginning of the specified read/write buffer.
Returns
This function will always return true. Other policy implementations may need to indicate failure.

Definition at line 148 of file storage_policy.h.


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