CQHierarchy Class Reference

#include <CQHierarchy.h>

Inheritance diagram for CQHierarchy:

CQuery CMagic

List of all members.

Public Member Functions

 CQHierarchy ()
 ~CQHierarchy ()
 CQHierarchy (CAccessorAdminCollection &inAccessorAdminCollection, CAlgorithm &inAlgorithm)
virtual CIDRelevanceLevelPairListfastQuery (const CXMLElement &inQuery, int inNumberOfInterestingImages, double inDifferenceToBest)
virtual bool setAlgorithm (CAlgorithm &inAlgorithm)

Protected Member Functions

void init ()

Protected Attributes

list< TIDmCurrentPath


Detailed Description

This is a simple hierarchy based browser.

: Wolfgang Müller

Definition at line 80 of file CQHierarchy.h.


Constructor & Destructor Documentation

CQHierarchy::CQHierarchy (  ) 

default constructor

default constructor SHOULD NOT BE CALLED

Definition at line 44 of file CQHierarchy.cc.

00044                         {
00045   assert(0);
00046 };

CQHierarchy::~CQHierarchy (  ) 

we need to unregister the accessors used

destructor: at present empty

Definition at line 72 of file CQHierarchy.cc.

00072                          {
00073 
00074   cout << "destroying this "
00075        << __FILE__
00076        << __LINE__
00077        << flush
00078        << endl;
00079 
00080   //i thought i will need this, but at present I do not have this impression
00081   //it does not hurt, so we leave it in
00082 };

CQHierarchy::CQHierarchy ( CAccessorAdminCollection inAccessorAdminCollection,
CAlgorithm inAlgorithm 
)

In fact, what we are doing here is to get ourselves an accessor ACURL2FTS to do a proper fastQuery

constructor see CQuery

Definition at line 51 of file CQHierarchy.cc.

References init(), CQuery::mAccessor, CQuery::mAccessorAdmin, and CAccessorAdmin::openAccessor().

00052                                         :
00053   CQuery(inAccessorAdminCollection,
00054    inAlgorithm){
00055   {
00056 
00057     // mproxy has been filled in a reasonable way 
00058     // by CQuery::CQuery
00059     mAccessor=mAccessorAdmin->openAccessor("hierarchy");
00060 
00061     init();
00062 
00063     assert(mAccessor);
00064   }
00065 };
    


Member Function Documentation

void CQHierarchy::init (  )  [protected, virtual]

sets mCurrentPosition to 0

There is no special initialisation to do, so this function is empty

Implements CQuery.

Definition at line 35 of file CQHierarchy.cc.

References mCurrentPath.

Referenced by CQHierarchy().

00035                       {
00036   mCurrentPath.clear();
00037 };

CIDRelevanceLevelPairList * CQHierarchy::fastQuery ( const CXMLElement inQuery,
int  inNumberOfInterestingImages,
double  inDifferenceToBest 
) [virtual]

enables moving in the hierarchy. You can either move down (i.e. you select an image) or up in the hierarchy (by getting a cui-hierarchy-move-up signal as query). RICHLY COMMENTED IN THE *.cc FILE.

Parameters:
inQuery an CXMLElement containing a query-step element
inNumberOfInterestingImages preferred number of result images (ignored)
inDifferenceToBest preferred relevance cutoff (ignored)

Implements CQuery.

Definition at line 107 of file CQHierarchy.cc.

References CXMLElement::child_list_begin(), CXMLElement::child_list_end(), mrml_const::cui_hierarchy_up, mrml_const::image_location, CQuery::mAccessor, mCurrentPath, CAccessor::URLToID(), mrml_const::user_relevance, mrml_const::user_relevance_element, and mrml_const::user_relevance_element_list.

