System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CSessionManager.h

00001 /* -*- mode: c++ -*- 00002 */ 00003 /* 00004 00005 GIFT, a flexible content based image retrieval system. 00006 Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 */ 00023 // -*- mode: c++ -*- 00024 #ifndef _CSESSIONMANAGER 00025 #define _CSESSIONMANAGER 00026 #include "libMRML/include/uses-declarations.h" 00027 #include <iostream> 00028 #include <string> 00029 #include <list> 00030 #include <map> 00031 #include "libMRML/include/CXMLElement.h" 00032 #include "libMRML/include/CAccessorAdminCollection.h" 00033 #include "libMRML/include/CI18nTranslator.h" 00034 #include "libMRML/include/CAlgorithm.h" 00035 #include "libMRML/include/CPropertySheetList.h" 00036 #include "libMRML/include/CAccessorElement.h" 00037 #include "libMRML/include/CAlgorithmCollection.h" 00038 #include "libMRML/include/CQueryTreeBuilder.h" 00039 #include "libMRML/include/CMutex.h" // multithreading 00040 class CStaticQueryFactory; 00041 class CAlgorithm; 00042 class CSessionManager; 00043 class CQueryTreeNode; 00044 class CStaticQueryFactory; 00061 class CSession{ 00062 protected: 00064 string mPreferredLanguage; 00066 typedef list<string> CLanguageList; 00068 CLanguageList mLanguages; 00070 CMutex mMutexSession; 00072 bool mIsOpen; 00074 string mUser; 00076 string mID; 00080 string mSessionName; 00084 CAlgorithm* mActiveAlgorithm; 00086 pair<CQueryContainer*,CQueryTreeNode*> mQueryTree; 00088 static CQueryTreeBuilder mQueryTreeBuilder; 00089 public: 00090 //-------------------------------------------------- 00092 CSession(); 00095 CSession(string inUser, 00096 string inID, 00097 string inSessionName, 00098 CAlgorithm* inActiveAlgorithm 00099 ); 00103 ~CSession(); 00104 //-------------------------------------------------- 00106 ostream& write(ostream& outStream)const; 00108 istream& read(istream& inStream); 00109 //-------------------------------------------------- 00111 string getUser()const; 00113 void setUser(const string& inUser); 00115 string getID()const; 00117 void setID(const string& inID); 00119 string getSessionName()const; 00121 void setSessionName(const string& inSessionName); 00123 CAlgorithm* getActiveAlgorithm(); 00132 bool setActiveAlgorithm(CAccessorAdminCollection& inCaller, 00133 CAlgorithmCollection& inAlgorithmCollection, 00134 CAlgorithm* inActiveAlgorithm, 00135 CStaticQueryFactory& inBaseTypeFactory); 00137 //string getActiveCollection()const; 00139 // void setActiveCollection(const string& inCollection); 00140 //-------------------------------------------------- 00147 CXMLElement* query(CSessionManager& inCaller, 00148 const CXMLElement& inQuery); 00149 //-------------------------------------------------- 00151 CXMLElement* getRandomImages(CSessionManager& inCaller, 00152 const string& inAlgorithm, 00153 int inResultSize); 00154 00155 //-------------------------------------------------- 00161 bool open(); 00162 //-------------------------------------------------- 00165 bool close(); 00166 //-------------------------------------------------- 00170 bool rename(const string& inName); 00173 void CSession::clearLanguages(); 00176 void CSession::addLanguage(string inLanguageCode); 00180 void CSession::commitLanguages(const CI18nTranslator& inTranslator); 00182 list<string> CSession::getLanguages()const; 00184 string CSession::getPreferredLanguage()const; 00185 00186 //-------------------------------------------------- 00188 string toXML(bool isPrivate)const; 00189 }; 00190 00207 class CSessionManager:public CAlgorithmCollection 00208 //,public CAlgorithmIDListList 00209 { 00211 CMutex mMutexSessionManager; 00212 protected: 00216 CAccessorAdminCollection mAccessorAdminCollection; 00220 CI18nTranslator mI18nTranslator; 00224 typedef map<string,list<CSession> > CUserToSessions; 00226 typedef map<string,CSession*> CIDToSession; 00228 mutable CUserToSessions mUserToSessions; 00230 mutable CIDToSession mIDToSession; 00235 CPropertySheetList* mPropertySheetList; 00238 CXMLElement* mPropertySheetSubtree; 00241 CStaticQueryFactory* mBaseTypeFactory; 00242 public: 00247 CSessionManager(string inSessions, 00248 string inConfiguration, 00249 string inI18nFileName); 00250 //---------------------------------------- 00255 CQuery* makeQuery(const string& inBaseType, 00256 CAlgorithm& inAlgorithm); 00257 //---------------------------------------- 00260 istream& read(istream&); 00262 ostream& write(ostream&); 00263 //---------------------------------------- 00267 CXMLElement* openSession(string inUserName, 00268 string inSessionID, 00269 string inSessionName); 00270 //---------------------------------------- 00274 CXMLElement* renameSession(string inSessionID, 00275 string inSessionName); 00278 CXMLElement* deleteSession(string inSessionID); 00283 CXMLElement* closeSession(string inSessionID); 00290 CXMLElement* query(const string& inSessionID, 00291 const CXMLElement& inRelevanceLevelList); 00292 //-------------------------------------------------- 00304 CXMLElement* getRandomImages(const string& inSessionID, 00305 const string& inAlgorithm, 00306 int inResultSize); 00307 //-------------------------------------------------- 00309 list<CAccessorElement>* getAllAccessorElements(const string& inSessionID, 00310 const string& inAlgorithm 00311 ); 00312 //-------------------------------------------------- 00314 list<TID>* getAllIDs(const string& inSessionID, 00315 const string& inAlgorithm 00316 ); 00317 //---------------------------------------- 00325 bool setAlgorithm(const string& inSessionID, 00326 CAlgorithm* inAlgorithm); 00328 string newSession(const string& inUser, 00329 const string& inSessionName); 00331 string newSession(const string& inID, 00332 const string& inUser, 00333 const string& inSessionName); 00336 void setSessionName(const string& inOldSessionName, 00337 const string& inNewSessionName); 00338 //---------------------------------------- 00362 //---------------------------------------- 00367 string toXML(bool isPrivate=false)const; 00375 string toXMLSessions(const string& inUser, 00376 bool isPrivate=false)const; 00378 string toXMLSessionConfiguration()const; 00380 pair<string,string> toXMLHandshake(const string& inUser); 00386 CXMLElement* getPropertySheet(string inSessionID, 00387 string inAlgorithmID)const; 00388 //---------------------------------------- 00397 void startPropertySheetSubtree(); 00400 CXMLElement* getPropertySheetSubtree(); 00404 void endPropertySheetSubtree(); 00407 CXMLElement* getCollections()const; 00410 CXMLElement* getAlgorithms()const; 00412 bool clearSessionLanguages(const string& inSessionID); 00414 bool addSessionLanguage(const string& inSessionID, 00415 const string& inLanguageCode); 00417 bool commitSessionLanguages(const string& inSessionID); 00419 list<string> getSessionLanguages(const string& inSessionID)const; 00421 void CSessionManager::translate(string inSessionID, 00422 CXMLElement& inoutToBeTranslated)const; 00423 }; 00424 00425 #endif

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