System documentation of the GNU Image-Finding Tool

CAcIFFileSystem.h
1 /* -*- mode: c++ -*-
2 */
3 /*
4 
5  GIFT, a flexible content based image retrieval system.
6  Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
7 
8  Copyright (C) 2003, 2004 Bayreuth University
9  2005 Bamberg University
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 */
25 // -*- mode: c++ -*-
26 
27 
28 class CXMLElement;
29 
30 /*
31 *
32 *
33 * This class manages the access to the inverted file as well
34 * as its generation
35 *
36 *
37 *
38 * modification history:
39 *
40 * WM 1099 changed documentation format
41 * completed documentation
42 * HM 090399 created the documentation
43 * WM 1098 created the file
44 *
45 *
46 *
47 * compiler defines used:
48 *
49 *
50 */
51 
52 #ifndef _CACIFFILESYSTEM
53 #define _CACIFFILESYSTEM
54 #include "libGIFTAcInvertedFile/include/uses-declarations.h"
55 #include <string>
56 #include "libMRML/include/TID.h"
57 #include "libMRML/include/CSelfDestroyPointer.h"
58 #include "libMRML/include/CArraySelfDestroyPointer.h"
59 #include "libGIFTAcInvertedFile/include/CDocumentFrequencyList.h"
60 #include "libMRML/include/CMutex.h" // multi threading
61 //#include "CCollectionFrequencyList.h"
62 #include "libGIFTAcInvertedFile/include/CADIHash.h"
63 #include "libGIFTAcURL2FTS/include/CAcURL2FTS.h"
64 #include "libGIFTAcInvertedFile/include/CAcInvertedFile.h"
65 #include <iostream>
66 #include <fstream>
67 #include <map>
68 #include <vector>
69 #ifdef HAS_HASH_MAP
70 #include <hash_map>
71 #define HASH_MAP hash_map
72 #else
73 #define HASH_MAP map
74 #endif
75 #include <functional>
76 #include <algorithm>
77 
78 #include "libMRML/include/CMagic.h"
79 
80 
81 typedef TID TFeatureID ;
82 
94 
95 protected:
108 #ifndef V295
110 #else
112 #endif
113 
118 
120  mutable ifstream mOffsetFile;
121 
124 
127 
130 
133 
135  typedef HASH_MAP<TID,streampos> CIDToOffset;//new hash
138 
140  mutable HASH_MAP<TID,double> mFeatureToCollectionFrequency;//new hash
141 
145  HASH_MAP<TID,unsigned int> mFeatureDescription;//new hash_
146 
152 
155  void writeOffsetFileElement(TID inFeatureID,
156  streampos inPosition,
157  ostream& inOpenOffsetFile);
159  CDocumentFrequencyList* getFeatureFile(string inFileName)const;
160 public:
162  bool operator()()const;
163 
190  CAcIFFileSystem(const CXMLElement& inCollectionElement);
192  bool init(bool);
193 
196 
198  string IDToURL(TID inID)const;
199 
203  CDocumentFrequencyList* FeatureToList(TFeatureID)const;
204 
206  CDocumentFrequencyList* URLToFeatureList(string inURL)const;
207 
209  CDocumentFrequencyList* DIDToFeatureList(TID inDID)const;
210 
212 
213 
217  double FeatureToCollectionFrequency(TFeatureID)const;
218 
220  unsigned int getFeatureDescription(TID inFeatureID)const;
222 
226  double DIDToMaxDocumentFrequency(TID)const;
227 
229  double DIDToDFSquareSum(TID)const;
230 
232  double DIDToSquareDFLogICFSum(TID)const;
234 
235  /*@name Inverted File Generation and Consistency Checking*/
237 
245  bool generateInvertedFile();
246 
255 
258  bool checkConsistency();
259 
266  bool findWithinStream(TID inFeatureID,
267  TID inDocumentID,
268  double inDocumentFrequency)const;
269 
271 
277  virtual pair<bool,TID> URLToID(const string& inURL)const;
278 
280  void getAllIDs(list<TID>&)const;
283  void getAllAccessorElements(list<CAccessorElement>&)const;
288  void getRandomIDs(list<TID>&,
289  list<TID>::size_type)const;
298  void getRandomAccessorElements(list<CAccessorElement>& outResult,
299  list<CAccessorElement>::size_type inSize)const;
301  int size()const;
303 
304  TID getMaximumFeatureID()const;
312  list<TID>* getAllFeatureIDs()const;
318  virtual pair<bool,CAccessorElement> IDToAccessorElement(TID inID)const;
320  operator bool()const;
321 
322 };
323 
324 #endif

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