rasdaman complete source
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
akg::NbJob Class Referenceabstract

#include <akgnet_nbcomm.hh>

Inheritance diagram for akg::NbJob:
akg::NbClientJob akg::NbServerJob rnp::RnpClientJob rnp::RnpServerJob RnpRasserverJob

Public Types

enum  acceptStatus { acs_nopending = 0, acs_Iambusy = 1, acs_accepted = 2 }
 Status regarding accepting a new job. More...
 
enum  workingStatus {
  wks_notdefined = 0, wks_accepting = 1, wks_reading = 2, wks_writing = 3,
  wks_processing = 4
}
 Status during the lifetime of a job. More...
 

Public Member Functions

virtual ~NbJob () throw ()
 
workingStatus getStatus () throw ()
 Returns the working status. More...
 
bool isOperationPending () throw ()
 
bool isAccepting () throw ()
 Returns true if the job is ready to accept a connection. More...
 
bool isReading () throw ()
 Returns true if the job is reading data. More...
 
bool isWriting () throw ()
 Returns true if the job is writing data. More...
 
bool isProcessing () throw ()
 Returns true if the job is processing. More...
 
virtual void initOnAttach (Selector *pselector)=0 throw ()
 
virtual acceptStatus acceptConnection (ListenSocket &listenSocket)=0 throw ()
 
bool readPartialMessage () throw ()
 
bool writePartialMessage () throw ()
 
void clearConnection () throw ()
 Clears the connection - closes the socket and removes it from the Selector. More...
 
int getSocket () throw ()
 Returns the OS file descriptor for the socket. More...
 
int getErrno () throw ()
 Returns the errno of the last socket operation. More...
 
virtual bool cleanUpIfTimeout () throw ()
 
virtual void processRequest ()=0 throw ()
 

Static Public Member Functions

static void setCurrentTime () throw ()
 
static void setTimeoutInterval (time_t x) throw ()
 
static time_t getTimeoutInterval () throw ()
 Returns the timeout interval set for the jobs. More...
 

Protected Member Functions

virtual bool validateMessage ()=0 throw ()
 called after every read, returns 'true' if the message is all here More...
 
virtual void executeOnAccept () throw ()
 called when client is accepted, default does nothing More...
 
virtual void executeOnWriteReady ()=0 throw ()
 called when message is written More...
 
virtual void specificCleanUpOnTimeout ()=0 throw ()
 called when timeout, it has to set the status apropriate and do other cleanup More...
 
virtual void executeOnReadError ()=0 throw ()
 called when a read error occurs, usual a message and clean up More...
 
virtual void executeOnWriteError ()=0 throw ()
 called when a write error occurs, usual a message and clean up More...
 
 NbJob (FileDescriptor &) throw ()
 Protected constructor, taking a FileDescriptor, usually a Socket. More...
 
bool setReading () throw ()
 Helper function for setting the job in read modus. More...
 
bool setWriting () throw ()
 Helper function for setting the job in write modus. More...
 
void action () throw ()
 Helper function which marks the current moment, so timeout counter is reset. More...
 

Protected Attributes

workingStatus status
 
FileDescriptorfdRef
 
SelectorselectorPtr
 
CommBuffercurrentBufferPtr
 
time_t lastActionTime
 

Static Protected Attributes

static time_t timeOutInterv
 
static time_t currentTime
 

Detailed Description

Base class for non-blocking communication jobs

Constructor & Destructor Documentation

virtual akg::NbJob::~NbJob ( )
throw (
)
virtual
akg::NbJob::NbJob ( FileDescriptor )
throw (
)
protected

Protected constructor, taking a FileDescriptor, usually a Socket.

Member Function Documentation

virtual acceptStatus akg::NbJob::acceptConnection ( ListenSocket listenSocket)
throw (
)
pure virtual

Pure function to do initialization when accepting a connection Returns:

  • acs_nopending when there is connection pending
  • acs_Iambusy when the job can't accept this connection
  • acs_accepted when the connection was accepted Assert: the 'currentBufferPtr' is initialized. This would be a software error Don't throw!

Implemented in akg::NbClientJob, and akg::NbServerJob.

void akg::NbJob::action ( )
throw (
)
protected

Helper function which marks the current moment, so timeout counter is reset.

virtual bool akg::NbJob::cleanUpIfTimeout ( )
throw (
)
virtual

