CAccessorImplementation Class Reference

#include <CAccessorImplementation.h>

Inheritance diagram for CAccessorImplementation:

CAccessor CAcHierarchy CAcURL2FTS CAcDistanceMatrix CAcInvertedFile CAcIFFileSystem CAcIFMeta

List of all members.

Public Member Functions

virtual operator bool () const =0
virtual string IDToURL (TID inID) const
virtual pair< bool,
CAccessorElement
IDToAccessorElement (TID inID) const
virtual pair< bool, TIDURLToID (const string &inURL) const
void getAllIDs (list< TID > &) const
void getAllAccessorElements (list< CAccessorElement > &) const
void getRandomIDs (list< TID > &, list< TID >::size_type) const
void getRandomAccessorElements (list< CAccessorElement > &outResult, list< CAccessorElement >::size_type inSize) const
int size () const

Protected Attributes

for fast access...
string_TID_map mURLToID
TID_CAccessorElement_map mIDToAccessorElement


Detailed Description

CAccessorImplementation - a base class for everything accessing a GIFT database. at present this will be either an inverted file or a TrackingGIFT accessor. in the future this might be an SQL database or Monet??

modification history:

WM 19990804 created file

compiler defines used:

Definition at line 92 of file CAccessorImplementation.h.


Member Function Documentation

virtual CAccessorImplementation::operator bool (  )  const [pure virtual]

Is this accessor up and working?

Implements CAccessor.

Implemented in CAcHierarchy, CAcIFFileSystem, CAcIFMeta, and CAcURL2FTS.

string CAccessorImplementation::IDToURL ( TID  inID  )  const [virtual]

Translate a DocumentID to a URL (for output)

Implements CAccessor.

Reimplemented in CAcIFFileSystem, CAcIFMeta, CAcInvertedFile, and CAcInvertedFile.

Definition at line 273 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

00274 {
00275 
00276   TID_CAccessorElement_map::const_iterator lI=mIDToAccessorElement.find(inID);
00277   
00278   if(lI!=mIDToAccessorElement.end())
00279     {
00280       return (*lI).second.getURL();
00281     }
00282   else
00283     {
00284       cerr << "Error in Conversion from ID "
00285      << inID 
00286      << " to URL."
00287      << endl;
00288       return "error";
00289     }
00290 }

pair< bool, CAccessorElement > CAccessorImplementation::IDToAccessorElement ( TID  inID  )  const [virtual]

Translate a DocumentID to an accessor Element

Implements CAccessor.

Reimplemented in CAcIFFileSystem, and CAcIFMeta.

Definition at line 239 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

00240 {
00241 
00242   TID_CAccessorElement_map::const_iterator lI=mIDToAccessorElement.find(inID);
00243   
00244   if(lI!=mIDToAccessorElement.end())
00245     {
00246       return make_pair(true,(*lI).second);
00247     }
00248   else
00249     {
00250       cerr << "Error in Conversion from ID "
00251      << inID 
00252      << " to AccessorElement."
00253      << endl;
00254       return make_pair(false,CAccessorElement(-1,
00255                 "error",
00256                 "error",
00257                 "error"));
00258     }
00259 }

pair< bool, TID > CAccessorImplementation::URLToID ( const string &  inURL  )  const [virtual]

Translate an URL to its document ID

Implements CAccessor.

Reimplemented in CAcIFFileSystem, CAcIFMeta, CAcInvertedFile, and CAcInvertedFile.

Definition at line 305 of file CAccessorImplementation.cc.

References mURLToID.

00306 {
00307 
00308   string_TID_map::const_iterator lI=mURLToID.find(inURL);
00309   
00310   if(lI!=mURLToID.end())
00311     {
00312       return make_pair<bool,TID>(true,(*lI).second);
00313     }
00314   else
00315     {
00316       cerr << "Error in Conversion from URL "
00317      << inURL 
00318      << " to ID."
00319      << endl;
00320       return make_pair<bool,TID>(false,-1);
00321     }
00322 }

void CAccessorImplementation::getAllIDs ( list< TID > &  outReturnList  )  const [virtual]

This is useful for making lists of which images are present in a database etc. List of the IDs of all documents present in the accessor file

Implements CAccessor.

Reimplemented in CAcIFFileSystem, and CAcIFMeta.

Definition at line 77 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

00077                                                                     {
00078   
00079   for(TID_CAccessorElement_map::const_iterator i=mIDToAccessorElement.begin();
00080       i!=mIDToAccessorElement.end();
00081       i++){
00082     outReturnList.push_back(i->first);
00083   }
00084 }

void CAccessorImplementation::getAllAccessorElements ( list< CAccessorElement > &  outReturnList  )  const [virtual]

List of triplets (ID,imageURL,thumbnailURL) of all the documents present in the inverted file

Implements CAccessor.

Reimplemented in CAcIFFileSystem, and CAcIFMeta.

Definition at line 97 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

Referenced by generateDistanceMatrix().

