System documentation of the GNU Image-Finding Tool

Public Member Functions | Public Attributes | Protected Attributes | List of all members
CCommunicationHandler Class Reference

a helper class for use with expat, which also handles the socket stuff. More...

#include <CCommunicationHandler.h>

Public Member Functions

void setSocket (int inSocket)
 communications:
string preamble ()
 helpers for creating mrml messages
string frame (const string &inSession, const string &inString)
 Frame: this is for all messages the same.
string toAttribute (string inName, string inString)
 making attributes out of name/value pairs
string toAttribute (string inName, int inInt)
string toAttribute (string inName, double inFloat)
int sendError (const string &inSession, const string &inMessage)
 turning a relevance level element into a string
void openSession (const string &inUserName, const string &inSessionName)
 Opening a session.
void renameSession (const string &inSessionID, const string &inNewName)
 renaming the current session
void deleteSession (const string &inName)
 renaming the current session
void getPropertySheet (const string &inSessionID, const string &inAlgorithmID)
 Gets the property sheet contained in the algorithm with inAlgorithmID.
int sendHandshake (const string &inUser)
 the handshake message (old MRML)
void getSessions (const string &inUser)
 getting the sessions for one user (new MRML)
void getCollections ()
 getting collections available on a system
void getAlgorithms ()
 getting algorithms available on a system
int sendResult (const string &inSession, const CXMLElement &inRLL)
 the result of a query
int sendRandomImages (const string &inSession, const string &inAlgorithm, const string &inCollection, const string &inNumberOfImages)
 random images
void setResultSize (int inResultSize)
 setting properties of the query
void setResultCutoff (const string &inCutoff)
void setResultCutoff (double inCutoff)
void setCollectionID (const string &inID)
void setAlgorithmID (const string &inID)
void startTreeBuilding (const char *inElementName, const char *const *const inAttributes)
 Start building a tree by successive adding of XML elements.
void addToCurrentTree (const char *inElementName, const char *const *const inAttributes)
 Start building a tree by successive adding of XML elements.
void moveUpCurrentTree ()
 move up in the tree
bool isBuildingTree () const
 is this building a tree at present?
void parseString (const string &inMessage)
 parse XML using expat
void clearAlgorithmElement ()
 Clear the algorithm tree element.
void startAlgorithmElement (const char *inName, const char *const *const inAttributes)
 start of an element in the tree of configured algorithms.
void endAlgorithmElement ()
 end of an element in the tree of configured algorithms
void initAlgorithmElement ()
 clear the pointer to the algorithm tree
CAlgorithmreadAlgorithmElement ()
 read the pointer to the algorithm tree
void endConfiguration ()
 End the configuration i.e.
void clearParsingFinished ()
void setParsingFinished ()
bool isParsingFinished () const
bool readAndParse ()
void makeParser ()
void startMultiRequest (const string &inSessionID, const string &inLanguageCode="en")
 If we process multiple queries which are part of one message, we have to first collect the answers from the requests, and then send the whole message.
void endMultiRequest ()
 sends the message which has been built
void addToMultiResponse (CXMLElement *inElement)
 adds an XMLElement to the multi-response which is built
const string getCurrentSessionID ()
 returns the currently valid SessionID
CSessionManagergetSessionManager ()
 Using the session manager which is a member.
void incrementQueryAtRandomCount ()
 incrementing the QueryAtRandomCount flag
int getQueryAtRandomCount () const
 reading this flag
void setPeerAddressString (string)
 set the name of the peer, this is just an informative string, destined for the log.
const string & getPeerAddressString () const
 get the Peer adress string
 CCommunicationHandler (CSessionManager &inSessionManager, ofstream &inLogFile)
 constructor/destructor

Public Attributes

CSelfDestroyPointer< CXMLElementmMultiResponse
 A DOM-alike tree which will be built from all the answers given to the requests.
CXMLElementgQueryImages
 processing a query
string mSessionID
int mResultSize
double mCutoff
string mCollection
string mAlgorithm
bool mParsingFinished
 parsing from a stream: read each character parse it

Protected Attributes

int mQueryAtRandomCount
 We have said, that the user can tell, if he wants a query in the normal sense or rather a collection of random images, in which case the inner parts of the query are ignored.
int mSocket
 The socket, which is used for this communication.
ofstream & mLog
 The logfile which logs all communication.

Detailed Description

a helper class for use with expat, which also handles the socket stuff.

Author
: Wolfgang Müller

Member Function Documentation

void CCommunicationHandler::clearAlgorithmElement ( )

Clear the algorithm tree element.

We do not assume destruction responsability here

This responsability is transferred to the containing session.

FIXME do something cleaner for the case of failure

void CCommunicationHandler::endConfiguration ( )

End the configuration i.e.

make out of the algorithm structure a query processing structure.

CSessionManager& CCommunicationHandler::getSessionManager ( )

Using the session manager which is a member.

of this for other purposes

string CCommunicationHandler::preamble ( )

helpers for creating mrml messages

the preamble for a session

int CCommunicationHandler::sendError ( const string &  inSession,
const string &  inMessage 
)

turning a relevance level element into a string

(obsolete) Error message

void CCommunicationHandler::setPeerAddressString ( string  )

set the name of the peer, this is just an informative string, destined for the log.

The string can contain either the IP of the connecting computer, or else the peer credentials of the connecting tasks.

void CCommunicationHandler::setSocket ( int  inSocket)

communications:

setting the communication socket for this session

void CCommunicationHandler::startAlgorithmElement ( const char *  inName,
const char *const *const  inAttributes 
)

start of an element in the tree of configured algorithms.

If mAlgorithm=0 then generate a new XML element with the content given by inName and inAttributes

Parameters
inNameThe name like given by expat
inAttributesan attributes list like given by expat
void CCommunicationHandler::startMultiRequest ( const string &  inSessionID,
const string &  inLanguageCode = "en" 
)

If we process multiple queries which are part of one message, we have to first collect the answers from the requests, and then send the whole message.

startMultiRequest and endMultiRequest

are the functions which administer this process.

startMultiRequest clears the message which is going to be built and sets the language code

Member Data Documentation

ofstream& CCommunicationHandler::mLog
protected

The logfile which logs all communication.

*this will APPEND NEW DATA to the logfile, as you would expect

CSelfDestroyPointer<CXMLElement> CCommunicationHandler::mMultiResponse

A DOM-alike tree which will be built from all the answers given to the requests.

at the moment this is public, because I need it to slowly hack the negotiation code.

int CCommunicationHandler::mQueryAtRandomCount
protected

We have said, that the user can tell, if he wants a query in the normal sense or rather a collection of random images, in which case the inner parts of the query are ignored.

The flag used to perform this is this variable.


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

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen