2011-06-08 19:05:19 +04:00
|
|
|
#ifndef moses_DynSAInclude_params_h
|
|
|
|
#define moses_DynSAInclude_params_h
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
2012-07-10 13:08:23 +04:00
|
|
|
#include "FileHandler.h"
|
2011-06-08 19:05:19 +04:00
|
|
|
#include "utils.h"
|
|
|
|
#include "types.h"
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
#define NumOfParams(paramArray) (sizeof(paramArray)/sizeof((paramArray)[0]))
|
2011-06-08 19:05:19 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2011-06-08 19:05:19 +04:00
|
|
|
typedef struct ParamDefs {
|
|
|
|
std::string name;
|
2013-05-29 21:16:15 +04:00
|
|
|
std::string value;
|
2011-06-08 19:05:19 +04:00
|
|
|
std::string abbrev;
|
|
|
|
int type;
|
|
|
|
std::string description;
|
|
|
|
} ParamDefs;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
//! @todo ask abby2
|
|
|
|
class Parameters
|
|
|
|
{
|
2011-06-08 19:05:19 +04:00
|
|
|
public:
|
2013-05-29 21:16:15 +04:00
|
|
|
static const std::string kNotSetValue;
|
2011-06-08 19:05:19 +04:00
|
|
|
static const int kBoolValue;
|
|
|
|
static const int kIntValue;
|
|
|
|
static const int kFloatValue;
|
|
|
|
static const int kStringValue;
|
|
|
|
static const int kUndefinedValue;
|
|
|
|
static const std::string kFalseValue;
|
|
|
|
static const std::string kTrueValue;
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2011-06-08 19:05:19 +04:00
|
|
|
Parameters(const ParamDefs * paramdefs, const count_t paramNum);
|
|
|
|
Parameters(int argc, char** argv, const ParamDefs * paramdefs, const count_t paramNum);
|
|
|
|
~Parameters() {}
|
|
|
|
bool loadParams(int argc, char ** argv);
|
|
|
|
bool loadParams(const std::string& param_file, std::set<std::string>&);
|
|
|
|
int getValueType(const std::string & name);
|
2013-05-29 21:16:15 +04:00
|
|
|
bool setParamValue(const std::string& name, const std::string& value);
|
|
|
|
bool verifyValueType(const std::string& name, const std::string& value);
|
2011-06-08 19:05:19 +04:00
|
|
|
bool isValidParamName(const std::string & name);
|
|
|
|
std::string getParamValue(const std::string& name);
|
|
|
|
//void* getParam(const std::string& name);
|
|
|
|
std::string getParam(const std::string& name);
|
|
|
|
int getParamCount() const;
|
|
|
|
/*
|
|
|
|
int getCSVParams(const std::string & name, std::vector<std::string> & values);
|
|
|
|
bool checkParamIsSet(const std::string& name);
|
|
|
|
bool printParams();
|
|
|
|
bool printHelp(const std::string & name);
|
|
|
|
*/
|
|
|
|
private:
|
|
|
|
std::string normaliseParamName(const std::string &name);
|
|
|
|
void initialize(const ParamDefs * paramdefs, const count_t paramNum);
|
|
|
|
std::map<std::string, ParamDefs > params_; // name->value,type,abbrev,desc
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif //INC_PARAMS.H
|
|
|
|
|