casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SearchEngine.h
Go to the documentation of this file.
00001 //# MSContinuumSubtractor.h: Fit & subtract continuum from spectral line data
00002 //# Copyright (C) 2004
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 //#
00028 #ifndef SPLAT_SEARCHENGINE_H
00029 #define SPLAT_SEARCHENGINE_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <casa/Logging/LogIO.h>
00036 #include <spectrallines/Splatalogue/SplatalogueTable.h>
00037 
00038 namespace casa {
00039 
00040 // <summary>Performs a query on a splatalogue spectral line table</summary>
00041 // <use visibility=export>
00042 // 
00043 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00044 // </reviewed>
00045 // 
00046 
00047 // <etymology>
00048 // Searches a splatalogue table.
00049 // </etymology>
00050 //
00051 // <synopsis>
00052 // It is a requirement that users be able to perform searches on spectral
00053 // line tables they import from Splatalogue.
00054 // </synopsis>
00055 //
00056 // <example>
00057 // <srcBlock>
00058 // SearchEngine searcher(...);
00059 // SplatalogueTable *resTable = searcher.search();
00060 // </srcBlock>
00061 // </example>
00062 //
00063 // <motivation>
00064 // A class to for splatalogue spectral line searches.
00065 // </motivation>
00066 //
00067 // <todo asof="">
00068 // </todo>
00069  
00070 
00071 class SearchEngine
00072 {
00073 public:
00074         // <src>table</src> Input spectral line table to search.
00075         // <src>list</src> List result set of search to logger (and optional logfile)?
00076         // <src>logfile</src> Logfile to list results to. Only used if list=True. If empty, no logfile is created.
00077         // <src>append</src> Append results to logfile (True) or overwrite logfile (False) if it exists? Only used if list=True and logfile not empty.
00078         SearchEngine(
00079                 const SplatalogueTable* const table, const Bool list,
00080                 const String& logfile, const Bool append
00081         );
00082 
00083         //destuctor
00084         ~SearchEngine();
00085 
00086         // Search the table. It is the caller's responsibility to delete the returned pointer.
00087         SplatalogueTable* search(
00088                 const String& resultsTableName, const Double freqLow, const Double freqHigh,
00089                 const Vector<String>& species, const Bool recommendedOnly,
00090                 const Vector<String>& chemNames, const Vector<String>& qns,
00091                 const Double intensityLow, const Double intensityHigh,
00092                 const Double smu2Low, const Double smu2High,
00093                 const Double logaLow, const Double logaHigh,
00094                 const Double elLow, const Double elHigh,
00095                 const Double euLow, const Double euHigh,
00096                 const Bool includeRRLs, const Bool onlyRRLs
00097         ) const;
00098 
00099         // Get the unique species in the table.
00100         Vector<String> uniqueSpecies() const;
00101 
00102         // Get the unique chemical names in the table.
00103         Vector<String> uniqueChemicalNames() const;
00104 
00105 private:
00106         LogIO *_log;
00107         const SplatalogueTable *_table;
00108         String _logfile;
00109         const Bool _list, _append;
00110         SearchEngine();
00111 
00112         String _getBetweenClause(
00113                 const String& col, const Double low, const Double high
00114         ) const;
00115 
00116         // If the query table is currently not on disk, this method will temporarily
00117         // write a copy of it to disk and query it, and then remove the copy from disk.
00118         // The method returns the query results table.
00119         Table _runQuery(const String& query) const;
00120 
00121         void _logIt(const String& logString) const;
00122 };
00123 
00124 
00125 } //# NAMESPACE CASA - END
00126 
00127 #endif