activemq::io::BufferedInputStream Class Reference

#include <BufferedInputStream.h>

Inheritance diagram for activemq::io::BufferedInputStream:

activemq::io::InputStream activemq::concurrent::Synchronizable List of all members.

Public Member Functions

 BufferedInputStream (InputStream *stream)
 BufferedInputStream (InputStream *stream, const int bufferSize)
virtual ~BufferedInputStream ()
virtual void lock () throw ( exceptions::ActiveMQException )
virtual void unlock () throw ( exceptions::ActiveMQException )
virtual void wait () throw ( exceptions::ActiveMQException )
virtual void wait (unsigned long millisecs) throw ( exceptions::ActiveMQException )
virtual void notify () throw ( exceptions::ActiveMQException )
virtual void notifyAll () throw ( exceptions::ActiveMQException )
virtual int available () const
virtual unsigned char read () throw ( IOException )
virtual int read (unsigned char *buffer, const int bufferSize) throw ( IOException )
virtual void close (void) throw ( cms::CMSException )

Private Member Functions

void init (InputStream *stream, const int bufferSize)
void bufferData (void) throw ( IOException )

Private Attributes

InputStreamstream
unsigned char * buffer
int bufferSize
int head
int tail

Detailed Description

A wrapper around another input stream that performs a buffered read, where it reads more data than it needs in order to reduce the number of io operations on the input stream.


Constructor & Destructor Documentation

BufferedInputStream::BufferedInputStream InputStream stream  ) 
 

Constructor

Parameters:
stream The target input stream.

BufferedInputStream::BufferedInputStream InputStream stream,
const int  bufferSize
 

Constructor

Parameters:
stream the target input stream
bufferSize the size for the internal buffer.

BufferedInputStream::~BufferedInputStream  )  [virtual]
 


Member Function Documentation

virtual int activemq::io::BufferedInputStream::available  )  const [inline, virtual]
 

Indcates the number of bytes avaialable.

Returns:
the sum of the amount of data avalable in the buffer and the data available on the target input stream.

Implements activemq::io::InputStream.

void BufferedInputStream::bufferData void   )  throw ( IOException ) [private]
 

Populates the buffer with as much data as possible from the target input stream.

Exceptions:
CMSException 

void BufferedInputStream::close void   )  throw ( cms::CMSException ) [virtual]
 

Closes the target input stream.

Exceptions:
CMSException 

void BufferedInputStream::init InputStream stream,
const int  bufferSize
[private]
 

Initializes the internal structures.

Parameters:
stream to read from
size of buffer to allocate

virtual void activemq::io::BufferedInputStream::lock  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Locks the object. throws ActiveMQException

Implements activemq::concurrent::Synchronizable.

virtual void activemq::io::BufferedInputStream::notify  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Signals a waiter on this object that it can now wake up and continue. Must have this object locked before calling. throws ActiveMQException

Implements activemq::concurrent::Synchronizable.

virtual void activemq::io::BufferedInputStream::notifyAll  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Signals the waiters on this object that it can now wake up and continue. Must have this object locked before calling. throws ActiveMQException

Implements activemq::concurrent::Synchronizable.

int BufferedInputStream::read unsigned char *  buffer,
const int  bufferSize
throw ( IOException ) [virtual]
 

Reads an array of bytes from the buffer.

Parameters:
buffer (out) the target buffer.
bufferSize the size of the output buffer.
Returns:
The number of bytes read.
Exceptions:
IOException thrown if an error occurs.

Implements activemq::io::InputStream.

unsigned char BufferedInputStream::read  )  throw ( IOException ) [virtual]
 

Reads a single byte from the buffer.

Returns:
The next byte.
Exceptions:
IOException thrown if an error occurs.

Implements activemq::io::InputStream.

virtual void activemq::io::BufferedInputStream::unlock  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Unlocks the object. throws ActiveMQException

Implements activemq::concurrent::Synchronizable.

virtual void activemq::io::BufferedInputStream::wait unsigned long  millisecs  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Waits on a signal from this object, which is generated by a call to Notify. Must have this object locked before calling. This wait will timeout after the specified time interval.

Parameters:
millisecs time in millisecsonds to wait, or WAIT_INIFINITE
Exceptions:
ActiveMQException 

Implements activemq::concurrent::Synchronizable.

virtual void activemq::io::BufferedInputStream::wait  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Waits on a signal from this object, which is generated by a call to Notify. Must have this object locked before calling. throws ActiveMQException

Implements activemq::concurrent::Synchronizable.


Member Data Documentation

unsigned char* activemq::io::BufferedInputStream::buffer [private]
 

The internal buffer.

int activemq::io::BufferedInputStream::bufferSize [private]
 

The buffer size.

int activemq::io::BufferedInputStream::head [private]
 

The current head of the buffer.

InputStream* activemq::io::BufferedInputStream::stream [private]
 

The target input stream.

int activemq::io::BufferedInputStream::tail [private]
 

The current tail of the buffer.


The documentation for this class was generated from the following files:
Generated on Thu Aug 3 18:03:33 2006 for activemq-cpp by  doxygen 1.4.5