23 #ifndef CONFIG_PARAM_H
24 #define CONFIG_PARAM_H
50 option_base(
const char* name) : mIDName(name), mShortOption(0), mLongOption(NULL) { }
56 void set_ID(
const char* name) { mIDName=name; }
59 std::string
get_name()
const {
return mPrefix + mIDName; }
81 mShortOption = short_option;
82 mLongOption = long_option;
110 std::string mDescription;
113 const char* mLongOption;
123 operator bool()
const {
124 assert(value_set || default_set);
125 return value_set ? value : default_value;
128 virtual bool is_defined()
const {
return value_set || default_set; }
137 bool set(
bool v) { value_set=
true; value=v;
return true; }
155 operator std::string()
const {
return get(); }
157 assert(value_set || default_set);
158 return value_set ? value : default_value;
161 virtual bool is_defined()
const {
return value_set || default_set; }
164 void set_default(std::string v) { default_value=v; default_set=
true; }
170 bool set(std::string v) { value_set=
true; value=v;
return true; }
177 std::string default_value;
185 have_low_limit(false), have_high_limit(false) { }
187 void set_minimum(
int mini) { have_low_limit =
true; low_limit =mini; }
188 void set_maximum(
int maxi) { have_high_limit=
true; high_limit=maxi; }
195 assert(value_set || default_set);
196 return value_set ? value : default_value;
200 virtual bool is_defined()
const {
return value_set || default_set; }
210 if (is_valid(v)) { value_set=
true; value=v;
return true; }
211 else {
return false; }
221 bool have_low_limit, have_high_limit;
222 int low_limit, high_limit;
224 std::vector<int> valid_values_set;
226 bool is_valid(
int v)
const;
248 delete[] choice_string_table;
249 choice_string_table = NULL;
253 mutable char* choice_string_table;
264 void add_choice(
const std::string& s,
T id,
bool default_value=
false) {
265 choices.push_back( std::make_pair(s,
id) );
276 #ifdef FOR_LOOP_AUTO_SUPPORT
279 for (
typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
280 const std::pair<std::string,T> & c = *it;
282 if (c.second == val) {
284 defaultValue = c.first;
303 #ifdef FOR_LOOP_AUTO_SUPPORT
306 for (
typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
307 const std::pair<std::string,T> & c = *it;
309 if (val == c.first) {
310 selectedID = c.second;
321 assert(value_set || default_set);
322 return value_set ? selectedValue : defaultValue;
324 void setID(
T id) { selectedID=id; validValue=
true; }
325 const T getID()
const {
return value_set ? selectedID : defaultID; }
327 virtual bool is_defined()
const {
return value_set || default_set; }
332 std::vector<std::string> names;
333 #ifdef FOR_LOOP_AUTO_SUPPORT
336 for (
typename std::vector< std::pair<std::string,T> >::const_iterator it=choices.begin(); it!=choices.end(); ++it) {
337 const std::pair<std::string,T> & p = *it;
339 names.push_back(p.first);
349 std::vector< std::pair<std::string,T> > choices;
352 std::string defaultValue;
356 std::string selectedValue;
375 bool ignore_unknown_options=
false);
394 std::vector<option_base*> mOptions;
398 mutable char* param_string_table;
Definition: configparam.h:232
choice_option_base()
Definition: configparam.h:234
virtual std::string getTypeDescr() const
const char ** get_choices_string_table() const
bool set(std::string v)
Definition: configparam.h:237
void invalidate_choices_string_table()
Definition: configparam.h:247
~choice_option_base()
Definition: configparam.h:235
virtual std::vector< std::string > get_choice_names() const =0
virtual bool set_value(const std::string &val)=0
virtual LIBDE265_API bool processCmdLineArguments(char **argv, int *argc, int idx)
Definition: configparam.h:258
virtual bool has_default() const
Definition: configparam.h:328
virtual bool is_defined() const
Definition: configparam.h:327
bool isValidValue() const
Definition: configparam.h:318
std::vector< std::string > get_choice_names() const
Definition: configparam.h:330
std::string get_default_string() const
Definition: configparam.h:344
choice_option()
Definition: configparam.h:260
const std::string & getValue() const
Definition: configparam.h:320
void add_choice(const std::string &s, T id, bool default_value=false)
Definition: configparam.h:264
void setID(T id)
Definition: configparam.h:324
const T getID() const
Definition: configparam.h:325
void set_default(T val)
Definition: configparam.h:275
bool set_value(const std::string &val)
Definition: configparam.h:296
T operator()() const
Definition: configparam.h:346
Definition: configparam.h:366
const char ** get_parameter_string_table() const
const char ** get_parameter_choices_table(const char *param) const
void LIBDE265_API print_params() const
void LIBDE265_API add_option(option_base *o)
~config_parameters()
Definition: configparam.h:369
config_parameters()
Definition: configparam.h:368
std::vector< std::string > get_parameter_choices(const char *param) const
bool set_string(const char *param, const char *value)
bool set_bool(const char *param, bool value)
bool set_choice(const char *param, const char *value)
std::vector< std::string > get_parameter_IDs() const
bool LIBDE265_API parse_command_line_params(int *argc, char **argv, int *first_idx=NULL, bool ignore_unknown_options=false)
bool set_int(const char *param, int value)
Definition: configparam.h:47
void set_description(std::string descr)
Definition: configparam.h:64
std::string get_name() const
Definition: configparam.h:59
std::string get_description() const
Definition: configparam.h:65
void set_cmd_line_options(const char *long_option, char short_option=0)
Definition: configparam.h:79
virtual std::string get_default_string() const
Definition: configparam.h:104
bool hasLongOption() const
Definition: configparam.h:95
bool hasShortOption() const
Definition: configparam.h:93
void unsetCmdLineOption()
Definition: configparam.h:87
void set_short_option(char short_option)
Definition: configparam.h:85
std::string getLongOption() const
Definition: configparam.h:96
char getShortOption() const
Definition: configparam.h:94
virtual std::string getTypeDescr() const =0
virtual ~option_base()
Definition: configparam.h:51
option_base(const char *name)
Definition: configparam.h:50
virtual bool is_defined() const =0
void set_ID(const char *name)
Definition: configparam.h:56
virtual LIBDE265_API bool processCmdLineArguments(char **argv, int *argc, int idx)
Definition: configparam.h:98
void add_namespace_prefix(std::string prefix)
Definition: configparam.h:57
virtual bool has_default() const =0
bool is_undefined() const
Definition: configparam.h:72
option_base()
Definition: configparam.h:49
bool has_description() const
Definition: configparam.h:66
Definition: configparam.h:119
option_bool()
Definition: configparam.h:121
virtual bool is_defined() const
Definition: configparam.h:128
virtual LIBDE265_API bool processCmdLineArguments(char **argv, int *argc, int idx)
Definition: configparam.h:135
virtual bool has_default() const
Definition: configparam.h:129
bool set(bool v)
Definition: configparam.h:137
virtual std::string get_default_string() const
Definition: configparam.h:132
virtual std::string getTypeDescr() const
Definition: configparam.h:134
void set_default(bool v)
Definition: configparam.h:131
Definition: configparam.h:182
void set_range(int mini, int maxi)
void set_valid_values(const std::vector< int > &v)
Definition: configparam.h:190
virtual LIBDE265_API std::string get_default_string() const
bool set(int v)
Definition: configparam.h:209
virtual LIBDE265_API bool processCmdLineArguments(char **argv, int *argc, int idx)
option_int()
Definition: configparam.h:184
void set_maximum(int maxi)
Definition: configparam.h:188
virtual bool has_default() const
Definition: configparam.h:201
int operator()() const
Definition: configparam.h:194
virtual bool is_defined() const
Definition: configparam.h:200
void set_minimum(int mini)
Definition: configparam.h:187
const option_int & operator=(int v)
Definition: configparam.h:192
void set_default(int v)
Definition: configparam.h:203
virtual LIBDE265_API std::string getTypeDescr() const
Definition: configparam.h:149
std::string get() const
Definition: configparam.h:156
virtual bool has_default() const
Definition: configparam.h:162
void set_default(std::string v)
Definition: configparam.h:164
virtual bool is_defined() const
Definition: configparam.h:161
virtual LIBDE265_API std::string get_default_string() const
Definition: configparam.h:165
const option_string & operator=(std::string v)
Definition: configparam.h:153
virtual LIBDE265_API std::string getTypeDescr() const
Definition: configparam.h:167
option_string()
Definition: configparam.h:151
virtual LIBDE265_API bool processCmdLineArguments(char **argv, int *argc, int idx)
bool set(std::string v)
Definition: configparam.h:170
#define LIBDE265_API
Definition: de265.h:52
en265_parameter_type
Definition: en265.h:66
QStringView prefix
Definition: itemviewutilities.cpp:593
qulonglong value
Definition: itemviewutilities.cpp:592
#define FOR_LOOP(type, var, list)
Definition: util.h:72