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

FunnelDevice Class Reference

A device that acts like a 'funnel'. More...

#include <funneldevice.h>

Inheritance diagram for FunnelDevice:

IODevice List of all members.

Public Methods

 FunnelDevice (UserOfFunnelDevice *rcvr, bool isImmediate=false, size_t size=DEFAULT_FUNNEL_BUFFER_SIZE)
 A constructor. More...

virtual ~FunnelDevice (void)
 A destructor. More...

virtual void prepare (void) throw (ExaltIOException)
 Prepare the device. More...

virtual void flush (void) throw (ExaltIOException)
 Flush the device. More...

virtual void finish (void) throw (ExaltIOException)
 Finish the work with the device. More...

virtual IOState readData (char *buf, IOSize length) throw (ExaltIOException)
 Read up to the specified number of bytes into the buffer (unused). More...

virtual IOState getChar (int *) throw (ExaltIOException)
 Read a char (unused). More...

virtual IOState writeData (const char *buf, IOSize length) throw (ExaltIOException)
 Write the specified number of bytes from the buffer. More...

virtual IOState putChar (int) throw (ExaltIOException)
 Write a char. More...

virtual IOSize bytesReadTotal (void)
 Return the number of bytes read so far. More...

virtual IOSize bytesRead (void)
 Return the number of bytes read by the last read operation. More...

virtual IOSize bytesWritten (void)
 Return the number of bytes written so far (unused). More...

virtual bool errorOccurred (void)
 Informs about an error. More...

virtual bool eof (void)
 Informs about an end of file (unused). More...


Protected Attributes

UserOfFunnelDevicereceiver
 The receiver of the data.

size_t bufferSize
 The size of the inner data buffer.

size_t dataLength
 The length of the data in the buffer.

bool dataPresent
 Indication whether the buffer contains any data.

bool immediate
 Is the data delivery immediate, or buffered?

IOSize bw
 The number of bytes written to the device.

XmlChar * buffer
 The data buffer.


Detailed Description

A device that acts like a 'funnel'.

This device can be used for one-directional XmlChar data exchange between two objects. The object that receives the data has to be derived from the UserOfFunnelDevice class, and has to implement the UserOfFunnelDevice::receiveData() method. The sender can send the data to the receiver using standard IODevice write functions.

The data written to FunnelDevice are buffered until flush() is called, or the size of the inner buffer is exceeded. The buffering can be disabled in constructor to make the data delivery immediate.

See also:
IODevice, FileDevice.

Definition at line 58 of file funneldevice.h.


Constructor & Destructor Documentation

FunnelDevice::FunnelDevice UserOfFunnelDevice   rcvr,
bool    isImmediate = false,
size_t    size = DEFAULT_FUNNEL_BUFFER_SIZE
 

A constructor.

Initialization is performed.

In order to use the device, one has to specify the object that will receive the data (it must inherit UserOfFunnelDevice). The device stores the data in an inner buffer. If the buffer is full, the data is delivered to the receiving object. If isImmediate is set to TRUE, the data is not buffered.

Parameters:
rcvr  Pointer to the receiver.
isImmediate  Is the data delivered immediately?
size  Size of the device's inner buffer.

Definition at line 44 of file funneldevice.cpp.

References buffer, bufferSize, bw, dataLength, dataPresent, DEFAULT_FUNNEL_BUFFER_SIZE, immediate, and receiver.

FunnelDevice::~FunnelDevice void    [virtual]
 

A destructor.

Deletes the inner buffer.

Definition at line 65 of file funneldevice.cpp.

References buffer, and DELETE_ARRAY.


Member Function Documentation

IOSize FunnelDevice::bytesRead void    [virtual]
 

Return the number of bytes read by the last read operation.

Returns the number of bytes read from the device by the last read operation. Always returns 0, since the device only supports write operations.

Returns:
0 Zero bytes have been read.

Implements IODevice.

