Ceylan::Middleware::ProtocolServer Class Reference

Designates an applicative server which implements the server side of a protocol specification. More...

#include <CeylanProtocolServer.h>

Inheritance diagram for Ceylan::Middleware::ProtocolServer:
Inheritance graph
[legend]
Collaboration diagram for Ceylan::Middleware::ProtocolServer:
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

 ProtocolServer (Marshaller &marshaller)
 Constructs a new protocol server.
virtual ~ProtocolServer () throw ()
 Virtual destructor.
virtual bool notifyDataAvailability ()=0
 Reacts on data arrival, performs any work needed, and sends back an answer to the client if needed.
virtual bool isShutdownRequested () const
 Tells whether the underlying communication system (for example a network server) is expected to shutdown, once this instance of protocol exchange is over.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns a user-friendly description of the state of this object.

Static Public Member Functions

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 askForShutdown ()
 Records the fact that the protocol determined that the underlying medium should be stopped once the protocol exchange is terminated.

Protected Attributes

bool _shutdownRequested
 Tells whether, when the protocol exchange will be terminated, the underlying medium should be stopped.
Marshaller_marshaller
 The marshaller that will be used to (de)serialize informations of this endpoint.

Static Protected Attributes

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

Private Member Functions

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

Detailed Description

Designates an applicative server which implements the server side of a protocol specification.

Such server handles requests sent by clients, and manages them in a remote-invocation-method maneer.

There marshaller hides to the protocol server the details of the underlying stream that will be used to transport protcolol informations : the marshaller will take care of the appropriate encoding/decoding on the behalf of this protocol server.

Note:
Here the "server" word means an object whose role is to answer to requests, it is not especially linked with a networked server for example : a protocol server respects the server-side behaviour of a protocol specification, the protcol itself is conveyed by any technical solution, which may be a network-based one (ex : TCP/IP server socket), or a UNIX pipe, or anything else, the protocol server does not need to know that.

Following methods have to be subclassed so that the protocol server can perform its specific task :

(see Marshaller::retrieveData)

Definition at line 76 of file CeylanProtocolServer.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

ProtocolServer::ProtocolServer ( Marshaller marshaller  ) 

Constructs a new protocol server.

Parameters:
marshaller the marshaller that will encode and/or decode data to/from the stream for the protocol to be serialized. As marshallers are per-connection object, the protocol endpoint takes ownership of it and will delete the marshaller when itself deleted.

Definition at line 41 of file CeylanProtocolServer.cc.

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

Virtual destructor.

Definition at line 50 of file CeylanProtocolServer.cc.

Ceylan::Middleware::ProtocolServer::ProtocolServer ( const ProtocolServer 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 ProtocolServer::askForShutdown (  )  [protected, virtual]

Records the fact that the protocol determined that the underlying medium should be stopped once the protocol exchange is terminated.

Definition at line 85 of file CeylanProtocolServer.cc.

References _shutdownRequested, and generalUtils::true.

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]
bool ProtocolServer::isShutdownRequested (  )  const [virtual]

Tells whether the underlying communication system (for example a network server) is expected to shutdown, once this instance of protocol exchange is over.

Note:
This request is a special one that must be managed specifically, as it goes beyond the field of a particular protocol-based connection : the underlying media can be stopped only by specific means that violate the separation between protocol objects and communication objects.

Definition at line 57 of file CeylanProtocolServer.cc.

References _shutdownRequested.

Referenced by Ceylan::Network::MultiplexedProtocolBasedStreamServer::closeConnection(), and toString().

virtual bool Ceylan::Middleware::ProtocolServer::notifyDataAvailability (  )  [pure virtual]

Reacts on data arrival, performs any work needed, and sends back an answer to the client if needed.

This pure virtual method must be overriden by the user.

The marshaller can help writing a protocol exchange by taking care of lower-level decoding/encoding, and if the marshaller is buffered, one may use : _marshaller->retrieveData( expectedPDUSize) here, where expectedPDUSize is the size needed by this protocol server so that it can interpret the request. The retrieveData method returns the number of bytes ready to be decoded in the buffer of the marshaller. Therefore if this returned size is less than the minimum size requested by the server, then the protocol server can just return true and wait next notifications, until the read bytes accumulate in the buffer and the size it needs is reached.

Returns:
whether, from the protocol server point of view, the connection should be kept at the return of this method (if true). If false, incoming client data will not be waited for anymore, and the connection will be closed.
Exceptions:
ProtocolException on failure.
See also:
testCeylanMultiLwProtocolServer.cc
ProtocolServer& Ceylan::Middleware::ProtocolServer::operator= ( const ProtocolServer 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.

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().

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 string ProtocolServer::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns a 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::Middleware::ProtocolEndpoint.

Definition at line 66 of file CeylanProtocolServer.cc.

References isShutdownRequested().

Referenced by Ceylan::Network::AnonymousProtocolAwareStreamSocket::toString().


Member Data Documentation

The marshaller that will be used to (de)serialize informations of this endpoint.

Definition at line 146 of file CeylanProtocolEndpoint.h.

Referenced by Ceylan::Middleware::ProtocolEndpoint::toString(), and Ceylan::Middleware::ProtocolEndpoint::~ProtocolEndpoint().

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().

Tells whether, when the protocol exchange will be terminated, the underlying medium should be stopped.

Note:
This is the only means for protocol objects to i interfere with communication objects : without this mechanism, they are truly independent.

The communication object (ex : network server) may or may not take this information into account.

Definition at line 197 of file CeylanProtocolServer.h.

Referenced by askForShutdown(), and isShutdownRequested().


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