rasdaman complete source
|
#include <rnpcommunication.hh>
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 |
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
rnp::RnpBaseServerComm::RnpBaseServerComm | ( | ) | ||
throw | ( | |||
) |
Default constructor - 1 server job.
|
virtual |
Destructor.
|
protected |
Helper function to serialize an 'AkgException'.
|
protected |
Helper function to serialize an 'exception' (based on it's 'what()'-member.
|
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.
|
protectedpure virtual |
Called by 'processRequest' to dispatch to the specific functions Might throw whatever appropriate
|
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
|
protected |
Just for completeness, it's only an 'encoder.endFragment()'.
|
protected |
Returns the length of the data of the current parameter.
|
protected |
Returns next parameter as double, verifying the parameter type.
|
protected |
Returns next parameter as float, verifying the parameter type.
|
protected |
Returns next parameter as integer, verifying the parameter type.
|
protected |
Returns next parameter as const void* (can be NULL), verifying the parameter type.
|
protected |
Returns next parameter as string(can be NULL), verifying the parameter type.
int rnp::RnpBaseServerComm::getTransmitterBufferSize | ( | ) | ||
throw | ( | |||
) |
Returns the transmitter buffer size.
|
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.
|
protected |
Start building an OK-answer.
|
protected |
|
protected |