NLMISC::CMemStreamBuffer Class Reference

This class implement a copy on write behavior for memory stream buffer. More...

#include <mem_stream.h>

List of all members.

Classes

struct  TMemStreamBuffer

Public Types

typedef CObjectVector< uint8,
false > 
TBuffer

Public Member Functions

 CMemStreamBuffer ()
 constructor, allocate a shared buffer
const TBuffergetBuffer () const
 Return a read accessor to the buffer.
TBuffergetBufferWrite ()
 Return a write accessor to the buffer, create acopy it if more than one CMemStreamBuffer reference then buffer.
void swap (CMemStreamBuffer &other)
 Exchange the buffer of two CMemStreamBuffer (just swap memory pointer).

Public Attributes

uint32 Pos

Private Types

typedef CSmartPtr
< TMemStreamBuffer
TMemStreamBufferPtr

Private Attributes

TMemStreamBufferPtr _SharedBuffer

Detailed Description

This class implement a copy on write behavior for memory stream buffer.

The goal is to allow buffer sharing between CMemStream object, so that a CMemStream can be copied or passed by value as input/output parameter without copying the data buffer (thus making a CMemStrem copy almost free). This class reference a TMemStreamBuffer object with a smart pointer, when some code call the getBufferWrite() method to obtain write access to the memory buffer, if the ref count is more than 1, then we make a copy of the internal buffer for the current object.

Boris Boucher

Definition at line 56 of file mem_stream.h.


Member Typedef Documentation

Definition at line 59 of file mem_stream.h.

Definition at line 67 of file mem_stream.h.


Constructor & Destructor Documentation

NLMISC::CMemStreamBuffer::CMemStreamBuffer (  )  [inline]

constructor, allocate a shared buffer

Definition at line 76 of file mem_stream.h.

References _SharedBuffer, and Pos.


Member Function Documentation

const TBuffer& NLMISC::CMemStreamBuffer::getBuffer (  )  const [inline]
TBuffer& NLMISC::CMemStreamBuffer::getBufferWrite (  )  [inline]
void NLMISC::CMemStreamBuffer::swap ( CMemStreamBuffer other  )  [inline]

Exchange the buffer of two CMemStreamBuffer (just swap memory pointer).

Definition at line 103 of file mem_stream.h.

References _SharedBuffer, and Pos.

Referenced by NLMISC::CMemStream::swap().


Member Data Documentation

Definition at line 69 of file mem_stream.h.

Referenced by CMemStreamBuffer(), getBuffer(), getBufferWrite(), and swap().


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

Generated on Thu Jan 7 08:30:18 2010 for NeL by  doxygen 1.6.1