SearcherSQLite.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SEARCHERSQLITE_H_
00025 #define SEARCHERSQLITE_H_
00026
00027 #include <spectrallines/Splatalogue/Searcher.h>
00028 #include <spectrallines/Splatalogue/SplatResult.h>
00029
00030 class sqlite3;
00031 class sqlite3_stmt;
00032
00033 using namespace std;
00034
00035 namespace casa {
00041 class SearcherSQLite : public Searcher{
00042 public:
00043 SearcherSQLite( const string& databasePath);
00044
00049 string tableInfo( const string& tableName, string& errorMsg ) const;
00050
00054 string getCreatedDate() const;
00055 virtual bool isConnected() const;
00056 virtual void stopSearch();
00057
00058
00059 virtual void reset();
00060
00061
00062 virtual void setChemicalNames( const vector<string>& chemNames );
00063 virtual void setSpeciesNames( const vector<string>& speciesNames );
00067 virtual void setFrequencyRange( double minValue, double maxValue );
00068 virtual void setIntensityRange( double minValue, double maxValue );
00069 virtual void setSmu2Range( double minValue, double maxValue );
00070 virtual void setLogaRange( double minValue, double maxValue );
00071 virtual void setElRange( double minValue, double maxValue );
00072 virtual void setEuRange( double minValue, double maxValue );
00073 virtual void setQNS( const vector<string>& qns );
00074
00075
00076
00077 virtual void setFilterTop20( bool filter = true );
00078 virtual void setFilterPlanetaryAtmosphere( bool filter = true );
00079 virtual void setFilterHotCores( bool filter = true );
00080 virtual void setFilterDarkClouds( bool filter = true );
00081 virtual void setFilterDiffuseClouds( bool filter = true );
00082 virtual void setFilterComets( bool filter = true );
00083 virtual void setFilterAgbPpnPn( bool filter = true );
00084 virtual void setFilterExtragalactic( bool filter = true );
00085
00086
00094 virtual vector<SplatResult> doSearch( string& errorMsg, int offset );
00095 virtual long doSearchCount( string& errorMsg );
00102 virtual void setSearchResultLimit( int limit );
00103 virtual ~SearcherSQLite();
00104
00105 private:
00106 bool executeQuery( sqlite3_stmt*& statement, const string& query,
00107 string& errorMsg ) const;
00108
00109
00110
00111
00112
00113
00114
00115
00116 string prepareQuery( bool countOnly, int offset ) const;
00117 std::string getTrue() const;
00118 string numToString( double number ) const;
00119 string getBetweenClause( const string& columnName, double low, double high) const;
00120 string getInClause( const string& columnName, const vector<string>& values ) const;
00121 string getLikeClause( const string& columnName, const vector<string>& values ) const;
00122
00123
00124 sqlite3* db;
00125
00126
00127 double minValueFreq;
00128 double maxValueFreq;
00129 double minValueIntensity;
00130 double maxValueIntensity;
00131 double minValueSmu2;
00132 double maxValueSmu2;
00133 double minValueLoga;
00134 double maxValueLoga;
00135 double minValueEl;
00136 double maxValueEl;
00137 double minValueEu;
00138 double maxValueEu;
00139 bool recommendedOnly;
00140 vector<string> speciesNames;
00141 vector<string> chemicalNames;
00142 vector<string> qns;
00143
00144
00145 enum FILTER_LIST { FILTER_TOP_20, FILTER_PLANETARY_ATMOSPHERE, FILTER_HOT_CORES,
00146 FILTER_DARK_CLOUDS, FILTER_DIFFUSE_CLOUDS, FILTER_COMETS, FILTER_AGB_PPN_PN,
00147 FILTER_EXTRAGALACTIC, END_FILTERS };
00148 vector<bool> filters;
00149 static vector<string> filterNames;
00150
00151
00152 const static std::string TABLE_MAIN;
00153 const static std::string TABLE_SPECIES;
00154
00155
00156 const static std::string FREQUENCY_COLUMN;
00157 const static std::string TEMPERATURE_COLUMN;
00158 const static std::string SPECIES_ID_COLUMN;
00159 const static std::string SPECIES_COLUMN;
00160 const static std::string SMU2_COLUMN;
00161 const static std::string EL_COLUMN;
00162 const static std::string EU_COLUMN;
00163 const static std::string LOGA_COLUMN;
00164 const static std::string INTENSITY_COLUMN;
00165 const static std::string RESOLVED_QNS_COLUMN;
00166 const static std::string CHEMICAL_NAME_COLUMN;
00167 enum TableColumns { SPECIES_ID_COL, SPECIES_NAME_COL, CHEMICAL_NAME_COL,
00168 FREQUENCY_COL, TEMPERATURE_COL, RESOLVED_QNS_COL, INTENSITY_COL, SMU2_COL, LOGA_COL, EL_COL,
00169 EU_COL, END_COL };
00170 static std::vector<string> resultColumns;
00171
00172
00173 const static std::string FILTER_KNOWN_AST_COLUMN;
00174 const static std::string FILTER_PLANET_COLUMN;
00175 const static std::string FILTER_HOTCORE_COLUMN;
00176 const static std::string FILTER_DIFFUSECLOUD_COLUMN;
00177 const static std::string FILTER_DARKCLOUD_COLUMN;
00178 const static std::string FILTER_COMET_COLUMN;
00179 const static std::string FILTER_EXTRAGALACTIC_COLUMN;
00180 const static std::string FILTER_AGB_PPN_PN_COLUMN;
00181 const static std::string FILTER_TOP20_COLUMN;
00182
00183
00184
00185 const static std::string FROM;
00186 const static std::string SELECT;
00187 const static std::string BETWEEN;
00188 const static std::string AND;
00189 const static std::string OPEN_PAREN;
00190 const static std::string CLOSE_PAREN;
00191 const static std::string SINGLE_QUOTE;
00192 const static std::string COMMA;
00193 const static std::string PERIOD;
00194 const static std::string EQUALS;
00195 const static std::string IN;
00196 const static std::string LIKE;
00197 const static std::string OR;
00198
00199 const static int DEFAULT_VALUE;
00200
00201
00202 int rowLimit;
00203 };
00204 }
00205 #endif