System documentation of the GNU Image-Finding Tool

Public Member Functions | Protected Types | Protected Attributes | List of all members
CSessionManager Class Reference

This structure handles the sessions; by this, it encapsulates the current state of the server. More...

#include <CSessionManager.h>

Inheritance diagram for CSessionManager:
CAlgorithmCollection CStaticQueryFactory

Public Member Functions

 CSessionManager (string inSessions, string inConfiguration, string inI18nFileName)
 The session manager slurps in two XML files and generates out of this its initial state.
 
CQuerymakeQuery (const string &inBaseType, CAlgorithm &inAlgorithm)
 this CSessionManager has all the information to make a query structure.
 
istream & read (istream &)
 Initialization: read from a stream.
 
ostream & write (ostream &)
 Write into a stream.
 
CXMLElementopenSession (string inUserName, string inSessionID, string inSessionName)
 to be used by the Interface. More...
 
CXMLElementrenameSession (string inSessionID, string inSessionName)
 to be used by the Interface. More...
 
CXMLElementdeleteSession (string inSessionID)
 to be used by the Interface. More...
 
CXMLElementcloseSession (string inSessionID)
 Closes the session, but keeps it in memory. More...
 
CXMLElementquery (const string &inSessionID, const CXMLElement &inRelevanceLevelList)
 VeryImportantFunction: More...
 
CXMLElementgetRandomImages (const string &inSessionID, const string &inAlgorithm, int inResultSize)
 retrieving random images (as seeds for subsequent searches) More...
 
list< CAccessorElement > * getAllAccessorElements (const string &inSessionID, const string &inAlgorithm)
 retrieving the URLs of all images (for generating distance matrices)
 
list< TID > * getAllIDs (const string &inSessionID, const string &inAlgorithm)
 retrieving the IDs of all images (for generating distance matrices)
 
bool setAlgorithm (const string &inSessionID, CAlgorithm *inAlgorithm)
 set the algorithm used in this session it will also lead to a new construction of the query. More...
 
string newSession (const string &inUser, const string &inSessionName)
 making a new session and returning its ID
 
string newSession (const string &inID, const string &inUser, const string &inSessionName)
 making a new session and for a given ID, returnig the ID
 
void setSessionName (const string &inOldSessionName, const string &inNewSessionName)
 Set the name of the current session. More...
 
string toXML (bool isPrivate=false) const
 turn this into a part of the welcome message in fact, this generates standard property sheets out of the collections and algorithms available More...
 
string toXMLSessions (const string &inUser, bool isPrivate=false) const
 The sessions for one user only. More...
 
string toXMLSessionConfiguration () const
 The sessions for everybody known to the system.
 
pair< string, string > toXMLHandshake (const string &inUser)
 this is almost the complete shandshake message
 
CXMLElementgetPropertySheet (string inSessionID, string inAlgorithmID) const
 Get the property sheet of the algorithm with ID inAlgorithmID. More...
 
void startPropertySheetSubtree ()
 Building a property sheet list I consider building a list on a call by call basis as tedious. More...
 
CXMLElementgetPropertySheetSubtree ()
 This function gets us the current property sheet subtree.
 
void endPropertySheetSubtree ()
 This function does the actual breaking down into a CPropertySheetList.
 
CXMLElementgetCollections () const
 This function probably will quite soon be removed from this class, and it will become part of a class containing the CSessionManager.
 
CXMLElementgetAlgorithms () const
 This function probably will quite soon be removed from this class, and it will become part of a class containing the CSessionManager.
 
bool clearSessionLanguages (const string &inSessionID)
 i18n clear the preferred languages list of a given session
 
bool addSessionLanguage (const string &inSessionID, const string &inLanguageCode)
 i18n: add one language code to the list of preferred languages
 
bool commitSessionLanguages (const string &inSessionID)
 commit the languages to be used for a session. More...
 
list< string > getSessionLanguages (const string &inSessionID) const
 i18n: get the list of preferred languages of this session
 
void translate (string inSessionID, CXMLElement &inoutToBeTranslated) const
 i18n: get the list of preferred languages of this session
 
- Public Member Functions inherited from CAlgorithmCollection
CAlgorithmgetAlgorithmInConstruction ()
 returns a pointer to the algorithm in construction
 
void startAlgorithmConstruction (CAlgorithm *inAlgorithm)
 
 CAlgorithmCollection (string inConfigFileName)
 Constructor.
 
 ~CAlgorithmCollection ()
 Destructor destroys all members of CContent.
 
void addAlgorithm (CAlgorithm *inAlgorithm)
 adding a completely built algorithm XML document tree
 
CAlgorithmgetAlgorithmByType (const string &inType) const
 Algorithm for TYPE => permits configuring probably only the pointered version is interesting.
 
bool containsAlgorithmByType (const string &inType) const
 Algorithm for TYPE => permits configuring probably only the pointered version is interesting.
 
CAlgorithmmakeAlgorithmByType (const string &inType) const
 Creates a new algorithm for agiven type by cloning what you would get with getAlgorithm. More...
 
CAlgorithmgetDefaultAlgorithm () const
 A default algorithm for the default session This algorithm will be given by the ONE ALGORITHM which has the type "adefault".
 
CAlgorithmmakeDefaultAlgorithm () const
 creates a copy of what you'd get with the above function get... More...
 
CXMLElementgetAlgorithmList (const CXMLElement &inGetAlgorithms) const
 For handshaking: This makes you a list of all algorithms which work with a given query paradigm.
 
string toXML (bool inIsPrivate=false) const
 for shandshake and for state output
 
CXMLElementtoXMLElement () const
 for get-algorithms: the output is an CXMLElement, containing an algorithm-list element.
 