Virtual function to clean up if timeout occured This version returns 'false' if no timeout or no connection If timeout it clears the connection and calls 'specificCleanUpOnTimeout()' Don't throw!

void akg::NbJob::clearConnection ( )
throw (
)

Clears the connection - closes the socket and removes it from the Selector.

virtual void akg::NbJob::executeOnAccept ( )
throw (
)
protectedvirtual

called when client is accepted, default does nothing

Reimplemented in rnp::RnpServerJob.

virtual void akg::NbJob::executeOnReadError ( )
throw (
)
protectedpure virtual

called when a read error occurs, usual a message and clean up

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

virtual void akg::NbJob::executeOnWriteError ( )
throw (
)
protectedpure virtual

called when a write error occurs, usual a message and clean up

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

virtual void akg::NbJob::executeOnWriteReady ( )
throw (
)
protectedpure virtual

called when message is written

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

int akg::NbJob::getErrno ( )
throw (
)

Returns the errno of the last socket operation.

int akg::NbJob::getSocket ( )
throw (
)

Returns the OS file descriptor for the socket.

workingStatus akg::NbJob::getStatus ( )
throw (
)

Returns the working status.

static time_t akg::NbJob::getTimeoutInterval ( )
throw (
)
static

Returns the timeout interval set for the jobs.

virtual void akg::NbJob::initOnAttach ( Selector pselector)
throw (
)
pure virtual

Pure function to do initialization when attached to a Selector Don't throw!

Implemented in akg::NbClientJob, and akg::NbServerJob.

bool akg::NbJob::isAccepting ( )
throw (
)

Returns true if the job is ready to accept a connection.

bool akg::NbJob::isOperationPending ( )
throw (
)

Returns true if there is an operation in progress this means reading, writing or processing

bool akg::NbJob::isProcessing ( )
throw (
)

Returns true if the job is processing.

bool akg::NbJob::isReading ( )
throw (
)

Returns true if the job is reading data.

bool akg::NbJob::isWriting ( )
throw (
)

Returns true if the job is writing data.

virtual void akg::NbJob::processRequest ( )
throw (
)
pure virtual

Pure function to process the request It has to set the appropriate status, so the server knows how to continue with this job Don't throw!

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

bool akg::NbJob::readPartialMessage ( )
throw (
)

Reads as much data as it can. After every read it calls the 'validateMessage()' function and returns whatever this function returns. If there is a read error, other than EINTR or EAGAIN, the function 'executeOnReadError()' is called Returns 'true' if the message is completelly red Returns 'false' if there should be some more data

static void akg::NbJob::setCurrentTime ( )
throw (
)
static

Static function for setting the current time. Used for marking the last action time, so timeout can be monitorized

bool akg::NbJob::setReading ( )
throw (
)
protected

Helper function for setting the job in read modus.

static void akg::NbJob::setTimeoutInterval ( time_t  x)
throw (
)
static

Static function for setting the timeout interval We use the same timeout for all jobs because the server doesn't do any distinction between jobs

bool akg::NbJob::setWriting ( )
throw (
)
protected

Helper function for setting the job in write modus.

virtual void akg::NbJob::specificCleanUpOnTimeout ( )
throw (
)
protectedpure virtual

called when timeout, it has to set the status apropriate and do other cleanup

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

virtual bool akg::NbJob::validateMessage ( )
throw (
)
protectedpure virtual

called after every read, returns 'true' if the message is all here

Implemented in rnp::RnpServerJob, and rnp::RnpClientJob.

bool akg::NbJob::writePartialMessage ( )
throw (
)

Writes as much data as it can. After writing all data the function 'executeOnWriteReady()' is called. If there is a write error, other than EINTR or EAGAIN, the function 'executeOnWriteError()' is called Returns 'true' if the message is completelly written Returns 'false' if there should be some more data to write

Member Data Documentation

CommBuffer* akg::NbJob::currentBufferPtr
protected

Pointer to a CommBuffer, which has to be provided by the derived class

time_t akg::NbJob::currentTime
staticprotected
FileDescriptor& akg::NbJob::fdRef
protected

Reference to a FileDescriptor, usually a Socket. It has to be provided by the derived class

time_t akg::NbJob::lastActionTime
protected
Selector* akg::NbJob::selectorPtr
protected

Pointer to a Selector, which has to be provided by the Server object to which this job is attached

workingStatus akg::NbJob::status
protected
time_t akg::NbJob::timeOutInterv
staticprotected

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