CMemoryBuffer Class Reference

Basic standalone OpenViBE memory buffer implementationThis class offers a basic standalone impementation of the OpenViBE::IMemoryBuffer interface. This class can be directly instanciated and used. More...

Inheritance diagram for CMemoryBuffer:
IMemoryBuffer IObject

List of all members.

Public Member Functions

virtual OpenViBE::boolean reserve (const OpenViBE::uint64 ui64Size)
 Reserves some memory for this memory buffer.
virtual OpenViBE::boolean setSize (const OpenViBE::uint64 ui64Size, const OpenViBE::boolean bDiscard)
 Changes the size of this memory buffer.
virtual OpenViBE::uint64 getSize (void) const
 Gets the current size of this memory buffer.
virtual OpenViBE::uint8 * getDirectPointer (void)
 Gets a direct pointer to the byte array for read/write access.
virtual const OpenViBE::uint8 * getDirectPointer (void) const
 Gets a direct pointer to the byte array for read access.
virtual OpenViBE::boolean append (const OpenViBE::uint8 *pBuffer, const OpenViBE::uint64 ui64BufferSize)
 Appends data to this memory buffer.
virtual OpenViBE::boolean append (const OpenViBE::IMemoryBuffer &rMemoryBuffer)
 Appends data to this memory buffer.
Constructors
 CMemoryBuffer (void)
 Default constructor.
 CMemoryBuffer (const OpenViBE::IMemoryBuffer &rMemoryBuffer)
 Copy constructor.
 CMemoryBuffer (const OpenViBE::uint8 *pMemoryBuffer, const OpenViBE::uint64 ui64BufferSize)
 Copy constructor.
virtual ~CMemoryBuffer (void)
 Destructor.

Protected Attributes

OpenViBE::IMemoryBufferm_pMemoryBufferImpl
 Internal implementation.

Detailed Description

Basic standalone OpenViBE memory buffer implementation

This class offers a basic standalone impementation of the OpenViBE::IMemoryBuffer interface. This class can be directly instanciated and used.

Author:
Yann Renard (INRIA/IRISA)
Date:
2007-11-21 Instances of this class use an internal implementation of the OpenViBE::IMemoryBuffer interface and redirect their calls to this implementation.

Constructor & Destructor Documentation

CMemoryBuffer ( void  )

Default constructor.

This constructor builds the internal implementation of this memory buffer.

CMemoryBuffer ( const OpenViBE::IMemoryBuffer rMemoryBuffer)

Copy constructor.

This constructor builds the internal implementation of this memory buffer and initializes it with the actual parameter of the constructor as a copy.

CMemoryBuffer ( const OpenViBE::uint8 *  pMemoryBuffer,
const OpenViBE::uint64  ui64BufferSize 
)

Copy constructor.

This constructor builds the internal implementation of this memory buffer and initializes it with the actual parameter of the constructor as a copy.

virtual ~CMemoryBuffer ( void  ) [virtual]

Destructor.

The internal implementation is released.


Member Function Documentation

virtual OpenViBE::boolean reserve ( const OpenViBE::uint64  ui64Size) [virtual]

Reserves some memory for this memory buffer.

Parameters:
ui64Size[in] : the amount of memory to reserve
Returns:
true in case of success.
false in case of error.

This function reserves some memory space for later use. This does not affect the actual size of the buffer but allows later calls to append not to reallocate the whole buffer.

Note:
if ui64Size is lower than the actual buffer size then true is returned and nothing is done.

Implements IMemoryBuffer.

virtual OpenViBE::boolean setSize ( const OpenViBE::uint64  ui64Size,
const OpenViBE::boolean  bDiscard 
) [virtual]

Changes the size of this memory buffer.

Parameters:
ui64Size[in] : the new size to give to the buffer
bDiscard[in] : tells the reallocation process whether it should presever currently stored data or not
Returns:
true in case of success.
false in case of error.
Note:
On error, the buffer is left unchanged.
If the new size if lower than the current size and bDiscard is true, the buffer is simply truncated to the ui64Size first bytes.
See also:
getSize

Implements IMemoryBuffer.

virtual OpenViBE::uint64 getSize ( void  ) const [virtual]

Gets the current size of this memory buffer.

Returns:
the current size of this memory buffer
See also:
setSize

Implements IMemoryBuffer.

virtual OpenViBE::uint8* getDirectPointer ( void  ) [virtual]

Gets a direct pointer to the byte array for read/write access.

Returns:
a direct pointer to the byte array for read/write access
See also:
getSize

Implements IMemoryBuffer.

virtual const OpenViBE::uint8* getDirectPointer ( void  ) const [virtual]

Gets a direct pointer to the byte array for read access.

Returns:
a direct pointer to the byte array for read access
See also:
getSize

Implements IMemoryBuffer.

virtual OpenViBE::boolean append ( const OpenViBE::uint8 *  pBuffer,
const OpenViBE::uint64  ui64BufferSize 
) [virtual]

Appends data to this memory buffer.

Parameters:
pBuffer[in] : the buffer containing data that should be appended
ui64BufferSize[in] : the buffer size that should be appended
Returns:
true in case of success.
false in case of error.

Implements IMemoryBuffer.

virtual OpenViBE::boolean append ( const OpenViBE::IMemoryBuffer rMemoryBuffer) [virtual]

Appends data to this memory buffer.

Parameters:
rMemoryBuffer[in] : the memory buffer containing data that should be appended
Returns:
true in case of success.
false in case of error.

Reimplemented from IMemoryBuffer.