System documentation of the GNU Image-Finding Tool

CCommunicationHandler.h
1 /* -*- mode: c++ -*-
2 */
3 /*
4 
5  GIFT, a flexible content based image retrieval system.
6  Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
7 
8  Copyright (C) 2003, 2004 Bayreuth University
9  2005 Bamberg University
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 */
25 
26 
27 
28 //configuration files for sessions and algorithms/collections
29 #ifndef _CCOMMUNICATIONHANDLER
30 #define _CCOMMUNICATIONHANDLER
31 #include "libMRML/include/uses-declarations.h"
32 //the expat xml parser by J.Clark
33 #include <expat.h>
34 //a class for using xpat attributes in a nice way
35 #include "libMRML/include/CAttributeList.h"
36 
37 //This is mrml+gift specific
38 #include "libMRML/include/CSessionManager.h"
39 #include "libMRML/include/CXMLElement.h"
40 #include <functional>
41 #include <iostream>
42 #include <fstream>
43 #include "libMRML/include/CMutex.h"
44 //----------------------------------------
46 extern void startMRMLElement(void *userData,
47  const char *inElementName,
48  const char **inAttributes);
49 extern void endMRMLElement(void *userData, const char *name);
50 
55 
61 
64  XML_Parser mParser;
65 
68  CSessionManager& mSessionManager;
74  CAlgorithm* mAlgorithmTree;
80 
86  string mPeerAddressString;
87 
88 public:
97 
98 protected:
106 protected:
108  int mSocket;
112  ofstream& mLog;
113 public:
114  //----------------------------------------
116  //----------------------------------------
118  void setSocket(int inSocket);
119 
120  //----------------------------------------
122  //----------------------------------------
124  string preamble();
125 
126 
127 
129  string frame(const string& inSession,
130  const string& inString);
131 
132 
133  //----------------------------------------
135  string toAttribute(string inName,
136  string inString);
137 
138 
139  string toAttribute(string inName,
140  int inInt);
141 
142 
143  string toAttribute(string inName,
144  double inFloat);
145 
146  // //----------------------------------------
147  // /** turning a relevance level element into a string */
148  // /** (obsolete) */
149  // string stringOfRelevanceLevelElement(const CRelevanceLevel& inRE,
150  // double inUserRelevance=0.5);
151 
152  // string stringOfRelevanceLevelList(const CRelevanceLevelList& inRLL);
153 
154 
155  //----------------------------------------
157  int sendError(const string& inSession,
158  const string& inMessage);
159 
160  //----------------------------------------
162  void openSession(const string& inUserName,
163  const string& inSessionName);
165  void renameSession(const string& inSessionID,
166  const string& inNewName);
167 
169  void deleteSession(const string& inName);
170 
171 
174  void getPropertySheet(const string& inSessionID,
175  const string& inAlgorithmID);
176  //----------------------------------------
178  int sendHandshake(const string& inUser);
179 
181  void getSessions(const string& inUser);
183  void getCollections();
185  void getAlgorithms();
186  //----------------------------------------
188  int sendResult(const string& inSession,
189  const CXMLElement& inRLL);
190 
191 
192  //----------------------------------------
194  int sendRandomImages(const string& inSession,
195  const string& inAlgorithm,
196  const string& inCollection,
197  const string& inNumberOfImages) ;
198  ;
199 
200 
201  //----------------------------------------
203  //----------------------------------------
205  string mSessionID;
206  int mResultSize;
207  double mCutoff;
208  string mCollection;
209  string mAlgorithm;
210 
211  //----------------------------------------
213  void setResultSize(int inResultSize);
214 
215 
216  void setResultCutoff(const string& inCutoff);
217 
218  void setResultCutoff(double inCutoff);
219 
220 
221  void setCollectionID(const string& inID);
222 
223 
224  void setAlgorithmID(const string& inID);
225 
226  //----------------------------------------
229  void startTreeBuilding(const char* inElementName,
230  const char*const*const inAttributes);
233  void addToCurrentTree(const char* inElementName,
234  const char*const*const inAttributes);
238  void moveUpCurrentTree();
242  bool isBuildingTree()const;
243 
244  //----------------------------------------
246  //----------------------------------------
247  void parseString(const string& inMessage);
248 
249 
250  //----------------------------------------
260  void clearAlgorithmElement();
261  //----------------------------------------
274  //----------------------------------------
275  void startAlgorithmElement(const char* inName,
276  const char* const* const inAttributes);
277  //----------------------------------------
281  //----------------------------------------
282  void endAlgorithmElement();
283  //----------------------------------------
287  //----------------------------------------
288  void initAlgorithmElement();
289  //----------------------------------------
292  //----------------------------------------
294  //----------------------------------------
300  void endConfiguration();
301 
302  //----------------------------------------
307  void clearParsingFinished();
308  void setParsingFinished();
309  bool isParsingFinished()const;
310 
311  bool readAndParse();
312 
313 
314 
315  void makeParser();
316 
317 
331  void startMultiRequest(const string& inSessionID, const string& inLanguageCode="en");
333  void endMultiRequest();
337  void addToMultiResponse(CXMLElement* inElement);
339  const string getCurrentSessionID();
340 
341 
342  //----------------------------------------
345  //----------------------------------------
347 
351  int getQueryAtRandomCount()const;
352 
362  void setPeerAddressString(string);
364  const string& getPeerAddressString()const;
365 
366  //----------------------------------------
368  //----------------------------------------
369  CCommunicationHandler(CSessionManager& inSessionManager,
370  ofstream& inLogFile);
371 
373 };
374 
375 
376 #endif

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