Ceylan::System::AnonymousInputStream Class Reference

Abstract anonymous input stream class used in IPC. More...

#include <CeylanAnonymousInputStream.h>

Inheritance diagram for Ceylan::System::AnonymousInputStream:
Inheritance graph
[legend]
Collaboration diagram for Ceylan::System::AnonymousInputStream:
Collaboration graph
[legend]

List of all members.

Public Types

enum  TextOutputFormat { rawText, html }
 

Defines what text output formats for TextDisplayable instances are available.

More...

Public Member Functions

 AnonymousInputStream (FileDescriptor fd)
 Basic constructor for AnonymousInputStream, whose instances are created not selected.
virtual ~AnonymousInputStream () throw ()
 Basic virtual destructor.
virtual StreamID getInputStreamID () const
 Returns the stream's unique ID.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.
bool isSelected () const
 Tells if the stream has data to read.
bool isFaulty () const
virtual bool hasAvailableData () const =0
 Tells whether there is data available on input.
virtual Size read (Ceylan::Byte *buffer, Size length)
 Reads up to maxLength bytes from this InputStream to specified buffer.
virtual void clearInput ()
 Clears the input stream.
virtual Ceylan::Sint8 readSint8 ()
 Returns a Ceylan::Sint8 read from this input stream.
virtual Ceylan::Uint8 readUint8 ()
 Returns a Ceylan::Uint8 read from this input stream.
virtual Ceylan::Sint16 readSint16 ()
 Returns a Ceylan::Sint16 read from this input stream.
virtual Ceylan::Uint16 readUint16 ()
 Returns a Ceylan::Uint16 read from this input stream.
virtual Ceylan::Sint32 readSint32 ()
 Returns a Ceylan::Sint32 read from this input stream.
virtual Ceylan::Uint32 readUint32 ()
 Returns a Ceylan::Uint32 read from this input stream.
virtual Ceylan::Float32 readFloat32 ()
 Returns a Ceylan::Float32 read from this input stream.
virtual Ceylan::Float64 readFloat64 ()
 Returns a Ceylan::Float64 read from this input stream.
virtual void readString (std::string &result)
 Reads a string from this input stream, and stores it in the specified string.
virtual void skipWhitespaces (Ceylan::Uint8 &firstNonSpace)
 Reads from this input stream as long as there are whitespaces to be read.
bool isBlocking () const
 Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false).
virtual bool close ()=0
 Closes the stream.

Static Public Member Functions

static Ceylan::Uint16 Select (std::list< InputStream * > &is)
 Blocks the calling thread until bytes become available on one or more streams in is.
static Ceylan::Uint16 Test (std::list< InputStream * > &is)
 Checks whether bytes become available on one or more streams in is.
static bool Close (FileDescriptor &fd)
 Closes and zeroes the specified file descriptor.
static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Protected Member Functions

virtual void setSelected (bool newStatus)
 Used to set the selection status of this stream.
void setFaulty (bool newFaultyState=true)
 Sets the faulty state of this stream.
virtual void setStreamID (StreamID newInputStreamID)
 Sets this input stream's unique ID.
virtual void setBlocking (bool newStatus)
 Sets the blocking mode of this stream.

Protected Attributes

bool _isBlocking
 Stores whether the stream is in blocking mode.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

 AnonymousInputStream (const AnonymousInputStream &source)
 Copy constructor made private to ensure that it will be never called.
AnonymousInputStreamoperator= (const AnonymousInputStream &source)
 Assignment operator made private to ensure that it will be never called.

Private Attributes

FileDescriptor _fdes
 Stores the file descriptor of this stream.

Detailed Description

Abstract anonymous input stream class used in IPC.

This class is mostly used for servers offering multiplexed accesses to clients : the server is an I/O stream that controls the socket bound to its published port, and for each connected client a dedicated socket is spawned. This socket is an anonymous stream.

See also:
ServerStreamSocket, Socket, InputStream.

Definition at line 56 of file CeylanAnonymousInputStream.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

AnonymousInputStream::AnonymousInputStream ( FileDescriptor  fd  )  [explicit]

Basic constructor for AnonymousInputStream, whose instances are created not selected.

Exceptions:
StreamException if the operation failed, included if the file descriptor feature is not available.

Definition at line 49 of file CeylanAnonymousInputStream.cc.

