CBuffer Class Reference
[Opaque user dataI/O BuffersAsynchronous I/O]

Inheritance diagram for CBuffer:

Inheritance graph
[legend]
Collaboration diagram for CBuffer:

Collaboration graph
[legend]

List of all members.


Detailed Description

An implementation of the IBuffer interface which includes its own custom new and delete functionality so that the memory for the buffer and the memory for the rest of the class are allocated as a single block of memory. Note that the 'user data' is also allocated as part of the main buffer memory and the class knows how to access the various memory areas correctly.

Public Types

typedef unsigned short Operation
typedef size_t SequenceNumber
typedef unsigned long BufferSize
typedef unsigned short UserDataIndex

Public Member Functions

virtual WSABUF * GetWSABUF () const
 Return a pointer to a WSABUF structure so that the buffer can be used in overlapped send and receive calls.
virtual BufferSize GetUsed () const
 Returns how much space has been used in the buffer. That is, the current position of the insertion point.
virtual BufferSize GetSize () const
 Returns the size of the buffer.
virtual const BYTE * GetMemory () const
 Returns a pointer to the bytes in the buffer.
virtual void SetupZeroByteRead ()
 Sets up the WSABUF for a zero byte read, that is a read that doesn't actually read any data.
virtual void SetupRead ()
 Sets up the WSABUF for a read.
virtual void SetupWrite ()
 Sets up the WSABUF for a write.
virtual void AddData (const char *const pData, const BufferSize dataLength)
virtual void AddData (const BYTE *const pData, const BufferSize dataLength)
virtual void AddData (const BYTE data)
 Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.
virtual void Use (const BufferSize dataUsed)
virtual IBufferSplitBuffer (const BufferSize bytesToRemove)
 Splits the buffer into two. Allocates a new buffer and copies bytesToRemove bytes from the front of this buffer into the new buffer and then moves the rest of the contents of this buffer along to fill the gap. Returns a new buffer, remember to call Release() on it when you're done with it.
virtual IBufferAllocateNewBuffer () const
 Allocates a new instance of an IBuffer from the same buffer allocator that was used to allocate this buffer.
virtual void ConsumeAndRemove (const BufferSize bytesToRemove)
 Removes bytesToRemove bytes from the front of this buffer and moves the rest of the contents of the buffer to fill the gap.
virtual void Empty ()
 Move the insertion point to the start of the buffer; thus emptying it.
virtual void AddRef ()
virtual void Release ()
virtual Operation GetOperation () const
 Retrieves the arbitrary "operation" value from the buffer.
virtual void SetOperation (const Operation operation)
virtual SequenceNumber GetSequenceNumber () const
 Retrieves the arbitrary "sequence number" value from the buffer.
virtual void SetSequenceNumber (const SequenceNumber sequenceNumber)
virtual void * GetUserPointer (const UserDataIndex index) const
virtual void SetUserPointer (const UserDataIndex index, void *pData)
virtual ULONG_PTR GetUserData (const UserDataIndex index) const
virtual void SetUserData (const UserDataIndex index, const ULONG_PTR data)
virtual void SetOperation (const Operation operation)=0
 Sets an arbitrary "operation" value in the buffer. This value is generally used to determine which overlapped operation the buffer was involed in.
virtual void SetSequenceNumber (const SequenceNumber sequenceNumber)=0
 Sets an arbitrary "sequence number" value in the buffer. This value is generally used to maintain an ordering of overlapped operations.
virtual void AddData (const char *const pData, const BufferSize dataLength)=0
 Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.
virtual void AddData (const BYTE *const pData, const BufferSize dataLength)=0
 Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.
virtual void Use (const BufferSize dataUsed)=0
 Move the insertion point without adding any data.
DWORD GetOverlappedResult (HANDLE handle)
 Calls GetOverlappedResult() on this OVERLAPPED for the supplied HANDLE and returns the number of bytes transferred. Throws an exception on failure.
DWORD GetOverlappedResult (SOCKET socket)
 Calls GetOverlappedResult() on this OVERLAPPED for the supplied SOCKET and returns the number of bytes transferred. Throws an exception on failure.
virtual void * GetUserPointer (const UserDataIndex index) const =0
 Access the data stored at the specified index as a void pointer.
virtual void SetUserPointer (const UserDataIndex index, void *pData)=0
 Update the data stored at the specified index as a void pointer.
virtual ULONG_PTR GetUserData (const UserDataIndex index) const =0
 Access the data stored at the specified index as an unsigned long.
virtual void SetUserData (const UserDataIndex index, const ULONG_PTR data)=0
 Update the data stored at the specified index as an unsigned long.
