00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef moses_Parameter_h
00023 #define moses_Parameter_h
00024
00025 #include <string>
00026 #include <map>
00027 #include <vector>
00028 #include "TypeDef.h"
00029
00030 namespace Moses
00031 {
00032
00033 typedef std::vector<std::string> PARAM_VEC;
00034 typedef std::map<std::string, PARAM_VEC > PARAM_MAP;
00035 typedef std::map<std::string, bool> PARAM_BOOL;
00036 typedef std::map<std::string, std::string > PARAM_STRING;
00037
00041 class Parameter
00042 {
00043 protected:
00044 PARAM_MAP m_setting;
00045 PARAM_BOOL m_valid;
00046 PARAM_STRING m_abbreviation;
00047 PARAM_STRING m_description;
00048
00049 std::string FindParam(const std::string ¶mSwitch, int argc, char* argv[]);
00050 void OverwriteParam(const std::string ¶mSwitch, const std::string ¶mName, int argc, char* argv[]);
00051 bool ReadConfigFile(const std::string &filePath );
00052 bool FilesExist(const std::string ¶mName, int fieldNo, std::vector<std::string> const& fileExtension=std::vector<std::string>(1,""));
00053 bool isOption(const char* token);
00054 bool Validate();
00055
00056 void AddParam(const std::string ¶mName, const std::string &description);
00057 void AddParam(const std::string ¶mName, const std::string &abbrevName, const std::string &description);
00058
00059 void PrintCredit();
00060
00061 public:
00062 Parameter();
00063 ~Parameter();
00064 bool LoadParam(int argc, char* argv[]);
00065 bool LoadParam(const std::string &filePath);
00066 void Explain();
00067
00069 const PARAM_VEC &GetParam(const std::string ¶mName) {
00070 return m_setting[paramName];
00071 }
00073 bool isParamSpecified(const std::string ¶mName) {
00074 return m_setting.find( paramName ) != m_setting.end();
00075 }
00076
00077 };
00078
00079 }
00080
00081 #endif