AnonymousInputStream::~AnonymousInputStream (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 66 of file CeylanAnonymousInputStream.cc.

Ceylan::System::AnonymousInputStream::AnonymousInputStream ( const AnonymousInputStream source  )  [private]

Copy constructor made private to ensure that it will be never called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

void InputStream::clearInput (  )  [virtual, inherited]

Clears the input stream.

Exceptions:
InputStream::ReadFailedException if the operation failed.

Reimplemented in Ceylan::System::Pipe.

Definition at line 179 of file CeylanInputStream.cc.

References dataUtils::b, Ceylan::System::InputStream::hasAvailableData(), and Ceylan::System::InputStream::read().

bool Stream::Close ( FileDescriptor fd  )  [static, inherited]

Closes and zeroes the specified file descriptor.

It is passed by address so that this function can set it to zero on successful close.

Returns:
true iff an operation had to be performed.
Exceptions:
CloseException if the close operation failed.

Definition at line 114 of file CeylanStream.cc.

References Ceylan::System::Stream::close(), generalUtils::false, Ceylan::toString(), and generalUtils::true.

Referenced by Ceylan::System::StandardFile::close(), Ceylan::Network::Socket::close(), Ceylan::System::Pipe::close(), and Ceylan::System::LibfatFile::close().

virtual bool Ceylan::System::Stream::close (  )  [pure virtual, inherited]

Closes the stream.

Returns:
true iff an operation had to be performed.
Exceptions:
CloseException if the close operation failed.

Implemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.

Referenced by Ceylan::System::Stream::Close().

StreamID AnonymousInputStream::getInputStreamID (  )  const [virtual]

Returns the stream's unique ID.

Exceptions:
InputStreamException if the operation failed, for example if this input stream has not received a valid identifier yet.

Implements Ceylan::System::InputStream.

Definition at line 73 of file CeylanAnonymousInputStream.cc.

References _fdes.

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]
virtual bool Ceylan::System::InputStream::hasAvailableData (  )  const [pure virtual, inherited]

Tells whether there is data available on input.

Implemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::MemoryStream, and Ceylan::System::Pipe.

Referenced by Ceylan::System::InputStream::clearInput().

bool Stream::isBlocking (  )  const [inherited]

Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false).

Definition at line 93 of file CeylanStream.cc.

References Ceylan::System::Stream::_isBlocking.

Referenced by Ceylan::Network::StreamSocket::createSocket(), and Ceylan::Network::Socket::toString().

bool InputStream::isFaulty (  )  const [inherited]
bool InputStream::isSelected (  )  const [inherited]

Tells if the stream has data to read.

Definition at line 122 of file CeylanInputStream.cc.

References Ceylan::System::InputStream::_isSelected.

Referenced by Ceylan::System::InputStream::toString().

AnonymousInputStream& Ceylan::System::AnonymousInputStream::operator= ( const AnonymousInputStream source  )  [private]

Assignment operator made private to ensure that it will be never called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

Size InputStream::read ( Ceylan::Byte buffer,
Size  length 
) [virtual, inherited]

Reads up to maxLength bytes from this InputStream to specified buffer.

Parameters:
buffer the buffer where to store read bytes. Its size must be at least 'length' bytes.
length the maximum number of bytes that should be read.
Returns:
The number of bytes actually read, which should be equal to 'length' or lower.
Exceptions:
ReadFailed if a read error occurred, or if this default implementation has not been overriden.
Note:
This method is not pure virtual so that other methods using it can be defined here.
Each read method should set the selected status to false, after the actual reading.

Reimplemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.

Definition at line 169 of file CeylanInputStream.cc.

Referenced by Ceylan::System::InputStream::clearInput(), Ceylan::System::InputStream::readFloat32(), Ceylan::System::InputStream::readFloat64(), Ceylan::System::InputStream::readSint16(), Ceylan::System::InputStream::readSint32(), Ceylan::System::InputStream::readSint8(), Ceylan::System::InputStream::readString(), Ceylan::System::InputStream::readUint16(), Ceylan::System::InputStream::readUint32(), Ceylan::System::InputStream::readUint8(), and Ceylan::Middleware::Marshaller::retrieveData().

Ceylan::Float32 InputStream::readFloat32 (  )  [virtual, inherited]

Returns a Ceylan::Float32 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 356 of file CeylanInputStream.cc.

References ceylan_bswap_32, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat32().

Ceylan::Float64 InputStream::readFloat64 (  )  [virtual, inherited]

Returns a Ceylan::Float64 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 392 of file CeylanInputStream.cc.

References Ceylan::byteswap(), ceylan_bswap_64, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat64().

Ceylan::Sint16 InputStream::readSint16 (  )  [virtual, inherited]

Returns a Ceylan::Sint16 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 239 of file CeylanInputStream.cc.

References ceylan_bswap_16, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint16().

Ceylan::Sint32 InputStream::readSint32 (  )  [virtual, inherited]

Returns a Ceylan::Sint32 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 298 of file CeylanInputStream.cc.

References ceylan_bswap_32, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint32().

Ceylan::Sint8 InputStream::readSint8 (  )  [virtual, inherited]

