Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::Buffer< T > Class Template Reference

Buffer wraps a C-style array so that it can be used with Ptr. More...

#include <PhxBuffer.h>

Inheritance diagram for Phx::Buffer< T >:

Phx::LockedPtrInterface< Buffer< T > > List of all members.

Public Member Functions

 Buffer (const T *data, uint32_t size)
 Constructs a new buffer with a copy of the given data.
 Buffer (const std::vector< T > &array)
 Constructs a new buffer with a copy of the data in array.
 Buffer (uint32_t size=0)
 Constructs a new buffer, setting its initial buffer size.
uint32_t size () const
void size (uint32_t len)
 Sets the size of the buffer.
T * buffer ()
const T * buffer () const
void buffer (const T *buffer, uint32_t len)
 Overwrites the buffer with a copy of buffer.

Detailed Description

template<typename T>
class Phx::Buffer< T >

Buffer wraps a C-style array so that it can be used with Ptr.

The accessors size() and buffer() allow direct access to the data and control over its size. No concurrency protection (locking) is provided.


Constructor & Destructor Documentation

template<typename T>
Phx::Buffer< T >::Buffer uint32_t  size = 0  )  [inline]
 

Constructs a new buffer, setting its initial buffer size.

A standard way to use the Buffer class is to use this constructor allocate a buffer up front, then fill the buffer with data by retrieving the raw pointer to the array from buffer().

Parameters:
size The size of the buffer to allocate.


Member Function Documentation

template<typename T>
void Phx::Buffer< T >::buffer const T *  buffer,
uint32_t  len
[inline]
 

Overwrites the buffer with a copy of buffer.

Parameters:
buffer Pointer to data to be copied. If 0, the buffer will be resized as requested, but no data is copied.
len The size of the new buffer. If buffer is nonzero, then this many elements are copied from buffer.
Note:
If you wish to resize the buffer without copying the previous data, as is done by size(uint32_t), you can call this method setting 0 for buffer and the new size in len.

template<typename T>
void Phx::Buffer< T >::size uint32_t  len  )  [inline]
 

Sets the size of the buffer.

This will truncate the data if the new size is smaller, or default-construct new elements (preserving the old ones) if the new size is larger.

Note:
As in standard C++, default-construction of POD types does not initialize them.


The documentation for this class was generated from the following file:
Generated on Mon Jul 10 19:45:30 2006 for Phoenix OSFS by  doxygen 1.4.2