System documentation of the GNU Image-Finding Tool

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      Copyright (C) 2003, 2004 Bayreuth University
00009       2005 Bamberg University
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 
00024 */
00025 // -*- mode: c++ -*-
00026 #ifndef _CSESSIONMANAGER
00027 #define _CSESSIONMANAGER
00028 #include "libMRML/include/uses-declarations.h"
00029 #include <iostream>
00030 #include <string>
00031 #include <list>
00032 #include <map>
00033 #include "libMRML/include/CXMLElement.h"
00034 #include "libMRML/include/CAccessorAdminCollection.h"
00035 #include "libMRML/include/CI18nTranslator.h"
00036 #include "libMRML/include/CAlgorithm.h"
00037 #include "libMRML/include/CPropertySheetList.h"
00038 #include "libMRML/include/CAccessorElement.h"
00039 #include "libMRML/include/CAlgorithmCollection.h"
00040 #include "libMRML/include/CQueryTreeBuilder.h"
00041 #include "libMRML/include/CMutex.h" // multithreading
00042 class CStaticQueryFactory;
00043 class CAlgorithm;
00044 class CSessionManager;
00045 class CQueryTreeNode;
00046 class CStaticQueryFactory;
00063 class CSession{
00064 protected:
00066   string mPreferredLanguage;
00068   typedef list<string> CLanguageList;
00070   CLanguageList mLanguages;
00072   CMutex mMutexSession;
00074   bool mIsOpen;
00076   string mUser;
00078   string mID;
00082   string mSessionName;
00086   CAlgorithm* mActiveAlgorithm;
00088   pair<CQueryContainer*,CQueryTreeNode*> mQueryTree;
00090   static CQueryTreeBuilder mQueryTreeBuilder;
00091 public:
00092   //--------------------------------------------------
00094   CSession();
00097   CSession(string inUser,
00098            string inID,
00099            string inSessionName,
00100            CAlgorithm* inActiveAlgorithm
00101            );
00105   ~CSession();
00106   //--------------------------------------------------
00108   ostream& write(ostream& outStream)const;
00110   istream& read(istream& inStream);
00111   //--------------------------------------------------
00113   string getUser()const;
00115   void setUser(const string& inUser);
00117   string getID()const;
00119   void setID(const string& inID);
00121   string getSessionName()const;
00123   void setSessionName(const string& inSessionName);
00125   CAlgorithm* getActiveAlgorithm();
00134   bool setActiveAlgorithm(CAccessorAdminCollection& inCaller,
00135                           CAlgorithmCollection& inAlgorithmCollection,
00136                           CAlgorithm* inActiveAlgorithm,
00137                           CStaticQueryFactory& inBaseTypeFactory);
00139   //string  getActiveCollection()const;
00141   //  void setActiveCollection(const string& inCollection);
00142   //--------------------------------------------------
00149   CXMLElement* query(CSessionManager&     inCaller,
00150                      const CXMLElement& inQuery);
00151   //--------------------------------------------------
00153   CXMLElement* getRandomImages(CSessionManager& inCaller,
00154                                        const string& inAlgorithm,
00155                                        int inResultSize);
00156   
00157   //--------------------------------------------------
00163   bool open();
00164   //--------------------------------------------------
00167   bool close();
00168   //--------------------------------------------------
00172   bool rename(const string& inName);
00175   void CSession::clearLanguages();
00178   void CSession::addLanguage(string inLanguageCode);
00182   void CSession::commitLanguages(const CI18nTranslator& inTranslator);
00184   list<string> CSession::getLanguages()const;
00186   string CSession::getPreferredLanguage()const;
00187 
00188   //--------------------------------------------------
00190   string toXML(bool isPrivate)const;
00191 };
00192 
00209 class CSessionManager:public CAlgorithmCollection
00210                       //,public CAlgorithmIDListList
00211 {
00213   CMutex mMutexSessionManager;
00214 protected:
00218   CAccessorAdminCollection mAccessorAdminCollection;
00222   CI18nTranslator mI18nTranslator;
00226   typedef map<string,list<CSession> >   CUserToSessions;
00228   typedef map<string,CSession*>         CIDToSession;
00230   mutable CUserToSessions mUserToSessions;
00232   mutable CIDToSession    mIDToSession;
00237   CPropertySheetList* mPropertySheetList;
00240   CXMLElement* mPropertySheetSubtree;
00243   CStaticQueryFactory* mBaseTypeFactory;
00244 public:
00249   CSessionManager(string inSessions,
00250                   string inConfiguration,
00251                   string inI18nFileName);
00252   //----------------------------------------
00257   CQuery* makeQuery(const string& inBaseType,
00258                     CAlgorithm& inAlgorithm);
00259   //----------------------------------------
00262   istream& read(istream&);
00264   ostream& write(ostream&);
00265   //----------------------------------------
00269   CXMLElement* openSession(string inUserName,
00270                            string inSessionID,
00271                            string inSessionName);
00272   //----------------------------------------
00276   CXMLElement* renameSession(string inSessionID,
00277                              string inSessionName);
00280   CXMLElement* deleteSession(string inSessionID);
00285   CXMLElement* closeSession(string inSessionID);
00292   CXMLElement* query(const string& inSessionID,
00293                      const CXMLElement& inRelevanceLevelList);
00294   //--------------------------------------------------
00306   CXMLElement* getRandomImages(const string& inSessionID,
00307                                const string& inAlgorithm,
00308                                int inResultSize);
00309   //--------------------------------------------------
00311   list<CAccessorElement>* getAllAccessorElements(const string& inSessionID,
00312                                                  const string& inAlgorithm
00313                                                  );
00314   //--------------------------------------------------
00316   list<TID>* getAllIDs(const string& inSessionID,
00317                        const string& inAlgorithm
00318                        );
00319   //----------------------------------------
00327   bool setAlgorithm(const string& inSessionID,
00328                     CAlgorithm* inAlgorithm);
00330   string newSession(const string& inUser,
00331                     const string& inSessionName);
00333   string newSession(const string& inID,
00334                     const string& inUser,
00335                     const string& inSessionName);
00338   void setSessionName(const string& inOldSessionName,
00339                       const string& inNewSessionName);
00340   //----------------------------------------
00364   //----------------------------------------
00369   string toXML(bool isPrivate=false)const;
00377   string toXMLSessions(const string& inUser,
00378                        bool isPrivate=false)const;
00380   string toXMLSessionConfiguration()const;
00382   pair<string,string> toXMLHandshake(const string& inUser);
00388   CXMLElement* getPropertySheet(string inSessionID,
00389                                 string inAlgorithmID)const;
00390   //----------------------------------------
00399   void startPropertySheetSubtree();
00402   CXMLElement* getPropertySheetSubtree();
00406   void endPropertySheetSubtree();
00409   CXMLElement* getCollections()const;
00412   CXMLElement* getAlgorithms()const;
00414   bool clearSessionLanguages(const string& inSessionID);
00416   bool addSessionLanguage(const string& inSessionID,
00417                           const string& inLanguageCode);
00419   bool commitSessionLanguages(const string& inSessionID);
00421   list<string> getSessionLanguages(const string& inSessionID)const;
00423   void CSessionManager::translate(string inSessionID,
00424                                   CXMLElement& inoutToBeTranslated)const;
00425 };
00426 
00427 #endif

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