00001 #ifndef moses_DynSAInclude_params_h
00002 #define moses_DynSAInclude_params_h
00003
00004 #include <iostream>
00005 #include <map>
00006 #include <set>
00007 #include <vector>
00008 #include "FileHandler.h"
00009 #include "utils.h"
00010 #include "types.h"
00011
00012 #define NumOfParams(paramArray) (sizeof(paramArray)/sizeof((paramArray)[0]))
00013
00014 namespace Moses
00015 {
00016 typedef struct ParamDefs {
00017 std::string name;
00018 std::string value;
00019 std::string abbrev;
00020 int type;
00021 std::string description;
00022 } ParamDefs;
00023
00025 class Parameters
00026 {
00027 public:
00028 static const std::string kNotSetValue;
00029 static const int kBoolValue;
00030 static const int kIntValue;
00031 static const int kFloatValue;
00032 static const int kStringValue;
00033 static const int kUndefinedValue;
00034 static const std::string kFalseValue;
00035 static const std::string kTrueValue;
00036
00037 Parameters(const ParamDefs * paramdefs, const count_t paramNum);
00038 Parameters(int argc, char** argv, const ParamDefs * paramdefs, const count_t paramNum);
00039 ~Parameters() {}
00040 bool loadParams(int argc, char ** argv);
00041 bool loadParams(const std::string& param_file, std::set<std::string>&);
00042 int getValueType(const std::string & name);
00043 bool setParamValue(const std::string& name, const std::string& value);
00044 bool verifyValueType(const std::string& name, const std::string& value);
00045 bool isValidParamName(const std::string & name);
00046 std::string getParamValue(const std::string& name);
00047
00048 std::string getParam(const std::string& name);
00049 int getParamCount() const;
00050
00051
00052
00053
00054
00055
00056 private:
00057 std::string normaliseParamName(const std::string &name);
00058 void initialize(const ParamDefs * paramdefs, const count_t paramNum);
00059 std::map<std::string, ParamDefs > params_;
00060 };
00061
00062 }
00063 #endif //INC_PARAMS.H
00064