00001 00002 00003 00004 //----------------------------------------------------------------------------- 00005 // CVS: $Revision: 6421 $, $Date: 2009-11-27 10:57:35 +0000 (Fri, 27 Nov 2009) $, $Author: EckhardSutorius $ 00006 //----------------------------------------------------------------------------- 00007 #ifndef OPTIONS_H 00008 #define OPTIONS_H 00009 00010 #include <list> 00011 #include <map> 00012 #include <string> 00013 00014 #include "DataTypes.h" 00015 #include "MyException.h" 00016 //----------------------------------------------------------------------------- 00018 namespace OptionNames 00019 { 00020 const std::string sqlfile = "sqlfile"; 00021 const std::string pixfile = "pixfile"; 00022 const std::string catfile = "catfile"; 00023 const std::string archive = "archive"; 00024 const std::string cuEvent = "cuEvent"; 00025 const std::string files = "files"; 00026 const std::string tables = "tables"; 00027 const std::string csvpath = "csvpath"; 00028 const std::string csvprefix = "csvprefix"; 00029 const std::string sqlpath = "sqlpath"; 00030 const std::string illumname = "illumname"; 00031 const std::string outtables = "outtables"; 00032 const std::string newobjid = "newobjid"; 00033 } 00034 //----------------------------------------------------------------------------- 00037 class OptionException : public MyException 00038 { 00039 public: 00040 OptionException() {} 00041 OptionException(const std::string& aMsg) 00042 : MyException("OptionException: ", aMsg) { } 00043 }; 00044 //----------------------------------------------------------------------------- 00051 class Options 00052 { 00053 public: 00055 bool isOption(const std::string& name) const 00056 { return valueMap[name].length() > 0; } 00057 00059 void checkOptions(const std::list<std::string>& names) const; 00060 00062 int getOptionInt(const std::string& name) const; 00063 00065 double getOptionDbl(const std::string& name) const; 00066 00068 const std::string& getOptionStr(const std::string& name) const; 00069 00071 const std::string& getCurationEvent() const; 00072 00074 const std::string& getArchive() const; 00075 00078 const std::string& getCsvPath() const; 00079 00081 const std::string& getIllumFileList() const; 00082 00084 const std::string& getOutTablesList() const; 00085 00088 const std::string& getCsvPrefix() const; 00089 00092 const std::string& getSqlPath() const; 00093 00095 const std::string& getNewObjId() const; 00096 00099 const std::string& getTableList() const; 00100 00102 const std::string& getTableName(int n) const; 00103 00104 // Return the index of the table name in the table list 00105 int getTableNum(const std::string& name) const; 00106 00108 const std::string& getIllumTableName(int n) const; 00109 00111 const std::string& getSchemaFilename(int n) const; 00112 00115 StringMap getConstraints(int n) const; 00116 00118 int getNumTables() const; 00119 00120 //Input options associated with list of files 00121 00123 const std::string& getFileList() const; 00124 00126 const std::string& getPixelFilename(int n) const; 00127 00129 const std::string& getCatalogFilename(int n) const; 00130 00134 const std::string& getCompressedName(int n) const; 00135 00137 int getNumScienceFiles() const; 00138 00139 // Get the number of illumination tables 00140 int getNumIllumTables() const; 00141 00142 // Give the option filler class access to the private data 00143 friend class OptionsFiller; 00144 00145 private: 00146 static int numOptions; 00147 00149 static std::map<std::string, std::string> valueMap; 00150 00152 static std::map<int, StringMap> fileMap; 00153 00155 static std::map<int, StringMap> illumMap; 00156 00159 static std::map<int, StringMap> tableMap; 00160 }; 00161 //----------------------------------------------------------------------------- 00163 class OptionsFiller 00164 { 00165 public: 00168 void parseCommand(int argc, char *argv[]); 00169 00172 void parseFileList(const std::string& fileName); 00173 00175 void parseIllumList(const std::string& fileName); 00176 00178 void parseTableList(const std::string& fileName); 00179 00181 void setOption(const std::string& name, int value); 00182 00184 void setOption(const std::string& name, const double& value); 00185 00187 void setOption(const std::string& name, const std::string& value); 00188 }; 00189 //----------------------------------------------------------------------------- 00190 #endif