Definition at line 238 of file funneldevice.cpp.

References IOSize.

IOSize FunnelDevice::bytesReadTotal void    [virtual]
 

Return the number of bytes read so far.

Returns the total number of bytes read from the device. Always returns 0, since the device only supports write operations.

Returns:
0 Zero bytes have been read.

Implements IODevice.

Definition at line 228 of file funneldevice.cpp.

References IOSize.

IOSize FunnelDevice::bytesWritten void    [virtual]
 

Return the number of bytes written so far (unused).

Returns the total number of bytes written to the device.

Returns:
Number of bytes.

Implements IODevice.

Definition at line 248 of file funneldevice.cpp.

References bw, and IOSize.

bool FunnelDevice::eof void    [virtual]
 

Informs about an end of file (unused).

This method can be used for tests of the end of file. Always returns FALSE.

Return values:
FALSE  End of file didn't occurred.

Implements IODevice.

Definition at line 268 of file funneldevice.cpp.

bool FunnelDevice::errorOccurred void    [virtual]
 

Informs about an error.

If any of the IO operations was unsuccessful, this method can be used to test it. Always returns FALSE.

Return values:
FALSE  No error occurred.

Implements IODevice.

Definition at line 258 of file funneldevice.cpp.

void FunnelDevice::finish void    throw (ExaltIOException) [virtual]
 

Finish the work with the device.

This method ends the work with the device. An attempt to work with finished device will cause an ExaltIOException to be raised.

Implements IODevice.

Definition at line 107 of file funneldevice.cpp.

void FunnelDevice::flush void    throw (ExaltIOException) [virtual]
 

Flush the device.

Ensures that all the data is written to the device. This means that all the data is delivered to the receiver.

Implements IODevice.

Definition at line 84 of file funneldevice.cpp.

IOState FunnelDevice::getChar int *    c throw (ExaltIOException) [virtual]
 

Read a char (unused).

Reads one character from the device. If an error occurred, ExaltIOException is raised.

Parameters:
c  Pointer where the read character is stored.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 138 of file funneldevice.cpp.

References IOState, and ReadOk.

void FunnelDevice::prepare void    throw (ExaltIOException) [virtual]
 

Prepare the device.

This method prepares the device for further work. An attempt to work with unprepared device will cause an ExaltIOException to be raised.

Implements IODevice.

Definition at line 74 of file funneldevice.cpp.

References NEW, and XmlChar.

Referenced by XmlCodec::decode.

IOState FunnelDevice::putChar int    c throw (ExaltIOException) [virtual]
 

Write a char.

Writes one character to the device. If an error occurred, ExaltIOException is raised.

Parameters:
c  The character.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 194 of file funneldevice.cpp.

References IOState, ReadOk, and WriteError.

IOState FunnelDevice::readData char *    buf,
IOSize    length
throw (ExaltIOException) [virtual]
 

Read up to the specified number of bytes into the buffer (unused).

Reads up to length bytes from the device and stores them in buffer. If an error occurred, ExaltIOException is raised.

Parameters:
buf  Pointer to the buffer.
length  Length of the buffer.
Returns:
State of the device after the read operation.

Implements IODevice.

Definition at line 126 of file funneldevice.cpp.

References IOSize, IOState, and ReadOk.

IOState FunnelDevice::writeData const char *    buf,
IOSize    length
throw (ExaltIOException) [virtual]
 

Write the specified number of bytes from the buffer.

Writes length bytes from the buffer buf to the device. If an error occurred, ExaltIOException is raised.

Parameters:
buf  Pointer to the buffer.
length  Length of the buffer.
Returns:
State of the device after the write operation.

Implements IODevice.

Definition at line 152 of file funneldevice.cpp.

References IOSize, IOState, WriteError, WriteOk, and XmlChar.


The documentation for this class was generated from the following files:
Generated on Wed Feb 5 10:43:05 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002