Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

strmod::strmod::BufferChunk Class Reference

This is an abstract base class for StrChunks that are really just bags of bytes. More...

#include <StrMod/BufferChunk.h>

Inheritance diagram for strmod::strmod::BufferChunk:

Inheritance graph
[legend]
List of all members.

Public Methods

 BufferChunk ()
 As a convenience, initialize the protected variables maintained by the derived classes.

virtual ~BufferChunk ()
 Doesn't delete any storage whatsoever.

virtual int AreYouA (const lcore::ClassIdent &cid) const
 Asks if a class is of a particular type, or publicly derived from that type.

virtual bool invariant () const
 This should ALWAYS return true. It says whether the class invariant holds or not.

virtual void printState (std::ostream &os) const
virtual unsigned int Length () const
 Number of octets this chunk takes up. May be deprecated.

U1Byte & operator[] (unsigned int bnum)
 Returns a reference to the byte at index bnum.

void * getVoidP ()
 Gets a void pointer to at least Length() bytes of data.

U1Byte * getCharP ()
 Gets a U1Byte pointer to at least Length() bytes of data.

virtual void resize (unsigned int newsize)=0 throw (std::bad_alloc)
 Change the size of the chunk to newsize.


Static Public Attributes

const STR_ClassIdent identifier
 Globally unique identifier for this class.


Protected Methods

virtual const lcore::ClassIdent * i_GetIdent () const
 Returns the class identifier for the class the object actually is.

virtual void acceptVisitor (ChunkVisitor &visitor) throw (ChunkVisitor::halt_visitation)
 Accept a ChunkVisitor, and maybe lead it through your children.


Protected Attributes

void * buf_
 buf_ is expected to be maintained by the derived class.

unsigned int buflen_
 buflen_ is expected to be maintained by the derived class.


Detailed Description

This is an abstract base class for StrChunks that are really just bags of bytes.

Definition at line 46 of file BufferChunk.h.


Constructor & Destructor Documentation

virtual strmod::strmod::BufferChunk::~BufferChunk   [inline, virtual]
 

Doesn't delete any storage whatsoever.

Since this is an abstract class that doesn't ever actually allocate any storage, it's left to the derived classes to do the actual deletion.

Definition at line 63 of file BufferChunk.h.


Member Function Documentation

int strmod::strmod::BufferChunk::AreYouA const lcore::ClassIdent &    cid const [inline, virtual]
 

Asks if a class is of a particular type, or publicly derived from that type.

Overriden in every derived class (with a static identifier member) to compare against the identifier, then call the AreYouA methods of all the superclasses.

Parameters:
cid Usually <class>::identifier for the class you want to ask if the object is an instance of.

Reimplemented from strmod::lcore::Debugable.

Reimplemented in strmod::strmod::DynamicBuffer, and strmod::strmod::PreAllocBufferBase.

Definition at line 134 of file BufferChunk.h.

lcore::U1Byte * strmod::strmod::BufferChunk::getCharP   [inline]
 

Gets a U1Byte pointer to at least Length() bytes of data.

This guarantees that you can read or write to any byte in the valid range using this pointer as long as you make no calls to resize() in between accesses.

Definition at line 154 of file BufferChunk.h.

void * strmod::strmod::BufferChunk::getVoidP   [inline]
 

Gets a void pointer to at least Length() bytes of data.

This guarantees that you can read or write to any byte in the valid range using this pointer as long as you make no calls to resize() in between accesses.

Definition at line 149 of file BufferChunk.h.

virtual const lcore::ClassIdent* strmod::strmod::BufferChunk::i_GetIdent   const [inline, protected, virtual]
 

Returns the class identifier for the class the object actually is.

Should always be overridden in any class that has a static identifier member.

Reimplemented from strmod::lcore::Debugable.

Reimplemented in strmod::strmod::DynamicBuffer, and strmod::strmod::PreAllocBufferBase.

Definition at line 101 of file BufferChunk.h.

bool strmod::strmod::BufferChunk::invariant   const [inline, virtual]
 

This should ALWAYS return true. It says whether the class invariant holds or not.

Your class invariant should be as strict as possible. The class invariant is used to detect when the class goes into a bad state, so all possible bad states should be caught by the invariant.

Implements strmod::lcore::Debugable.

Reimplemented in strmod::strmod::PreAllocBufferBase, strmod::strmod::PreAllocBuffer< TInitialAlloc >, and strmod::strmod::PreAllocBuffer< 48 >.

Definition at line 139 of file BufferChunk.h.

lcore::U1Byte & strmod::strmod::BufferChunk::operator[] unsigned int    bnum [inline]
 

Returns a reference to the byte at index bnum.

If bnum is out of range, the behavior is undefined.

Definition at line 144 of file BufferChunk.h.

virtual void strmod::strmod::BufferChunk::resize unsigned int    newsize throw (std::bad_alloc) [pure virtual]
 

Change the size of the chunk to newsize.

Throws bad_alloc if the allocation fails, just like operator new.

Implemented in strmod::strmod::DynamicBuffer, strmod::strmod::PreAllocBufferBase, strmod::strmod::PreAllocBuffer< TInitialAlloc >, and strmod::strmod::PreAllocBuffer< 48 >.


Member Data Documentation

void* strmod::strmod::BufferChunk::buf_ [protected]
 

buf_ is expected to be maintained by the derived class.

This exists so that the above inline functions are truly inline. It's only allowed to change in the constructor, or in respone to the resize() method being called.

buf_ is required to be non-null when buflen_ is greater than 0.

Definition at line 115 of file BufferChunk.h.

unsigned int strmod::strmod::BufferChunk::buflen_ [protected]
 

buflen_ is expected to be maintained by the derived class.

This exist so that the above inline functions are truly inline. It's only allowed to change in the constructor, or in respone to the resize() method being called.

Definition at line 122 of file BufferChunk.h.

const STR_ClassIdent strmod::strmod::BufferChunk::identifier [static]
 

Globally unique identifier for this class.

Every class that might need to be identified should have a public static const identifier object in it.

Reimplemented from strmod::lcore::Debugable.

Reimplemented in strmod::strmod::DynamicBuffer, and strmod::strmod::PreAllocBufferBase.


The documentation for this class was generated from the following files:
Generated on Wed Jan 29 00:32:53 2003 for libNet by doxygen1.3-rc1