#ifndef CONFIG_H_ #define CONFIG_H_ #include #include #include #include #include #include enum param_type { NUMERIC, STRING }; enum param_mult { NONE, MULT, DIV }; /* * Structure for defining a benchmark parameter */ struct param_def { /* * Name of the parameter (as appears in rib.ini) */ std::string name; /* * Type of the parameter */ param_type type; /* * TODO: FIXME */ bool present; /* * Managed parameters can have multiple values to execute with e.g. all combinations, unmanaged not. * Unmanaged are intended for global options, do not appear in result file names, etc. */ bool managed; /* * How the parameter changes the results */ param_mult mult; /* * Constructor for parameters not modifying the results, optionally unmanaged (managed by default). */ param_def(std::string _name, param_type _type, bool _managed = true) : name(_name), type(_type), present(true), managed(_managed), mult(NONE) {}; /* * Constructor for parameters modifying the results, managed. */ param_def(std::string _name, param_type _type, param_mult _mult) : name(_name), type(_type), present(true), managed(true), mult(_mult) {}; }; class BenchParameter { public: virtual void print(std::ostream &s) = 0; virtual void print_current(std::ostream &s, bool units) = 0; virtual void reset() = 0; virtual bool nextStep() = 0; virtual bool nextStepPossible() = 0; virtual bool resume_from(BenchParameter * res) = 0; virtual ~BenchParameter() {}; }; class BenchParameterNumeric : public BenchParameter { public: enum { LINEAR, EXPONENTIAL } step_type; size_t begin; size_t end; size_t step; size_t current; BenchParameterNumeric(size_t _begin); void print(std::ostream &s); void print_current(std::ostream &s, bool units); void reset(); bool nextStep(); bool nextStepPossible(); bool resume_from(BenchParameter * res); }; class BenchParameterString : public BenchParameter { public: std::string value; BenchParameterString(std::string _value); void print(std::ostream &s); void print_current(std::ostream &s, bool units); void reset(); bool nextStep(); bool nextStepPossible(); bool resume_from(BenchParameter * res); virtual ~BenchParameterString() {}; }; typedef std::list params_list; std::map > parse_ini(const char * ini_filename); std::vector tokenize (const std::string & str, const std::string & delimiters); void replace_chars (std::string & str, char from, char to); /* * Deallocates all unconsumed parameters */ void free_ini(std::map > & allparams); #endif /*CONFIG_H_*/