Node * Next () const
 Return the next node in the list.
void Next (Node *pNext)
 Set the given node to be this nodes 'next node'.
void RemoveFromList ()
 If this node is currently in a list then it is removed.
bool InList (const CNodeList &list) const
 Returns true if this node is currently in the specified list.
bool InList () const
 Returns true if this node is currently in any list.

Friends

class CBufferAllocator
 Needs to be a friend so that it can new and delete us.

Member Typedef Documentation

typedef unsigned short Operation [inherited]

typedef size_t SequenceNumber [inherited]

typedef unsigned long BufferSize [inherited]

typedef unsigned short UserDataIndex [inherited]


Member Function Documentation

WSABUF * GetWSABUF (  )  const [virtual]

Return a pointer to a WSABUF structure so that the buffer can be used in overlapped send and receive calls.

Implements IBuffer.

IBufferBase::BufferSize GetUsed (  )  const [virtual]

Returns how much space has been used in the buffer. That is, the current position of the insertion point.

Implements IBufferBase.

IBufferBase::BufferSize GetSize (  )  const [virtual]

Returns the size of the buffer.

Implements IBufferBase.

const BYTE * GetMemory (  )  const [virtual]

Returns a pointer to the bytes in the buffer.

Implements IBufferBase.

void SetupZeroByteRead (  )  [virtual]

Sets up the WSABUF for a zero byte read, that is a read that doesn't actually read any data.

Implements IBuffer.

void SetupRead (  )  [virtual]

Sets up the WSABUF for a read.

Implements IBuffer.

void SetupWrite (  )  [virtual]

Sets up the WSABUF for a write.

Implements IBuffer.

void AddData ( const char *const   pData,
const BufferSize  dataLength 
) [virtual]

void AddData ( const BYTE *const   pData,
const BufferSize  dataLength 
) [virtual]

void AddData ( const BYTE  data  )  [virtual]

Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.

Implements IBufferBase.

void Use ( const BufferSize  dataUsed  )  [virtual]

IBuffer * SplitBuffer ( const BufferSize  bytesToRemove  )  [virtual]

Splits the buffer into two. Allocates a new buffer and copies bytesToRemove bytes from the front of this buffer into the new buffer and then moves the rest of the contents of this buffer along to fill the gap. Returns a new buffer, remember to call Release() on it when you're done with it.

Implements IBuffer.

IBuffer * AllocateNewBuffer (  )  const [virtual]

Allocates a new instance of an IBuffer from the same buffer allocator that was used to allocate this buffer.

Implements IBuffer.

void ConsumeAndRemove ( const BufferSize  bytesToRemove  )  [virtual]

Removes bytesToRemove bytes from the front of this buffer and moves the rest of the contents of the buffer to fill the gap.

Implements IBuffer.

void Empty (  )  [virtual]

Move the insertion point to the start of the buffer; thus emptying it.

Implements IBufferBase.

void AddRef (  )  [virtual]

Implements IBuffer.

void Release (  )  [virtual]

Implements IBuffer.

IBuffer::Operation GetOperation (  )  const [virtual]

Retrieves the arbitrary "operation" value from the buffer.

Implements IBuffer.

void SetOperation ( const Operation  operation  )  [virtual]

IBuffer::SequenceNumber GetSequenceNumber (  )  const [virtual]

Retrieves the arbitrary "sequence number" value from the buffer.

Implements IBuffer.

void SetSequenceNumber ( const SequenceNumber  sequenceNumber  )  [virtual]

void * GetUserPointer ( const UserDataIndex  index  )  const [virtual]

void SetUserPointer ( const UserDataIndex  index,
void *  pData 
) [virtual]

ULONG_PTR GetUserData ( const UserDataIndex  index  )  const [virtual]

void SetUserData ( const UserDataIndex  index,
const ULONG_PTR  data 
) [virtual]

virtual void SetOperation ( const Operation  operation  )  [pure virtual, inherited]

Sets an arbitrary "operation" value in the buffer. This value is generally used to determine which overlapped operation the buffer was involed in.

virtual void SetSequenceNumber ( const SequenceNumber  sequenceNumber  )  [pure virtual, inherited]

Sets an arbitrary "sequence number" value in the buffer. This value is generally used to maintain an ordering of overlapped operations.

virtual void AddData ( const char *const   pData,
const BufferSize  dataLength 
) [pure virtual, inherited]

Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.

virtual void AddData ( const BYTE *const   pData,
const BufferSize  dataLength 
) [pure virtual, inherited]

Adds data to the buffer at the current insertion point and moves the insertion point forward by the amount of data added. Throws an exception if there isn't enough space left in the buffer to add all of the data.

virtual void Use ( const BufferSize  dataUsed  )  [pure virtual, inherited]

Move the insertion point without adding any data.

DWORD GetOverlappedResult ( HANDLE  handle  )  [inherited]

Calls GetOverlappedResult() on this OVERLAPPED for the supplied HANDLE and returns the number of bytes transferred. Throws an exception on failure.

DWORD GetOverlappedResult ( SOCKET  socket  )  [inherited]

Calls GetOverlappedResult() on this OVERLAPPED for the supplied SOCKET and returns the number of bytes transferred. Throws an exception on failure.

virtual void* GetUserPointer ( const UserDataIndex  index  )  const [pure virtual, inherited]

Access the data stored at the specified index as a void pointer.

Implemented in TAsyncSocket< JetByteTools::Socket::IPoolableDatagramSocket, JetByteTools::Socket::IDatagramSocketConnectionManager, JetByteTools::Socket::IDatagramSocketCallback >, TAsyncSocket< JetByteTools::Socket::IPoolableStreamSocket, JetByteTools::Socket::IStreamSocketConnectionManager, JetByteTools::Socket::IStreamSocketCallback >, and TAsyncSocket< JetByteTools::Socket::IPoolableDatagramServerSocket, JetByteTools::Socket::IDatagramServerSocketConnectionManager, JetByteTools::Socket::IDatagramServerSocketCallback >.

virtual void SetUserPointer ( const UserDataIndex  index,
void *  pData 
) [pure virtual, inherited]

Update the data stored at the specified index as a void pointer.

Implemented in TAsyncSocket< JetByteTools::Socket::IPoolableDatagramSocket, JetByteTools::Socket::IDatagramSocketConnectionManager, JetByteTools::Socket::IDatagramSocketCallback >, TAsyncSocket< JetByteTools::Socket::IPoolableStreamSocket, JetByteTools::Socket::IStreamSocketConnectionManager, JetByteTools::Socket::IStreamSocketCallback >, and TAsyncSocket< JetByteTools::Socket::IPoolableDatagramServerSocket, JetByteTools::Socket::IDatagramServerSocketConnectionManager, JetByteTools::Socket::IDatagramServerSocketCallback >.

virtual ULONG_PTR GetUserData ( const UserDataIndex  index  )  const [pure virtual, inherited]

Access the data stored at the specified index as an unsigned long.

Implemented in TAsyncSocket< JetByteTools::Socket::IPoolableDatagramSocket, JetByteTools::Socket::IDatagramSocketConnectionManager, JetByteTools::Socket::IDatagramSocketCallback >, TAsyncSocket< JetByteTools::Socket::IPoolableStreamSocket, JetByteTools::Socket::IStreamSocketConnectionManager, JetByteTools::Socket::IStreamSocketCallback >, and TAsyncSocket< JetByteTools::Socket::IPoolableDatagramServerSocket, JetByteTools::Socket::IDatagramServerSocketConnectionManager, JetByteTools::Socket::IDatagramServerSocketCallback >.

virtual void SetUserData ( const UserDataIndex  index,
const ULONG_PTR  data 
) [pure virtual, inherited]

Update the data stored at the specified index as an unsigned long.

Implemented in TAsyncSocket< JetByteTools::Socket::IPoolableDatagramSocket, JetByteTools::Socket::IDatagramSocketConnectionManager, JetByteTools::Socket::IDatagramSocketCallback >, TAsyncSocket< JetByteTools::Socket::IPoolableStreamSocket, JetByteTools::Socket::IStreamSocketConnectionManager, JetByteTools::Socket::IStreamSocketCallback >, and TAsyncSocket< JetByteTools::Socket::IPoolableDatagramServerSocket, JetByteTools::Socket::IDatagramServerSocketConnectionManager, JetByteTools::Socket::IDatagramServerSocketCallback >.

CNodeList::Node * Next (  )  const [inherited]

Return the next node in the list.

void Next ( Node pNext  )  [inherited]

Set the given node to be this nodes 'next node'.

void RemoveFromList (  )  [inherited]

If this node is currently in a list then it is removed.

bool InList ( const CNodeList list  )  const [inherited]

Returns true if this node is currently in the specified list.

bool InList (  )  const [inherited]

Returns true if this node is currently in any list.


Friends And Related Function Documentation

friend class CBufferAllocator [friend]

Needs to be a friend so that it can new and delete us.


Generated on Tue Oct 2 15:45:24 2007 for JetByte Tools - v5.2 by  doxygen 1.5.3