tesseract 4.1.1
Loading...
Searching...
No Matches
ParamContent Class Reference

#include <paramsd.h>

Inheritance diagram for ParamContent:
ELIST_LINK

Public Member Functions

 ParamContent ()=default
 
 ParamContent (tesseract::StringParam *it)
 
 ParamContent (tesseract::IntParam *it)
 
 ParamContent (tesseract::BoolParam *it)
 
 ParamContent (tesseract::DoubleParam *it)
 
void SetValue (const char *val)
 
STRING GetValue () const
 
const char * GetName () const
 
const char * GetDescription () const
 
int GetId ()
 
bool HasChanged ()
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Static Public Member Functions

static int Compare (const void *v1, const void *v2)
 
static ParamContentGetParamContentById (int id)
 

Detailed Description

Definition at line 53 of file paramsd.h.

Constructor & Destructor Documentation

◆ ParamContent() [1/5]

ParamContent::ParamContent ( )
default

◆ ParamContent() [2/5]

ParamContent::ParamContent ( tesseract::StringParam it)
explicit

Definition at line 58 of file paramsd.cpp.

58 {
59 my_id_ = nrParams;
60 nrParams++;
61 param_type_ = VT_STRING;
62 sIt = it;
63 vcMap[my_id_] = this;
64}
@ VT_STRING
Definition: paramsd.h:44
tesseract::StringParam * sIt
Definition: paramsd.h:87

◆ ParamContent() [3/5]

ParamContent::ParamContent ( tesseract::IntParam it)
explicit

Definition at line 66 of file paramsd.cpp.

66 {
67 my_id_ = nrParams;
68 nrParams++;
69 param_type_ = VT_INTEGER;
70 iIt = it;
71 vcMap[my_id_] = this;
72}
@ VT_INTEGER
Definition: paramsd.h:42
tesseract::IntParam * iIt
Definition: paramsd.h:88

◆ ParamContent() [4/5]

ParamContent::ParamContent ( tesseract::BoolParam it)
explicit

Definition at line 74 of file paramsd.cpp.

74 {
75 my_id_ = nrParams;
76 nrParams++;
77 param_type_ = VT_BOOLEAN;
78 bIt = it;
79 vcMap[my_id_] = this;
80}
@ VT_BOOLEAN
Definition: paramsd.h:43
tesseract::BoolParam * bIt
Definition: paramsd.h:89

◆ ParamContent() [5/5]

ParamContent::ParamContent ( tesseract::DoubleParam it)
explicit

Definition at line 82 of file paramsd.cpp.

82 {
83 my_id_ = nrParams;
84 nrParams++;
85 param_type_ = VT_DOUBLE;
86 dIt = it;
87 vcMap[my_id_] = this;
88}
@ VT_DOUBLE
Definition: paramsd.h:45
tesseract::DoubleParam * dIt
Definition: paramsd.h:90

Member Function Documentation

◆ Compare()

int ParamContent::Compare ( const void *  v1,
const void *  v2 
)
static

Definition at line 189 of file paramsd.cpp.

189 {
190 const ParamContent* one = *static_cast<const ParamContent* const*>(v1);
191 const ParamContent* two = *static_cast<const ParamContent* const*>(v2);
192 return strcmp(one->GetName(), two->GetName());
193}
const char * GetName() const
Definition: paramsd.cpp:116

◆ GetDescription()

const char * ParamContent::GetDescription ( ) const

Definition at line 126 of file paramsd.cpp.

126 {
127 if (param_type_ == VT_INTEGER) { return iIt->info_str(); }
128 else if (param_type_ == VT_BOOLEAN) { return bIt->info_str(); }
129 else if (param_type_ == VT_DOUBLE) { return dIt->info_str(); }
130 else if (param_type_ == VT_STRING) { return sIt->info_str(); }
131 else return nullptr;
132}
const char * info_str() const
Definition: params.h:114

◆ GetId()

int ParamContent::GetId ( )
inline

Definition at line 75 of file paramsd.h.

75{ return my_id_; }

◆ GetName()

const char * ParamContent::GetName ( ) const

Definition at line 116 of file paramsd.cpp.

116 {
117 if (param_type_ == VT_INTEGER) { return iIt->name_str(); }
118 else if (param_type_ == VT_BOOLEAN) { return bIt->name_str(); }
119 else if (param_type_ == VT_DOUBLE) { return dIt->name_str(); }
120 else if (param_type_ == VT_STRING) { return sIt->name_str(); }
121 else
122 return "ERROR: ParamContent::GetName()";
123}
const char * name_str() const
Definition: params.h:113

◆ GetParamContentById()

ParamContent * ParamContent::GetParamContentById ( int  id)
static

Definition at line 91 of file paramsd.cpp.

91 {
92 return vcMap[id];
93}

◆ GetValue()

STRING ParamContent::GetValue ( ) const

Definition at line 135 of file paramsd.cpp.

135 {
136 STRING result;
137 if (param_type_ == VT_INTEGER) {
138 result.add_str_int("", *iIt);
139 } else if (param_type_ == VT_BOOLEAN) {
140 result.add_str_int("", *bIt);
141 } else if (param_type_ == VT_DOUBLE) {
142 result.add_str_double("", *dIt);
143 } else if (param_type_ == VT_STRING) {
144 if (STRING(*(sIt)).string() != nullptr) {
145 result = sIt->string();
146 } else {
147 result = "Null";
148 }
149 }
150 return result;
151}
const char * string() const
Definition: params.h:216
Definition: strngs.h:45
void add_str_int(const char *str, int number)
Definition: strngs.cpp:377
void add_str_double(const char *str, double number)
Definition: strngs.cpp:387

◆ HasChanged()

bool ParamContent::HasChanged ( )
inline

Definition at line 76 of file paramsd.h.

76{ return changed_; }

◆ SetValue()

void ParamContent::SetValue ( const char *  val)

Definition at line 154 of file paramsd.cpp.

154 {
155// TODO (wanke) Test if the values actually are properly converted.
156// (Quickly visible impacts?)
157 changed_ = true;
158 if (param_type_ == VT_INTEGER) {
159 iIt->set_value(atoi(val));
160 } else if (param_type_ == VT_BOOLEAN) {
161 bIt->set_value(atoi(val));
162 } else if (param_type_ == VT_DOUBLE) {
163 std::stringstream stream(val);
164 // Use "C" locale for reading double value.
165 stream.imbue(std::locale::classic());
166 double d = 0;
167 stream >> d;
168 dIt->set_value(d);
169 } else if (param_type_ == VT_STRING) {
170 sIt->set_value(val);
171 }
172}
void set_value(int32_t value)
Definition: params.h:151
void set_value(bool value)
Definition: params.h:184
void set_value(const STRING &value)
Definition: params.h:221
void set_value(double value)
Definition: params.h:254

Member Data Documentation

◆ bIt

tesseract::BoolParam* ParamContent::bIt

Definition at line 89 of file paramsd.h.

◆ dIt

tesseract::DoubleParam* ParamContent::dIt

Definition at line 90 of file paramsd.h.

◆ iIt

tesseract::IntParam* ParamContent::iIt

Definition at line 88 of file paramsd.h.

◆ sIt

tesseract::StringParam* ParamContent::sIt

Definition at line 87 of file paramsd.h.


The documentation for this class was generated from the following files: