CCommunicationHandler Class

# CCommunicationHandler Class Reference

[CADIHash.h Index] [CADIHash.h Hierarchy]

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

`#include <../GIFTServer/CCommunicationHandler.h>`

## Public Members

- void setSocket (int inSocket)
- string preamble ()
- string frame (const string& inSession, const string& inString)
- string toAttribute (string inName, string inString)
- string toAttribute (string inName, int inInt)
- string toAttribute (string inName, double inFloat)
- int sendError (const string& inSession, const string& inMessage)
- void openSession (const string& inUserName, const string& inSessionName)
- void renameSession (const string& inSessionID, const string& inNewName)
- void deleteSession (const string& inName)
- void getPropertySheet (const string& inSessionID, const string& inAlgorithmID)
- int sendHandshake (const string& inUser)
- void getSessions (const string& inUser)
- void getCollections ()
- void getAlgorithms ()
- int sendResult (const string& inSession, const CXMLElement& inRLL)
- int sendRandomImages (const string& inSession, const string& inAlgorithm, const string& inCollection, const string& inNumberOfImages)
- CXMLElement* gQueryImages
- string mSessionID
- int mResultSize
- double mCutoff
- string mCollection
- string mAlgorithm
- void setResultSize (int inResultSize)
- 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)
- void addToCurrentTree (const char* inElementName, const char*const*const inAttributes)
- void moveUpCurrentTree ()
- bool isBuildingTree ()
- void parseString (const string& inMessage)
- void clearAlgorithmElement ()
- void startAlgorithmElement (const char* inName, const char* const* const inAttributes)
- void endAlgorithmElement ()
- void initAlgorithmElement ()
- CAlgorithm* readAlgorithmElement ()
- void endConfiguration ()
- bool mParsingFinished
- void clearParsingFinished ()
- void setParsingFinished ()
- bool isParsingFinished ()
- bool readAndParse ()
- void makeParser ()
- void startMultiRequest (const string& inSessionID)
- void endMultiRequest ()
- void addToMultiResponse (CXMLElement* inElement)
- CSessionManager& getSessionManager ()
- void incrementQueryAtRandomCount ()
- int getQueryAtRandomCount ()
- CCommunicationHandler (const string& inBaseDir)
- ~CCommunicationHandler ()

## Protected Members

- int mQueryAtRandomCount
- int mSocket
- ofstream mLog

## Detailed Description

a helper class for use with expat, which also handles the socket stuff.@author: Wolfgang Müller

## void setSocket(int inSocket)

setting the communication socket for this session

## string preamble()

the preamble for a session

## 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

## int sendError(const string& inSession, const string& inMessage)

Error message

## 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

## 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

## CXMLElement* gQueryImages

processing a query

## void setResultSize(int inResultSize)

setting properties of the query

## void startTreeBuilding(const char* inElementName, const char*const*const inAttributes)

Start building a tree by successive adding

## void addToCurrentTree(const char* inElementName, const char*const*const inAttributes)

Start building a tree by successive adding

## void moveUpCurrentTree()

move up in the tree

## bool isBuildingTree()

is this building a tree at present?

## void parseString(const string& inMessage)

parse XML using expat

## void 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 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:

  inName | The name like given by expat
  inAttributes | an attributes list like given byexpat

## void endAlgorithmElement()

end of an element in the tree of configured

## void initAlgorithmElement()

clear the pointer to the algorithm tree

## CAlgorithm* readAlgorithmElement()

read the pointer to the algorithm tree

## void endConfiguration()

End the configuration i.e. make out of the algorithm structure a query processing structure.

## bool mParsingFinished

parsing from a stream: read each character

## void startMultiRequest(const string& inSessionID)

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.

## void endMultiRequest()

sends the message which has been built

## void addToMultiResponse(CXMLElement* inElement)

adds an XMLElement to the multi-response which is built

## CSessionManager& getSessionManager()

of this for other purposes

## void incrementQueryAtRandomCount()

incrementing the QueryAtRandomCount flag

## int getQueryAtRandomCount()

reading this flag

## CCommunicationHandler(const string& inBaseDir)

constructor/destructor

## int mQueryAtRandomCount

We have said, that the user can tell, if he wants a queryin 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.

## int mSocket

The socket, which is used for this communication

## ofstream mLog

The logfile which logs all communication. *thiswill APPEND NEW DATA to the logfile, as you would expect

| Kdoc