25 #include "genericvector.h" 58 static bool ReadParamsFile(
68 static bool SetParam(
const char *name,
const char* value,
80 for (i = 0; i < global_vec.
size(); ++i) {
81 if (strcmp(global_vec[i]->name_str(), name) == 0)
return global_vec[i];
83 for (i = 0; i < member_vec.
size(); ++i) {
84 if (strcmp(member_vec[i]->name_str(), name) == 0)
return member_vec[i];
91 for (
int i = 0; i < vec->
size(); ++i) {
92 if ((*vec)[i] == param_ptr) {
100 static bool GetParamAsString(
const char *name,
105 static void PrintParams(FILE *fp,
const ParamsVectors *member_params);
125 !this->is_debug()) ||
131 Param(
const char *name,
const char *comment,
bool init) :
132 name_(name), info_(comment), init_(init) {
133 debug_ = (strstr(name,
"debug") !=
nullptr) || (strstr(name,
"display"));
144 IntParam(int32_t value,
const char *name,
const char *comment,
bool init,
151 ~IntParam() { ParamUtils::RemoveParam<IntParam>(
this, params_vec_); }
152 operator int32_t()
const {
return value_; }
168 BoolParam(
bool value,
const char *name,
const char *comment,
bool init,
175 ~BoolParam() { ParamUtils::RemoveParam<BoolParam>(
this, params_vec_); }
176 operator BOOL8()
const {
return value_; }
193 const char *comment,
bool init,
200 ~StringParam() { ParamUtils::RemoveParam<StringParam>(
this, params_vec_); }
202 const char *
string()
const {
return value_.string(); }
203 const char *
c_str()
const {
return value_.string(); }
204 bool empty() {
return value_.length() <= 0; }
228 ~DoubleParam() { ParamUtils::RemoveParam<DoubleParam>(
this, params_vec_); }
229 operator double()
const {
return value_; }
264 #define INT_VAR_H(name,val,comment)\ 265 tesseract::IntParam name 267 #define BOOL_VAR_H(name,val,comment)\ 268 tesseract::BoolParam name 270 #define STRING_VAR_H(name,val,comment)\ 271 tesseract::StringParam name 273 #define double_VAR_H(name,val,comment)\ 274 tesseract::DoubleParam name 276 #define INT_VAR(name,val,comment)\ 277 tesseract::IntParam name(val,#name,comment,false,GlobalParams()) 279 #define BOOL_VAR(name,val,comment)\ 280 tesseract::BoolParam name(val,#name,comment,false,GlobalParams()) 282 #define STRING_VAR(name,val,comment)\ 283 tesseract::StringParam name(val,#name,comment,false,GlobalParams()) 285 #define double_VAR(name,val,comment)\ 286 tesseract::DoubleParam name(val,#name,comment,false,GlobalParams()) 288 #define INT_MEMBER(name, val, comment, vec)\ 289 name(val, #name, comment, false, vec) 291 #define BOOL_MEMBER(name, val, comment, vec)\ 292 name(val, #name, comment, false, vec) 294 #define STRING_MEMBER(name, val, comment, vec)\ 295 name(val, #name, comment, false, vec) 297 #define double_MEMBER(name, val, comment, vec)\ 298 name(val, #name, comment, false, vec) 300 #define INT_INIT_MEMBER(name, val, comment, vec)\ 301 name(val, #name, comment, true, vec) 303 #define BOOL_INIT_MEMBER(name, val, comment, vec)\ 304 name(val, #name, comment, true, vec) 306 #define STRING_INIT_MEMBER(name, val, comment, vec)\ 307 name(val, #name, comment, true, vec) 309 #define double_INIT_MEMBER(name, val, comment, vec)\ 310 name(val, #name, comment, true, vec) const char * string() const
Definition: params.h:202
StringParam(const char *value, const char *name, const char *comment, bool init, ParamsVectors *vec)
Definition: params.h:192
GenericVector< DoubleParam * > * params_vec_
Definition: params.h:240
bool is_debug() const
Definition: params.h:119
const char * info_
Definition: params.h:137
void remove(int index)
Definition: genericvector.h:766
static T * FindParam(const char *name, const GenericVector< T *> &global_vec, const GenericVector< T *> &member_vec)
Definition: params.h:76
BOOL8 value_
Definition: params.h:184
bool is_init() const
Definition: params.h:118
GenericVector< StringParam * > string_params
Definition: params.h:46
bool init_
Definition: params.h:138
const char * c_str() const
Definition: params.h:203
bool operator==(const STRING &other)
Definition: params.h:205
Definition: serialis.h:77
SetParamConstraint
Definition: params.h:36
~IntParam()
Definition: params.h:151
Definition: baseapi.cpp:94
BOOL8 default_
Definition: params.h:185
const char * name_str() const
Definition: params.h:116
BoolParam(bool value, const char *name, const char *comment, bool init, ParamsVectors *vec)
Definition: params.h:168
int32_t value_
Definition: params.h:160
Param(const char *name, const char *comment, bool init)
Definition: params.h:131
double default_
Definition: params.h:238
~StringParam()
Definition: params.h:200
void operator=(int32_t value)
Definition: params.h:153
void operator=(double value)
Definition: params.h:230
static void RemoveParam(T *param_ptr, GenericVector< T *> *vec)
Definition: params.h:90
void ResetToDefault()
Definition: params.h:208
bool empty()
Definition: params.h:204
~BoolParam()
Definition: params.h:175
GenericVector< BoolParam * > * params_vec_
Definition: params.h:187
void operator=(BOOL8 value)
Definition: params.h:177
GenericVector< StringParam * > * params_vec_
Definition: params.h:216
int32_t default_
Definition: params.h:161
void set_value(const STRING &value)
Definition: params.h:207
GenericVector< BoolParam * > bool_params
Definition: params.h:45
void ResetToDefault()
Definition: params.h:232
STRING default_
Definition: params.h:214
int size() const
Definition: genericvector.h:71
void set_value(BOOL8 value)
Definition: params.h:178
const char * name_
Definition: params.h:136
void operator=(const STRING &value)
Definition: params.h:206
void ResetToDefault()
Definition: params.h:179
bool debug_
Definition: params.h:139
double value_
Definition: params.h:237
IntParam(int32_t value, const char *name, const char *comment, bool init, ParamsVectors *vec)
Definition: params.h:144
DoubleParam(double value, const char *name, const char *comment, bool init, ParamsVectors *vec)
Definition: params.h:221
bool constraint_ok(SetParamConstraint constraint) const
Definition: params.h:120
const char * info_str() const
Definition: params.h:117
GenericVector< DoubleParam * > double_params
Definition: params.h:47
void ResetToDefault()
Definition: params.h:155
GenericVector< IntParam * > int_params
Definition: params.h:44
void set_value(double value)
Definition: params.h:231
STRING value_
Definition: params.h:213
~DoubleParam()
Definition: params.h:228
GenericVector< IntParam * > * params_vec_
Definition: params.h:163
void set_value(int32_t value)
Definition: params.h:154