00109                                        {
00110 
00111   CIDRelevanceLevelPairList* lReturnValue(0);
00112 
00113   /*
00114     AS FOR ANY CALL TO FASTQUERY
00115     the inQuery parameter contains a "query-step" element.
00116     
00117     we are interested in children that contain
00118     a "relevance-level-element-list" or a 
00119     "cui-hierarchy-up" element.
00120    */
00121   for(list<CXMLElement*>::const_iterator i=inQuery.child_list_begin();
00122       i!=inQuery.child_list_end();
00123       i++){// iterating over all the children of the inQuery element.
00124 
00125      cout << "I:The name of this tree element: "
00126    << endl
00127    << (*i)->getName()
00128    << endl;
00129      if((*i)->getName()==mrml_const::cui_hierarchy_up){
00130        // this is when a cui-hierarchy-up element was found
00131        if(mCurrentPath.size()){
00132    cout << "MOVING UP ";
00133    copy(mCurrentPath.begin(),
00134         mCurrentPath.end(),
00135         ostream_iterator<TID>(cout,","));
00136    cout << endl;       
00137    mCurrentPath.pop_back();
00138    copy(mCurrentPath.begin(),
00139         mCurrentPath.end(),
00140         ostream_iterator<TID>(cout,","));
00141    return ((CAcHierarchy*)mAccessor)->getChildren(mCurrentPath);
00142        }
00143        return new CIDRelevanceLevelPairList();
00144      }
00145      if((*i)->getName()==mrml_const::user_relevance_element_list){
00146        // if an user-relevance-element-list was found       
00147        for(list<CXMLElement*>::const_iterator j=(*i)->child_list_begin();
00148      j!=(*i)->child_list_end();
00149      j++){//iterate over all the children
00150    cout << "J:The name of this tree element: "
00151         << endl
00152         << (*j)->getName()
00153         << endl;
00154    if((*j)->getName()==mrml_const::user_relevance_element){
00155      // if the current child is a user-relevance-element
00156      if(((*j)->stringReadAttribute(mrml_const::image_location).first)
00157         &&
00158         ((*j)->stringReadAttribute(mrml_const::user_relevance).first)){
00159        // get the image-location and the user-relevance attributes
00160        if((*j)->doubleReadAttribute(mrml_const::user_relevance).second){
00161          //the relevance of this element != 0
00162          if(!lReturnValue){
00163      // if the return value is still undefined
00164      // (i.e. there was no previous element with (user-relevance != 0)
00165      list<TID> lOldCurrentPath=mCurrentPath;
00166      // add this element to the path
00167      mCurrentPath.push_back(mAccessor->URLToID((*j)->stringReadAttribute(mrml_const::image_location).second).second);
00168      
00169      cout << "The new mCurrentPath: ";
00170      copy(mCurrentPath.begin(),
00171           mCurrentPath.end(),
00172           ostream_iterator<TID>(cout,","));
00173      cout << endl;
00174      
00175      // get the children of this node from the accessor
00176      lReturnValue=((CAcHierarchy*)mAccessor)->getChildren(mCurrentPath);
00177      if(lReturnValue){// if there are children:
00178        // return them
00179        return lReturnValue;
00180      }else{
00181        // if not:
00182        // take the old path, get it's children, and return them
00183        mCurrentPath=lOldCurrentPath;
00184        lReturnValue=((CAcHierarchy*)mAccessor)->getChildren(mCurrentPath);
00185        return lReturnValue;
00186      }
00187          }
00188        }
00189      }
00190    }
00191        }
00192      }
00193   }
00194   // if nothing else was found,
00195   // display the first selection:
00196   mCurrentPath.clear();// clear the path
00197   return ((CAcHierarchy*)mAccessor)->getChildren(mCurrentPath);//children of root node
00198 };

bool CQHierarchy::setAlgorithm ( CAlgorithm inAlgorithm  )  [virtual]

set the Algorithm.

Reimplemented from CQuery.

Definition at line 85 of file CQHierarchy.cc.

References CAccessorAdmin::closeAccessor(), CAlgorithm::getCollectionID(), CAccessorAdminCollection::getProxy(), CQuery::mAccessor, CQuery::mAccessorAdmin, CQuery::mAccessorAdminCollection, CQuery::mAlgorithm, CAccessorAdmin::openAccessor(), and CQuery::setAlgorithm().

00085                                                       {
00086   if(mAlgorithm && mAlgorithm->getCollectionID()==inAlgorithm.getCollectionID()){
00087     
00088     return true;
00089     
00090   }else{
00091     //close the old collection, if exsisting
00092     if(mAccessorAdmin)
00093       mAccessorAdmin->closeAccessor("hierarchy");
00094     //
00095     mAccessorAdmin=&mAccessorAdminCollection->getProxy(inAlgorithm.getCollectionID());
00096     mAccessor=mAccessorAdmin->openAccessor("hierarchy");
00097     
00098     assert(mAccessor);
00099     //
00100     return (CQuery::setAlgorithm(inAlgorithm) && mAccessor);
00101   }
00102 };


Member Data Documentation

list<TID> CQHierarchy::mCurrentPath [protected]

The current position in the hierarchy

Definition at line 84 of file CQHierarchy.h.

Referenced by fastQuery(), and init().


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

Generated on Wed Jan 7 00:31:10 2009 for Gift by  doxygen 1.5.6