rasdaman complete source
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rnp::RnpBaseServerComm Class Referenceabstract

#include <rnpcommunication.hh>

Inheritance diagram for rnp::RnpBaseServerComm:
RnpRasDaManComm

Public Member Functions

 RnpBaseServerComm () throw ()
 Default constructor - 1 server job. More...
 
virtual ~RnpBaseServerComm () throw ()
 Destructor. More...
 
bool setServerJobs (int nrOfServerJobs) throw ()
 
int countServerJobs () throw ()
 Returns the number of server jobs. More...
 
void connectToCommunicator (NbCommunicator &)
 Connect to the communicator. It also creates the jobs. Throws whatever new throws. Assert: no other connection! More...
 
bool disconnectFromCommunicator () throw ()
 
void setTransmitterBufferSize (int) throw ()
 Set the transmitter buffer size. More...
 
int getTransmitterBufferSize () throw ()
 Returns the transmitter buffer size. More...
 
virtual void processRequest (CommBuffer *receiverBuffer, CommBuffer *transmiterBuffer, RnpTransport::CarrierProtocol, RnpServerJob *callingJob) throw ()
 
void communicatorShouldExit () throw ()
 

Protected Member Functions

virtual void decodeFragment ()=0
 
const char * getNextAsString (RnpQuark parameterType) const
 Returns next parameter as string(can be NULL), verifying the parameter type. More...
 
int getNextAsInteger (RnpQuark parameterType) const
 Returns next parameter as integer, verifying the parameter type. More...
 
float getNextAsFloat (RnpQuark parameterType) const
 Returns next parameter as float, verifying the parameter type. More...
 
double getNextAsDouble (RnpQuark parameterType) const
 Returns next parameter as double, verifying the parameter type. More...
 
const void * getNextAsOpaque (RnpQuark parameterType) const
 Returns next parameter as const void* (can be NULL), verifying the parameter type. More...
 
int getCurrentParameterLength () const throw ()
 Returns the length of the data of the current parameter. More...
 
void answerAkgSerializable (AkgSerializableException &) throw ()
 Helper function to serialize an 'AkgException'. More...
 
void answerSTLException (exception &) throw ()
 Helper function to serialize an 'exception' (based on it's 'what()'-member. More...
 
void answerUnknownError () throw ()
 Helper function to serialize an unknown exception. More...
 
void discardFragment () throw ()
 Helper function to discard a fragment. More...
 
void startOkAnswer () throw ()
 Start building an OK-answer. More...
 
void endOkAnswer () throw ()
 Just for completeness, it's only an 'encoder.endFragment()'. More...
 

Protected Attributes

RnpProtocolDecoder decoder
 
RnpTransmitter encoder
 

Detailed Description

RnpBaseServerComm is the base class for the server communication. It offers the necessary elements for decoding the request, and for creating and transmitting the answer. Every specific server comm will inherit from this and will implement the various functions, most important the 'processRequest()', using the elements provided by this class.

It has a pool of 'RnpServerJob's which deal with the communication. Whichever has a valid request calls 'processRequest()'. The communicator object is external

Constructor & Destructor Documentation

rnp::RnpBaseServerComm::RnpBaseServerComm ( )
throw (
)

Default constructor - 1 server job.

virtual rnp::RnpBaseServerComm::~RnpBaseServerComm ( )
throw (
)
virtual

Destructor.

Member Function Documentation

void rnp::RnpBaseServerComm::answerAkgSerializable ( AkgSerializableException &  )
throw (
)
protected

Helper function to serialize an 'AkgException'.

void rnp::RnpBaseServerComm::answerSTLException ( exception &  )
throw (
)
protected

Helper function to serialize an 'exception' (based on it's 'what()'-member.

void rnp::RnpBaseServerComm::answerUnknownError ( )
throw (
)
protected

Helper function to serialize an unknown exception.

void rnp::RnpBaseServerComm::communicatorShouldExit ( )
throw (
)

Instructs the communicator that it should exit. Usefull to implement 'down server' commands

void rnp::RnpBaseServerComm::connectToCommunicator ( NbCommunicator &  )

Connect to the communicator. It also creates the jobs. Throws whatever new throws. Assert: no other connection!

int rnp::RnpBaseServerComm::countServerJobs ( )
throw (
)

Returns the number of server jobs.

virtual void rnp::RnpBaseServerComm::decodeFragment ( )
protectedpure virtual

Called by 'processRequest' to dispatch to the specific functions Might throw whatever appropriate

void rnp::RnpBaseServerComm::discardFragment ( )
throw (
)
protected

Helper function to discard a fragment.

bool rnp::RnpBaseServerComm::disconnectFromCommunicator ( )
throw (
)

Disconnect the jobs from the communicator and destroys them. Returns 'false' if there wasn't any connection to a communicator

void rnp::RnpBaseServerComm::endOkAnswer ( )
throw (
)
protected

Just for completeness, it's only an 'encoder.endFragment()'.

int rnp::RnpBaseServerComm::getCurrentParameterLength ( ) const
throw (
)
protected

Returns the length of the data of the current parameter.

double rnp::RnpBaseServerComm::getNextAsDouble ( RnpQuark  parameterType) const
protected

Returns next parameter as double, verifying the parameter type.

float rnp::RnpBaseServerComm::getNextAsFloat ( RnpQuark  parameterType) const
protected

Returns next parameter as float, verifying the parameter type.

int rnp::RnpBaseServerComm::getNextAsInteger ( RnpQuark  parameterType) const
protected

Returns next parameter as integer, verifying the parameter type.

const void* rnp::RnpBaseServerComm::getNextAsOpaque ( RnpQuark  parameterType) const
protected

Returns next parameter as const void* (can be NULL), verifying the parameter type.

const char* rnp::RnpBaseServerComm::getNextAsString ( RnpQuark  parameterType) const
protected

Returns next parameter as string(can be NULL), verifying the parameter type.

int rnp::RnpBaseServerComm::getTransmitterBufferSize ( )
throw (
)

Returns the transmitter buffer size.

virtual void rnp::RnpBaseServerComm::processRequest ( CommBuffer *  receiverBuffer,
CommBuffer *  transmiterBuffer,
RnpTransport::CarrierProtocol  ,
RnpServerJob callingJob 
)
throw (
)
virtual

The heart of the class. It takes the request, decodes it, sends every fragment to the 'decodeFragment()', which has to dispatch the commands to the specific functions. These functions have to use 'decoder' and 'encoder' to do their job and might throw whatever is appropriate. 'processRequest()' catches 'AkgException', 'exception' and (...) and converts them for transmission. If you don't like this version, make another one

Reimplemented in RnpRasDaManComm.

bool rnp::RnpBaseServerComm::setServerJobs ( int  nrOfServerJobs)
throw (
)

Sets the number of server jobs, only if there is no connection to a communicator Otherwise it changes nothing and returns 'false'

void rnp::RnpBaseServerComm::setTransmitterBufferSize ( int  )
throw (
)

Set the transmitter buffer size.

void rnp::RnpBaseServerComm::startOkAnswer ( )
throw (
)
protected

Start building an OK-answer.

Member Data Documentation

RnpProtocolDecoder rnp::RnpBaseServerComm::decoder
protected
RnpTransmitter rnp::RnpBaseServerComm::encoder
protected

The documentation for this class was generated from the following file: