buffer_base Class Reference

The base class for buffers to be managed by this library. More...

#include <buffer_base.h>

Inheritance diagram for buffer_base:

Inheritance graph
[legend]
Collaboration diagram for buffer_base:

Collaboration graph
[legend]
List of all members.

Public Types

enum  outcomes {
  OKAY = common::OKAY, IN_USE = common::IN_USE, OUT_OF_MEMORY = common::OUT_OF_MEMORY, BAD_INPUT = common::BAD_INPUT,
  NO_SPACE = common::NO_SPACE, INCOMPLETE = common::INCOMPLETE, NOT_FOUND = common::NOT_FOUND
}
 outcomes represent how a buffer operation has completed. More...
enum  release_style { RESET_STATUS, KEEP_STATUS }

Public Member Functions

virtual ~buffer_base ()
 should release any storage used by the buffer.
virtual bool alive () const=0
 returns true if this buffer is still alive.
virtual int packets () const=0
 the number of packets in this buffer.
virtual buffer_key key () const=0
 observe the key for this buffer.
virtual void set_key (const buffer_key &to_set)=0
 modify the key for this buffer.
virtual outcome store_packet (int packet_number, const byte_array &buffer)=0
 puts a packet into the buffer at the "packet_number"th position.
virtual byte_array get_packet (int packet_number) const=0
 returns a packet from the buffer.
virtual int packet_length (int packet_number) const=0
 returns the length of a particular packet.
virtual bool whole () const=0
 returns true if the entire buffer has been stored.
virtual bool empty () const=0
 returns true if the buffer has no packets stored yet.
virtual int full_length (int offset=0) const =0
 returns the full length of this buffer, ignoring first "offset" bytes.
virtual int guess_size (int offset=0)=0
 provides an estimate of what the full size will eventually be.
virtual bool did_estimate () const=0
 returns true if we have previously estimated a size for this buffer.
virtual void reset_estimate ()=0
 tosses our earlier estimate of the buffer's size.
virtual int estimate () const=0
 returns our estimate, if we've made one.
virtual outcome dump (byte_array &storage_location, int offset=0)=0
 stuffs the entire buffer into contiguous memory at "storage_location".
virtual void release (int packet_number, release_style status_handling=KEEP_STATUS)=0
 frees the storage for the "packet_number"th packet.
virtual void release ()=0
 frees the entire buffer, returning it to an unallocated state.
virtual istring text_form () const=0
 returns a text string representing the state of the buffer.
virtual istring detailed_form (bool really_detailed=false) const=0
 returns a more detailed text string for this buffer.
virtual time_stamp last_add () const=0
 returns the last time that the buffer was added to.
virtual void set_last_add (const time_stamp &new_last_add)=0
 sets the last time that the buffer was added to.
virtual bool owner_alerted () const=0
 records whether the buffer's owner was alerted to completion.
virtual void set_alerted (bool owner_alerted)=0
 records that the owner was alerted, if "owner_alerted" is true.
virtual void get_attachment (byte_array &storage) const =0
 the attachment allows extra information to be stored with each buffer.
virtual void set_attachment (const byte_array &new_attachment)=0
 sets the attachment, which is empty until this is used.
virtual span_manager buffer_status () const=0
 allows a peek at the object tracking our packet statuses.
virtual int_array packet_sizes () const=0
 returns a list of the sizes of the packets for this buffer.

Static Public Member Functions

static const char * outcome_name (const outcome &to_name)
 reports a textual form of the name.

Detailed Description

The base class for buffers to be managed by this library.

Definition at line 27 of file buffer_base.h.


Member Enumeration Documentation

enum buffer_base::outcomes

outcomes represent how a buffer operation has completed.

Enumerator:
OKAY 
IN_USE 
OUT_OF_MEMORY 
BAD_INPUT 
NO_SPACE 
INCOMPLETE 
NOT_FOUND 

Definition at line 37 of file buffer_base.h.

enum buffer_base::release_style

Enumerator:
RESET_STATUS 
KEEP_STATUS 

Definition at line 109 of file buffer_base.h.


Constructor & Destructor Documentation

buffer_base::~buffer_base (  )  [virtual]

should release any storage used by the buffer.

Definition at line 20 of file buffer_base.cpp.


Member Function Documentation

virtual bool buffer_base::alive (  )  const [pure virtual]

returns true if this buffer is still alive.

Implemented in buffer, and linked_buffer.

const char * buffer_base::outcome_name ( const outcome to_name  )  [static]

reports a textual form of the name.

Definition at line 22 of file buffer_base.cpp.

References common::outcome_name().

virtual int buffer_base::packets (  )  const [pure virtual]

the number of packets in this buffer.

Implemented in buffer, and linked_buffer.

virtual buffer_key buffer_base::key (  )  const [pure virtual]

observe the key for this buffer.

Implemented in buffer, and linked_buffer.

Referenced by buffer_manager::add_buffer(), and buffer_manager::extract().

virtual void buffer_base::set_key ( const buffer_key to_set  )  [pure virtual]

modify the key for this buffer.

Implemented in buffer, and linked_buffer.

virtual outcome buffer_base::store_packet ( int  packet_number,
const byte_array buffer 
) [pure virtual]

puts a packet into the buffer at the "packet_number"th position.

the packet numbering starts at zero. if the packet has already been stored previously, then IN_USE is returned.

Implemented in buffer, and linked_buffer.

