Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

BufferedSink Class Reference

#include <BufferedSink.h>

Inheritance diagram for BufferedSink:

Inheritance graph
[legend]
Collaboration diagram for BufferedSink:

Collaboration graph
[legend]
List of all members.

Detailed Description

A Sink First-In First-Out buffer.

This buffer can always be written to, it overwrites any data contained if needed. The class is not thread-safe.

Author:
Author
jbebel
Version:
Revision
1.8

Definition at line 61 of file BufferedSink.h.

Public Member Functions

 BufferedSink (Sink *sink, unsigned int size, unsigned int chunkSize=1) throw ( Exception )
 Constructor by an underlying Sink, buffer size and chunk size.
 BufferedSink (const BufferedSink &buffer) throw ( Exception )
 Copy constructor.
virtual ~BufferedSink (void) throw ( Exception )
 Destructor.
virtual BufferedSinkoperator= (const BufferedSink &bs) throw ( Exception )
 Assignment operator.
unsigned int getPeak (void) const throw ()
 Get the peak usage of the internal buffer.
virtual bool open (void) throw ( Exception )
 Open the BufferedSink.
virtual bool isOpen (void) const throw ()
 Check if a BufferedSink is open.
virtual bool canWrite (unsigned int sec, unsigned int usec) throw ( Exception )
 Check if the BufferedSink is ready to accept data.
virtual unsigned int write (const void *buf, unsigned int len) throw ( Exception )
 Write data to the BufferedSink.
virtual void flush (void) throw ( Exception )
 Flush all data that was written to the BufferedSink to the underlying Sink.
virtual void close (void) throw ( Exception )
 Close the BufferedSink.

Protected Member Functions

 BufferedSink (void) throw ( Exception )
 Default constructor.
unsigned int getSize (void) const throw ()
 Get the size of the buffer.
unsigned int store (const void *buffer, unsigned int bufferSize) throw ( Exception )
 Store data in the internal buffer.


Constructor & Destructor Documentation

BufferedSink::BufferedSink void   )  throw ( Exception ) [inline, protected]
 

Default constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 211 of file BufferedSink.h.

BufferedSink::BufferedSink Sink sink,
unsigned int  size,
unsigned int  chunkSize = 1
throw ( Exception ) [inline]
 

Constructor by an underlying Sink, buffer size and chunk size.

Parameters:
sink the Sink to attach this BufferSink to.
size the size of the buffer to use for buffering.
chunkSize hanlde all data in write() as chunks of chunkSize
Exceptions:
Exception 

Definition at line 253 of file BufferedSink.h.

BufferedSink::BufferedSink const BufferedSink buffer  )  throw ( Exception )
 

Copy constructor.

Parameters:
buffer the object to copy.
Exceptions:
Exception 

Definition at line 108 of file BufferedSink.cpp.

virtual BufferedSink::~BufferedSink void   )  throw ( Exception ) [inline, virtual]
 

Destructor.

Exceptions:
Exception 

Definition at line 274 of file BufferedSink.h.


Member Function Documentation

virtual bool BufferedSink::canWrite unsigned int  sec,
unsigned int  usec
throw ( Exception ) [inline, virtual]
 

Check if the BufferedSink is ready to accept data.

Always returns true immediately.

Parameters:
sec the maximum seconds to block.
usec micro seconds to block after the full seconds.
Returns:
true
Exceptions:
Exception 

Implements Sink.

Definition at line 333 of file BufferedSink.h.

void BufferedSink::close void   )  throw ( Exception ) [virtual]
 

Close the BufferedSink.

Closes the underlying Sink.

Exceptions:
Exception 

Implements Sink.

Definition at line 358 of file BufferedSink.cpp.

References flush(), and isOpen().

virtual void BufferedSink::flush void   )  throw ( Exception ) [inline, virtual]
 

Flush all data that was written to the BufferedSink to the underlying Sink.

Exceptions:
Exception 

Implements Sink.

Definition at line 362 of file BufferedSink.h.

References write().

Referenced by close().

unsigned int BufferedSink::getPeak void   )  const throw () [inline]
 

Get the peak usage of the internal buffer.

Returns:
the peak usage of the internal buffer.

Definition at line 295 of file BufferedSink.h.

unsigned int BufferedSink::getSize void   )  const throw () [inline, protected]
 

Get the size of the buffer.

Returns:
the size of the buffer.

Definition at line 222 of file BufferedSink.h.

virtual bool BufferedSink::isOpen void   )  const throw () [inline, virtual]
 

Check if a BufferedSink is open.

Returns:
true if the BufferedSink is open, false otherwise.

Implements Sink.

Definition at line 318 of file BufferedSink.h.

References Sink::isOpen().

Referenced by close().

virtual bool BufferedSink::open void   )  throw ( Exception ) [inline, virtual]
 

Open the BufferedSink.

Opens the underlying Sink.

Returns:
true if opening was successful, false otherwise.
Exceptions:
Exception 

Implements Sink.

Definition at line 307 of file BufferedSink.h.

References Sink::open().

BufferedSink & BufferedSink::operator= const BufferedSink bs  )  throw ( Exception ) [virtual]
 

Assignment operator.

Parameters:
bs the object to assign to this one.
Returns:
a reference to this object.
Exceptions:
Exception 

Definition at line 138 of file BufferedSink.cpp.

References Sink::operator=().

unsigned int BufferedSink::store const void *  buffer,
unsigned int  bufferSize
throw ( Exception ) [protected]
 

Store data in the internal buffer.

If there is not enough space, discard all in the buffer and the beginning of the supplied buffer if needed.

Parameters:
buffer the data to store.
bufferSize the amount of data to store in bytes.
Returns:
number of bytes really stored.

Definition at line 164 of file BufferedSink.cpp.

unsigned int BufferedSink::write const void *  buf,
unsigned int  len
throw ( Exception ) [virtual]
 

Write data to the BufferedSink.

Always reads the maximum number of chunkSize chunks buf holds. If the data can not be written to the underlying stream, it is buffered. If the buffer overflows, the oldest data is discarded.

Parameters:
buf the data to write.
len number of bytes to write from buf.
Returns:
the number of bytes written (may be less than len).
Exceptions:
Exception 

Implements Sink.

Definition at line 257 of file BufferedSink.cpp.

Referenced by flush().


The documentation for this class was generated from the following files:
Generated on Sat Oct 22 13:17:06 2005 for DarkIce by  doxygen 1.4.4