#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 | |
CAlgorithm * | readAlgorithmElement () |
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 | |
CSessionManager & | getSessionManager () |
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< CXMLElement > | mMultiResponse |
A DOM-alike tree which will be built from all the answers given to the requests. | |
CXMLElement * | gQueryImages |
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. |
void CCommunicationHandler::setSocket | ( | int | inSocket | ) |
communications:
setting the communication socket for this session
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::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::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
inName | The name like given by expat | |
inAttributes | an attributes list like given by expat |
void CCommunicationHandler::endConfiguration | ( | ) |
End the configuration i.e.
make out of the algorithm structure a query processing structure.
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
CSessionManager& CCommunicationHandler::getSessionManager | ( | ) |
Using the session manager which is a member.
of this for other purposes
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.
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.
ofstream& CCommunicationHandler::mLog [protected] |
The logfile which logs all communication.
*this will APPEND NEW DATA to the logfile, as you would expect