virtual byte_array buffer_base::get_packet ( int  packet_number  )  const [pure virtual]

returns a packet from the buffer.

if that packet has not been stored yet, then NIL is returned.

Implemented in buffer, and linked_buffer.

virtual int buffer_base::packet_length ( int  packet_number  )  const [pure virtual]

returns the length of a particular packet.

Implemented in buffer, and linked_buffer.

virtual bool buffer_base::whole (  )  const [pure virtual]

returns true if the entire buffer has been stored.

Implemented in buffer, and linked_buffer.

Referenced by buffer_manager::extract().

virtual bool buffer_base::empty (  )  const [pure virtual]

returns true if the buffer has no packets stored yet.

Implemented in buffer, and linked_buffer.

virtual int buffer_base::full_length ( int  offset = 0  )  const [pure virtual]

returns the full length of this buffer, ignoring first "offset" bytes.

the first "offset" bytes are not considered as part of the buffer, providing for a header's presence on each buffer. note that the full length is not actually known for sure until all packets are present in the buffer. BAD_INPUT is returned if the offset is invalid. INCOMPLETE is returned if the buffer was not whole yet. to receive an estimate of the size before the buffer is complete, use the guess_size() method.

Implemented in buffer, and linked_buffer.

virtual int buffer_base::guess_size ( int  offset = 0  )  [pure virtual]

provides an estimate of what the full size will eventually be.

once this measurement is provided, it is important that it remain constant; otherwise calculations based on it would be incorrect later. so, the did_estimate() method reports whether the size was ever guessed for this buffer and this function will return the same value until the buffer is released.

Implemented in buffer, and linked_buffer.

virtual bool buffer_base::did_estimate (  )  const [pure virtual]

returns true if we have previously estimated a size for this buffer.

Implemented in buffer, and linked_buffer.

virtual void buffer_base::reset_estimate (  )  [pure virtual]

tosses our earlier estimate of the buffer's size.

Implemented in buffer, and linked_buffer.

virtual int buffer_base::estimate (  )  const [pure virtual]

returns our estimate, if we've made one.

Implemented in buffer, and linked_buffer.

virtual outcome buffer_base::dump ( byte_array storage_location,
int  offset = 0 
) [pure virtual]

stuffs the entire buffer into contiguous memory at "storage_location".

if the buffer cannot be allocated, OUT_OF_MEMORY is returned. if the buffer is not complete, INCOMPLETE will be returned. if the "offset" is positive, then the packets stored in the buffer will have the first "offset" bytes chopped off of them before they are stored. if any packet is too short for the given offset (or if offset is negative), BAD_INPUT is returned.

Implemented in buffer, and linked_buffer.

Referenced by buffer_manager::extract().

virtual void buffer_base::release ( int  packet_number,
release_style  status_handling = KEEP_STATUS 
) [pure virtual]

frees the storage for the "packet_number"th packet.

if keep_status is true, then packet's state of being present is retained; otherwise, the packet is considered not to have been received yet. if the status is kept, then the packet will appear to be there but will have zero length and a NIL content.

Implemented in buffer, and linked_buffer.

virtual void buffer_base::release (  )  [pure virtual]

frees the entire buffer, returning it to an unallocated state.

Implemented in buffer, and linked_buffer.

virtual istring buffer_base::text_form (  )  const [pure virtual]

returns a text string representing the state of the buffer.

Reimplemented from object_base.

Implemented in buffer, and linked_buffer.

virtual istring buffer_base::detailed_form ( bool  really_detailed = false  )  const [pure virtual]

returns a more detailed text string for this buffer.

if "really_detailed" is true, then the status of each component of the buffer is included.

Implemented in buffer, and linked_buffer.

virtual time_stamp buffer_base::last_add (  )  const [pure virtual]

returns the last time that the buffer was added to.

Implemented in buffer, and linked_buffer.

virtual void buffer_base::set_last_add ( const time_stamp new_last_add  )  [pure virtual]

sets the last time that the buffer was added to.

Implemented in buffer, and linked_buffer.

virtual bool buffer_base::owner_alerted (  )  const [pure virtual]

records whether the buffer's owner was alerted to completion.

this is only meaningful if the set_alerted() method is used when the buffer is first found to be finished.

Implemented in buffer, and linked_buffer.

virtual void buffer_base::set_alerted ( bool  owner_alerted  )  [pure virtual]

records that the owner was alerted, if "owner_alerted" is true.

Implemented in buffer, and linked_buffer.

virtual void buffer_base::get_attachment ( byte_array storage  )  const [pure virtual]

the attachment allows extra information to be stored with each buffer.

Implemented in buffer, and linked_buffer.

Referenced by buffer_manager::extract().

virtual void buffer_base::set_attachment ( const byte_array new_attachment  )  [pure virtual]

sets the attachment, which is empty until this is used.

Implemented in buffer, and linked_buffer.

virtual span_manager buffer_base::buffer_status (  )  const [pure virtual]

allows a peek at the object tracking our packet statuses.

Implemented in buffer, and linked_buffer.

virtual int_array buffer_base::packet_sizes (  )  const [pure virtual]

returns a list of the sizes of the packets for this buffer.

Implemented in buffer, and linked_buffer.


The documentation for this class was generated from the following files:
Generated on Fri Aug 29 04:30:20 2008 for HOOPLE Libraries by  doxygen 1.5.1