CQuerymakeQuery (const string &inBaseType, CAccessorAdminCollection &inAccessorAdminCollection, CAlgorithm &inAlgorithm, CStaticQueryFactory &inFactory)
 handed through to the CStaticQueryFactory
 
- Public Member Functions inherited from CStaticQueryFactory
virtual CQuerymakeQuery (const string &inBaseType, CAccessorAdminCollection &inAccessorAdminCollection, CAlgorithm &inAlgorithm)
 generates a new CQuery for a given basetype. More...
 

Protected Types

typedef map< string, list
< CSession > > 
CUserToSessions
 point the user to all the sessions
 
typedef map< string, CSession * > CIDToSession
 
- Protected Types inherited from CAlgorithmCollection
typedef map< string, CAlgorithm * > CContent
 The content of an algorithm collection is a map between algorihm type and a pointer to the corresponding CAlgorithm.
 

Protected Attributes

CAccessorAdminCollection mAccessorAdminCollection
 The accessor collection is needed for constructing queries.
 
CI18nTranslator mI18nTranslator
 The Translator for this.
 
CUserToSessions mUserToSessions
 
CIDToSession mIDToSession
 
CPropertySheetListmPropertySheetList
 These are the building blocks of the property sheets to be generated by *this.
 
CXMLElementmPropertySheetSubtree
 The subtree from which the mPropertySheets will be built.
 
CStaticQueryFactorymBaseTypeFactory
 The base type factory is a factory for query base types.
 
- Protected Attributes inherited from CAlgorithmCollection
CAlgorithmmAlgorithmInConstruction
 as the name sais
 
CContent mContent
 

Additional Inherited Members

- Protected Member Functions inherited from CAlgorithmCollection
CContent::const_iterator begin () const
 for being able to read all the content
 
CContent::const_iterator end () const
 for being able to read all the content
 

Detailed Description

This structure handles the sessions; by this, it encapsulates the current state of the server.

Basically, it hands all requests through to the right sessions. It also handles the generation of new sessions etc.. In short, it is the configuration manager.

This class is now approaching what I would like it to be, however, cleaning is always wellcome

ATTENTION MULTITHREADING: WHAT TO LOCK AND WHAT TO UNLOCK IS NOT ENTIRELY TRIVIAL THIS MIGHT BE A SOURCE OF MISTAKES

Member Function Documentation

CXMLElement* CSessionManager::closeSession ( string  inSessionID)

Closes the session, but keeps it in memory.

FUTURE: put the state of the session into a blob

bool CSessionManager::commitSessionLanguages ( const string &  inSessionID)

commit the languages to be used for a session.

CXMLElement* CSessionManager::deleteSession ( string  inSessionID)

to be used by the Interface.

Not yet implemented.

CXMLElement* CSessionManager::getPropertySheet ( string  inSessionID,
string  inAlgorithmID 
) const

Get the property sheet of the algorithm with ID inAlgorithmID.

We look for the attribute cui-property-sheet-id in the algorithm. If this exsists, we look for the right property sheet id in the CPropertySheetList.

CXMLElement* CSessionManager::getRandomImages ( const string &  inSessionID,
const string &  inAlgorithm,
int  inResultSize 
)

retrieving random images (as seeds for subsequent searches)

Parameters
inSessionIDThe ID of the session in which the request was issued.
inAlgorithmOne would think this is not needed when retrieving random images. However, it is useful to know the collection involved, and if the random images we are retrieving will fit the algorithm used later.
inCollectionThe collection from which random images will be retrieved.
CXMLElement* CSessionManager::openSession ( string  inUserName,
string  inSessionID,
string  inSessionName 
)

to be used by the Interface.

Not yet implemented.

CXMLElement* CSessionManager::query ( const string &  inSessionID,
const CXMLElement inRelevanceLevelList 
)

VeryImportantFunction:

This function looks for a CSession with CSession::mSessionID==inSessionID and hands through the rest of the parameter list to CSession::query.

CXMLElement* CSessionManager::renameSession ( string  inSessionID,
string  inSessionName 
)

to be used by the Interface.

Not yet implemented.

bool CSessionManager::setAlgorithm ( const string &  inSessionID,
CAlgorithm inAlgorithm 
)

set the algorithm used in this session it will also lead to a new construction of the query.

We have to perform some comparisons here present version is probably a HACK

void CSessionManager::setSessionName ( const string &  inOldSessionName,
const string &  inNewSessionName 
)

Set the name of the current session.

Presently not implemented or tested

void CSessionManager::startPropertySheetSubtree ( )

Building a property sheet list I consider building a list on a call by call basis as tedious.

So what I do is: I first build a tree, and then I break down this tree into our list.

This function makes a new tree

string CSessionManager::toXML ( bool  isPrivate = false) const

turn this into a part of the welcome message in fact, this generates standard property sheets out of the collections and algorithms available

It means:

  1. Make out of each algorithm in the collection a property sheet.
  2. Make out of the algorithm-id-list-list a property sheet with a parent node which does not send messages.
  3. Make out of the collection list a choice of collections, each having as a child a property sheet out of 2.

If we do things this way we are losing a bit of the flexibility given in the property sheet specification. However, for the moment I (WM) consider this loss nost as big compared to what we earn in terms of configuration of the system. If necessary recode.

string convertPropertyToXML(bool isPrivate=false)const;

THIS IS DEPRECATED STUFF, SO IT'S DELETED NOW!turn this into a part of the welcome message

THIS CODE IS TO LEAVE SOON

string CSessionManager::toXMLSessions ( const string &  inUser,
bool  isPrivate = false 
) const

The sessions for one user only.

Parameters
inUserthe name of the user for which we want the session names.
isPrivatesend internal configuration information along? (distinction between messages for internet and config files)

The documentation for this class was generated from the following file:

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