00097                                                                                               {
00098   
00099   for(TID_CAccessorElement_map::const_iterator i=mIDToAccessorElement.begin();
00100       i!=mIDToAccessorElement.end();
00101       i++){
00102     outReturnList.push_back(i->second);
00103   }
00104 }

void CAccessorImplementation::getRandomIDs ( list< TID > &  outReturnList,
list< TID >::size_type  inRequestedSize 
) const [virtual]

get a given number of random AccessorElement's

Parameters:
inoutResultList the list which will contain the result
inSize the desired size of the inoutResultList

Implements CAccessor.

Reimplemented in CAcIFFileSystem, and CAcIFMeta.

Definition at line 117 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

00118                                                    {
00119   
00120   const list<TID>::size_type lModulo=mIDToAccessorElement.size();
00121   
00122   inRequestedSize=min(lModulo,
00123           inRequestedSize);
00124   
00125   set<list<TID>::size_type> lPositions;
00126   
00128   for(int i=0;
00129       i<inRequestedSize;
00130       i++){
00131     lPositions.insert(rand()%lModulo);
00132   }
00133   while(lPositions.size()<inRequestedSize){
00134     lPositions.insert(rand()%lModulo);
00135   }
00136 
00137   cout << "Size of the drawn set" 
00138        << lPositions.size()
00139        << endl;
00140 
00142   TID_CAccessorElement_map::const_iterator lCurrentID=mIDToAccessorElement.begin();
00144   TID_CAccessorElement_map::size_type lCurrentPosition=0;
00146   for(set<list<TID>::size_type>::const_iterator i=lPositions.begin();
00147       i!=lPositions.end();
00148       i++){
00149     for(;
00150   lCurrentPosition<*i;
00151   lCurrentPosition++){
00152       lCurrentID++;
00153     }
00154     outReturnList.push_back(lCurrentID->first);
00155   }
00156 }

void CAccessorImplementation::getRandomAccessorElements ( list< CAccessorElement > &  outResult,
list< CAccessorElement >::size_type  inSize 
) const [virtual]

For drawing random sets. Why is this part of an CAccessorImplementation? The way the accessor is organised might influence the way random sets can be drawn. At present everything happens in RAM, but we do not want to be fixed on that.

Parameters:
inoutResultList the list which will contain the result
inSize the desired size of the inoutResultList

Implements CAccessor.

Reimplemented in CAcIFFileSystem, and CAcIFMeta.

Definition at line 170 of file CAccessorImplementation.cc.

References mIDToAccessorElement.

00171                                                                  {
00172 
00173   if(!inRequestedSize){
00174     return;
00175   }
00176 
00177   outReturnList.clear();
00178 
00179   const list<CAccessorElement>::size_type lModulo=mIDToAccessorElement.size();
00180 
00181   inRequestedSize=min(lModulo,
00182           inRequestedSize);
00183   
00184   set<list<CAccessorElement>::size_type> lPositions;
00185   
00187   for(int i=0;
00188       i<inRequestedSize;
00189       i++){
00190     lPositions.insert(rand()%lModulo);
00191   }
00192 
00193   while(lPositions.size()<inRequestedSize){
00194     lPositions.insert(rand()%lModulo);
00195   }
00196   
00197   cout << "Size of the drawn set" 
00198        << lPositions.size()
00199        << ","
00200        << inRequestedSize
00201        << endl;
00203   list<CAccessorElement>::size_type lCurrentPosition(0);
00205   TID_CAccessorElement_map::const_iterator lCurrentID=mIDToAccessorElement.begin();
00207   for(set<list<CAccessorElement>::size_type>::const_iterator i=lPositions.begin();
00208       i!=lPositions.end();
00209       i++){
00210 //     cout << "Before lCurrentID" 
00211 //   << lCurrentID->first
00212 //   << endl;
00213     for(/* keep lCurrentPosition */;
00214   lCurrentPosition<*i;
00215   lCurrentPosition++){
00216       lCurrentID++;
00217     }
00218 //     cout << "lCurrentID" 
00219 //   << lCurrentID->first
00220 //   << endl;
00221 
00222     outReturnList.push_back(lCurrentID->second);
00223   }
00224   //  cout << "still ariving here " << endl;
00225 }

int CAccessorImplementation::size (  )  const [virtual]

The number of images in this accessor

Implements CAccessor.

Reimplemented in CAcIFFileSystem, CAcIFMeta, and CAcURL2FTS.

Definition at line 335 of file CAccessorImplementation.cc.

References mURLToID.

00336 {
00337   return mURLToID.size();
00338 }


Member Data Documentation

map the url of an image to the id of this image

Definition at line 99 of file CAccessorImplementation.h.

Referenced by CAcHierarchy::addElement(), CAcURL2FTS::addImage(), CAcIFFileSystem::CAcIFFileSystem(), CAcURL2FTS::CAcURL2FTS(), size(), and URLToID().


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

Generated on Tue Jan 6 00:31:03 2009 for Gift by  doxygen 1.5.6