Returns a Ceylan::Sint8 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 203 of file CeylanInputStream.cc.

References Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint8().

void InputStream::readString ( std::string &  result  )  [virtual, inherited]

Reads a string from this input stream, and stores it in the specified string.

Note:
Read strings can have no more than 65535 characters.
Parameters:
result the string to fill from this input stream.
Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 437 of file CeylanInputStream.cc.

References Ceylan::System::InputStream::read(), Ceylan::System::InputStream::readUint16(), and Ceylan::toString().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeString().

Ceylan::Uint16 InputStream::readUint16 (  )  [virtual, inherited]

Returns a Ceylan::Uint16 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 268 of file CeylanInputStream.cc.

References ceylan_bswap_16, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint16(), and Ceylan::System::InputStream::readString().

Ceylan::Uint32 InputStream::readUint32 (  )  [virtual, inherited]

Returns a Ceylan::Uint32 read from this input stream.

Exceptions:
ReadFailedException in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected.

Definition at line 327 of file CeylanInputStream.cc.

References ceylan_bswap_32, and Ceylan::System::InputStream::read().

Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint32().

Ceylan::Uint8 InputStream::readUint8 (  )  [virtual, inherited]
Ceylan::Uint16 InputStream::Select ( std::list< InputStream * > &  is  )  [static, inherited]

Blocks the calling thread until bytes become available on one or more streams in is.

To see which are selected, use the isSelected method.

Returns:
the number of selected streams.
See also:
the non-blocking version, Test.
Exceptions:
SelectFailedException if the operation failed, for example if the file descriptor feature is not available on this platform.

Definition at line 534 of file CeylanInputStream.cc.

References Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::System::getError(), Ceylan::Network::getSocketError(), Ceylan::System::Thread::Sleep(), and Ceylan::toString().

Referenced by Ceylan::Network::MultiplexedServerStreamSocket::run().

void Stream::setBlocking ( bool  newStatus  )  [protected, virtual, inherited]

Sets the blocking mode of this stream.

Parameters:
newStatus if true, sets the stream in blocking mode, if false set to non-blocking mode. If the stream is already in the target state, nothing is done.
Exceptions:
NonBlockingNotSupportedException if the operation failed or is not supported.
Note:
This default implementation always raises its exception, streams that supports non-blocking access have to override it.

Reimplemented in Ceylan::Network::Socket, and Ceylan::Network::StreamSocket.

Definition at line 175 of file CeylanStream.cc.

void InputStream::setFaulty ( bool  newFaultyState = true  )  [protected, inherited]

Sets the faulty state of this stream.

Parameters:
newFaultyState the new faulty state.

Definition at line 1004 of file CeylanInputStream.cc.

References Ceylan::System::InputStream::_isFaulty.

Referenced by Ceylan::Network::MultiplexedServerStreamSocket::run().

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

void InputStream::setSelected ( bool  newStatus  )  [protected, virtual, inherited]
void InputStream::setStreamID ( StreamID  newInputStreamID  )  [protected, virtual, inherited]

Sets this input stream's unique ID.

Exceptions:
InputStreamException in all cases as long as not specifically overriden.

Definition at line 1013 of file CeylanInputStream.cc.

void InputStream::skipWhitespaces ( Ceylan::Uint8 firstNonSpace  )  [virtual, inherited]

Reads from this input stream as long as there are whitespaces to be read.

Parameters:
firstNonSpace the variable which will be set by this method to the value of the first non-whitespace character that is read.

Definition at line 516 of file CeylanInputStream.cc.

References Ceylan::isWhitespace(), and Ceylan::System::InputStream::readUint8().

Referenced by Ceylan::XML::XMLParser::handleNextElement().

Ceylan::Uint16 InputStream::Test ( std::list< InputStream * > &  is  )  [static, inherited]

Checks whether bytes become available on one or more streams in is.

To see which are selected, use the isSelected method.

This method returns always immediatly.

Returns:
the number of selected streams.
See also:
the blocking version, Select.
Exceptions:
SelectFailedException if the operation failed, for example if the file descriptor feature is not available on this platform.

Definition at line 863 of file CeylanInputStream.cc.

References Ceylan::System::explainError(), and Ceylan::System::getError().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const std::string AnonymousInputStream::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Reimplemented from Ceylan::System::InputStream.

Definition at line 82 of file CeylanAnonymousInputStream.cc.

References _fdes.


Member Data Documentation

Stores the file descriptor of this stream.

Definition at line 116 of file CeylanAnonymousInputStream.h.

Referenced by getInputStreamID(), and toString().

bool Ceylan::System::Stream::_isBlocking [protected, inherited]
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 13:42:03 2010 for Ceylan by  doxygen 1.6.3