System documentation of the GNU Image-Finding Tool

CSessionManager.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 // -*- mode: c++ -*-
26 #ifndef _CSESSIONMANAGER
27 #define _CSESSIONMANAGER
28 #include "libMRML/include/uses-declarations.h"
29 #include <iostream>
30 #include <string>
31 #include <list>
32 #include <map>
33 #include "libMRML/include/CXMLElement.h"
34 #include "libMRML/include/CAccessorAdminCollection.h"
35 #include "libMRML/include/CI18nTranslator.h"
36 #include "libMRML/include/CAlgorithm.h"
37 #include "libMRML/include/CPropertySheetList.h"
38 #include "libMRML/include/CAccessorElement.h"
39 #include "libMRML/include/CAlgorithmCollection.h"
40 #include "libMRML/include/CQueryTreeBuilder.h"
41 #include "libMRML/include/CMutex.h" // multithreading
43 class CAlgorithm;
44 class CSessionManager;
45 class CQueryTreeNode;
63 class CSession{
64 protected:
68  typedef list<string> CLanguageList;
74  bool mIsOpen;
76  string mUser;
78  string mID;
82  string mSessionName;
88  pair<CQueryContainer*,CQueryTreeNode*> mQueryTree;
90  static CQueryTreeBuilder mQueryTreeBuilder;
91 public:
92  //--------------------------------------------------
94  CSession();
97  CSession(string inUser,
98  string inID,
99  string inSessionName,
100  CAlgorithm* inActiveAlgorithm
101  );
105  ~CSession();
106  //--------------------------------------------------
108  ostream& write(ostream& outStream)const;
110  istream& read(istream& inStream);
111  //--------------------------------------------------
113  string getUser()const;
115  void setUser(const string& inUser);
117  string getID()const;
119  void setID(const string& inID);
121  string getSessionName()const;
123  void setSessionName(const string& inSessionName);
135  CAlgorithmCollection& inAlgorithmCollection,
136  CAlgorithm* inActiveAlgorithm,
137  CStaticQueryFactory& inBaseTypeFactory);
139  //string getActiveCollection()const;
141  // void setActiveCollection(const string& inCollection);
142  //--------------------------------------------------
149  CXMLElement* query(CSessionManager& inCaller,
150  const CXMLElement& inQuery);
151  //--------------------------------------------------
154  const string& inAlgorithm,
155  int inResultSize);
156 
157  //--------------------------------------------------
163  bool open();
164  //--------------------------------------------------
167  bool close();
168  //--------------------------------------------------
172  bool rename(const string& inName);
175  void clearLanguages();
178  void addLanguage(string inLanguageCode);
182  void commitLanguages(const CI18nTranslator& inTranslator);
184  list<string> getLanguages()const;
186  string getPreferredLanguage()const;
187 
188  //--------------------------------------------------
190  string toXML(bool isPrivate)const;
191 };
192 
210  //,public CAlgorithmIDListList
211 {
213  CMutex mMutexSessionManager;
214 protected:
226  typedef map<string,list<CSession> > CUserToSessions;
228  typedef map<string,CSession*> CIDToSession;
230  mutable CUserToSessions mUserToSessions;
232  mutable CIDToSession mIDToSession;
244 public:
249  CSessionManager(string inSessions,
250  string inConfiguration,
251  string inI18nFileName);
252  //----------------------------------------
257  CQuery* makeQuery(const string& inBaseType,
258  CAlgorithm& inAlgorithm);
259  //----------------------------------------
262  istream& read(istream&);
264  ostream& write(ostream&);
265  //----------------------------------------
269  CXMLElement* openSession(string inUserName,
270  string inSessionID,
271  string inSessionName);
272  //----------------------------------------
276  CXMLElement* renameSession(string inSessionID,
277  string inSessionName);
280  CXMLElement* deleteSession(string inSessionID);
285  CXMLElement* closeSession(string inSessionID);
292  CXMLElement* query(const string& inSessionID,
293  const CXMLElement& inRelevanceLevelList);
294  //--------------------------------------------------
306  CXMLElement* getRandomImages(const string& inSessionID,
307  const string& inAlgorithm,
308  int inResultSize);
309  //--------------------------------------------------
311  list<CAccessorElement>* getAllAccessorElements(const string& inSessionID,
312  const string& inAlgorithm
313  );
314  //--------------------------------------------------
316  list<TID>* getAllIDs(const string& inSessionID,
317  const string& inAlgorithm
318  );
319  //----------------------------------------
327  bool setAlgorithm(const string& inSessionID,
328  CAlgorithm* inAlgorithm);
330  string newSession(const string& inUser,
331  const string& inSessionName);
333  string newSession(const string& inID,
334  const string& inUser,
335  const string& inSessionName);
338  void setSessionName(const string& inOldSessionName,
339  const string& inNewSessionName);
340  //----------------------------------------
364  //----------------------------------------
369  string toXML(bool isPrivate=false)const;
377  string toXMLSessions(const string& inUser,
378  bool isPrivate=false)const;
380  string toXMLSessionConfiguration()const;
382  pair<string,string> toXMLHandshake(const string& inUser);
388  CXMLElement* getPropertySheet(string inSessionID,
389  string inAlgorithmID)const;
390  //----------------------------------------
409  CXMLElement* getCollections()const;
412  CXMLElement* getAlgorithms()const;
414  bool clearSessionLanguages(const string& inSessionID);
416  bool addSessionLanguage(const string& inSessionID,
417  const string& inLanguageCode);
419  bool commitSessionLanguages(const string& inSessionID);
421  list<string> getSessionLanguages(const string& inSessionID)const;
423  void translate(string inSessionID,
424  CXMLElement& inoutToBeTranslated)const;
425 };
426 
427 #endif

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