System documentation of the GNU Image-Finding Tool

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CAcIFMySQL.h

00001 /* -*- mode: c++ -*- 
00002 */
00003 #ifdef __GIFT_WITH_MYSQL__
00004 /* 
00005 
00006     GIFT, a flexible content based image retrieval system.
00007     Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023 */
00024 // -*- mode: c++ -*-
00025 
00026 
00027 class CXMLElement;
00028 
00048 #ifndef _CACIFMYSQL
00049 #define _CACIFMYSQL
00050 #include "libGIFTAcInvertedFile/include/uses-declarations.h"
00051 class CXMLElement;
00052 
00053 #include "libGIFTAcInvertedFile/include/CAcInvertedFile.h"
00054 #include "libGIFTAcURL2FTS/include/CAcURL2FTS.h"
00055 #include <string>
00056 #include "libMRML/include/TID.h"
00057 #include "libMRML/include/CSelfDestroyPointer.h"
00058 #include "libMRML/include/CArraySelfDestroyPointer.h"
00059 #include "libGIFTAcInvertedFile/include/CDocumentFrequencyList.h"
00060 
00061 #include "libGIFTAcInvertedFile/include/CADIHash.h"
00062 #include <iostream>
00063 #include <fstream>
00064 #include <map>
00065 #include <vector>
00066 #ifdef HAS_HASH_MAP
00067 #include <hash_map>
00068 #else
00069 #define hash_map map
00070 #endif
00071 #include <functional>
00072 #include <algorithm>
00073 
00074 #include <sqlplus.hh>
00075 #include <custom.hh>
00076 #include "libMRML/include/CMagic.h"
00077 
00078 
00079 typedef TID TFeatureID ;
00080 
00088 class documentFeatureConnection;
00089 
00090 class CAcIFMySQL:public CAccessor{  
00096   CSelfDestroyPointer<CAcURL2FTS> mURL2FTS;
00098   documentFeatureConnection* mConnection;
00099 
00100   string GdbName;
00101   string GdbUser;
00102   string GdbHost;
00103   string GdbPassword;
00104 
00105   bool connection2dbOK;
00106 
00107   Connection *cnx;
00108 
00110   //vector <documentFeatureConnection> queryReturn;
00112   vector <documentFeatureConnection>::iterator It;
00114   CDocumentFrequencyList* featureList2docList(CDocumentFrequencyList inFeatureList);
00116   void showDocFreqList(CDocumentFrequencyList docFreqList);
00117   /* neither this */
00118   CDocumentFrequencyList* blob2docFreqList(string inBlobFile)const;
00119 
00120 protected:
00121   int CAcIFMySQL::recordCount(string ltableName)const;
00122   bool CAcIFMySQL::selectDB( string);
00123   bool CAcIFMySQL::createDB( string);
00124   bool CAcIFMySQL::dropDB( string);
00125   void CAcIFMySQL::initialiseGIFTTables(bool, bool,string);
00126 
00127 
00128 public:
00130   virtual bool operator()()const;
00131 
00146   CAcIFMySQL(const CXMLElement& inCollectionElement);
00148   ~CAcIFMySQL();
00149 
00153   virtual string IDToURL(TID inID)const;
00154 
00156   virtual pair<bool,TID> URLToID(const string& inURL)const;
00157   
00174   virtual CDocumentFrequencyList* FeatureToList(TFeatureID inFID)const;
00175 
00177   virtual CDocumentFrequencyList* URLToFeatureList(string inURL)const;
00178 
00180   virtual CDocumentFrequencyList* DIDToFeatureList(TID inDID)const;
00181 
00194 
00195 
00199   virtual double FeatureToCollectionFrequency(TFeatureID)const;
00200 
00202   virtual unsigned int getFeatureDescription(TID inFeatureID)const;
00204 
00208   virtual double DIDToMaxDocumentFrequency(TID)const;
00209 
00211   virtual double DIDToDFSquareSum(TID)const;
00212 
00214   virtual double DIDToSquareDFLogICFSum(TID)const;
00216 
00217   /*@name Inverted File Generation and Consistency Checking*/
00219 
00226 
00234   void CAcIFMySQL::getAllIDs( list<TID > &) const;
00235   void CAcIFMySQL::getAllAccessorElements( list<CAccessorElement> &) const;
00236   void CAcIFMySQL::getRandomIDs(list<TID > &, size_t) const;
00237   void CAcIFMySQL::getRandomAccessorElements(list<CAccessorElement > &, size_t) const;
00238   virtual list<TID>* getAllFeatureIDs()const;
00244   virtual pair<bool,CAccessorElement> IDToAccessorElement(TID inID)const;
00245 
00246   int CAcIFMySQL::size() const;
00247   CAcIFMySQL::operator bool()const;
00248 
00249 };
00250 
00251 
00252 #endif
00253 #endif

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