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;
70  CLanguageList mLanguages;
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  //----------------------------------------
399  void startPropertySheetSubtree();
402  CXMLElement* getPropertySheetSubtree();
406  void endPropertySheetSubtree();
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
string getID() const
set ID of this session
bool rename(const string &inName)
Renaming this session (calls setSessionName, at present)
A class containing a session.
Definition: CSessionManager.h:63
ostream & write(ostream &outStream) const
Read the state.
string mPreferredLanguage
the language to be used in this session
Definition: CSessionManager.h:66
void setUser(const string &inUser)
set user of this session
The algorithm collection is kind of a factory for CQuery structures:
Definition: CAlgorithmCollection.h:58
CI18nTranslator mI18nTranslator
The Translator for this.
Definition: CSessionManager.h:222
CAlgorithm * mActiveAlgorithm
The algorithm used for the next query At present this fully describes a session.
Definition: CSessionManager.h:86
CStaticQueryFactory * mBaseTypeFactory
The base type factory is a factory for query base types.
Definition: CSessionManager.h:243
This class captures the structure of an XML element.
Definition: CXMLElement.h:51
This class builds and maintains a query tree.
Definition: CQueryTreeBuilder.h:30
takes the information contained in the list of properties, which is given in the config.mrml file.
Definition: CPropertySheetList.h:41
CSession()
Constructors.
string mSessionName
the name of this session
Definition: CSessionManager.h:82
string getUser() const
get user of this session
This class does nothing but wrap the current query interface in a way, that it can be used with CORBA...
Definition: CQueryTreeNode.h:24
CXMLElement * mPropertySheetSubtree
The subtree from which the mPropertySheets will be built.
Definition: CSessionManager.h:240
list< string > getLanguages() const
get the preferred languages of this session
An algorithm is a CXMLElement which is linked to a CSessionManager together they are able to build CQ...
Definition: CAlgorithm.h:43
CPropertySheetList * mPropertySheetList
These are the building blocks of the property sheets to be generated by *this.
Definition: CSessionManager.h:237
This class offers runtime translation of strings.
Definition: CI18nTranslator.h:38
bool open()
opening this session.
The Query manager for Queries on inverted Files.
Definition: CQuery.h:73
A factory for base types of algorithms.
Definition: CStaticQueryFactory.h:38
void addLanguage(string inLanguageCode)
one language code is added at the back of the list of preferred languages
string getPreferredLanguage() const
get the preferred languages of this session
bool close()
Closing this session.
map< string, list< CSession > > CUserToSessions
point the user to all the sessions
Definition: CSessionManager.h:226
CMutex mMutexSession
the mutex for this session
Definition: CSessionManager.h:72
This structure handles the sessions; by this, it encapsulates the current state of the server...
Definition: CSessionManager.h:209
This is in fact a collection of collections.
Definition: CAccessorAdminCollection.h:39
CAccessorAdminCollection mAccessorAdminCollection
The accessor collection is needed for constructing queries.
Definition: CSessionManager.h:218
pair< CQueryContainer *, CQueryTreeNode * > mQueryTree
The information about the current query tree.
Definition: CSessionManager.h:88
void commitLanguages(const CI18nTranslator &inTranslator)
commit the list of languages.
CXMLElement * getRandomImages(CSessionManager &inCaller, const string &inAlgorithm, int inResultSize)
retrieving random images as seeds
void setID(const string &inID)
get ID of this session
istream & read(istream &inStream)
Write the state.
This class offers an abstraction from the locking method used.
Definition: CMutex.h:40
string getSessionName() const
get the displayname of this session
bool setActiveAlgorithm(CAccessorAdminCollection &inCaller, CAlgorithmCollection &inAlgorithmCollection, CAlgorithm *inActiveAlgorithm, CStaticQueryFactory &inBaseTypeFactory)
set the algorithm of this session.
CAlgorithm * getActiveAlgorithm()
get the algorithm of this session
void clearLanguages()
the list of preferred languages of this is cleared
string toXML(bool isPrivate) const
generating XML output for configuration/shandshake
~CSession()
destroys all members
CLanguageList mLanguages
the list of languages to be used
Definition: CSessionManager.h:70
CXMLElement * query(CSessionManager &inCaller, const CXMLElement &inQuery)
set the collection of this session
void setSessionName(const string &inSessionName)
set the displayname of this session
list< string > CLanguageList
the list of languages to be used
Definition: CSessionManager.h:68

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