tesseract v5.3.3.20231005
tesseract::ParamContent Class Reference

#include <paramsd.h>

Inheritance diagram for tesseract::ParamContent:
tesseract::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)
 
std::string GetValue () const
 
const char * GetName () const
 
const char * GetDescription () const
 
int GetId () const
 
bool HasChanged () const
 
- Public Member Functions inherited from tesseract::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 47 of file paramsd.h.

Constructor & Destructor Documentation

◆ ParamContent() [1/5]

tesseract::ParamContent::ParamContent ( )
default

◆ ParamContent() [2/5]

tesseract::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:40
tesseract::StringParam * sIt
Definition: paramsd.h:84

◆ ParamContent() [3/5]

tesseract::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:40
tesseract::IntParam * iIt
Definition: paramsd.h:85

◆ ParamContent() [4/5]

tesseract::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:40
tesseract::BoolParam * bIt
Definition: paramsd.h:86

◆ ParamContent() [5/5]

tesseract::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:40
tesseract::DoubleParam * dIt
Definition: paramsd.h:87

Member Function Documentation

◆ Compare()

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

Definition at line 194 of file paramsd.cpp.

194 {
195 const ParamContent *one = *static_cast<const ParamContent *const *>(v1);
196 const ParamContent *two = *static_cast<const ParamContent *const *>(v2);
197 return strcmp(one->GetName(), two->GetName());
198}

◆ GetDescription()

const char * tesseract::ParamContent::GetDescription ( ) const

Definition at line 130 of file paramsd.cpp.

130 {
131 if (param_type_ == VT_INTEGER) {
132 return iIt->info_str();
133 } else if (param_type_ == VT_BOOLEAN) {
134 return bIt->info_str();
135 } else if (param_type_ == VT_DOUBLE) {
136 return dIt->info_str();
137 } else if (param_type_ == VT_STRING) {
138 return sIt->info_str();
139 } else {
140 return nullptr;
141 }
142}
const char * info_str() const
Definition: params.h:120

◆ GetId()

int tesseract::ParamContent::GetId ( ) const
inline

Definition at line 68 of file paramsd.h.

68 {
69 return my_id_;
70 }

◆ GetName()

const char * tesseract::ParamContent::GetName ( ) const

Definition at line 115 of file paramsd.cpp.

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

◆ GetParamContentById()

ParamContent * tesseract::ParamContent::GetParamContentById ( int  id)
static

Definition at line 91 of file paramsd.cpp.

91 {
92 return vcMap[id];
93}

◆ GetValue()

std::string tesseract::ParamContent::GetValue ( ) const

Definition at line 145 of file paramsd.cpp.

145 {
146 std::string result;
147 if (param_type_ == VT_INTEGER) {
148 result += std::to_string(*iIt);
149 } else if (param_type_ == VT_BOOLEAN) {
150 result += std::to_string(*bIt);
151 } else if (param_type_ == VT_DOUBLE) {
152 result += std::to_string(*dIt);
153 } else if (param_type_ == VT_STRING) {
154 result = sIt->c_str();
155 }
156 return result;
157}
const char * c_str() const
Definition: params.h:248

◆ HasChanged()

bool tesseract::ParamContent::HasChanged ( ) const
inline

Definition at line 71 of file paramsd.h.

71 {
72 return changed_;
73 }

◆ SetValue()

void tesseract::ParamContent::SetValue ( const char *  val)

Definition at line 160 of file paramsd.cpp.

160 {
161 // TODO (wanke) Test if the values actually are properly converted.
162 // (Quickly visible impacts?)
163 changed_ = true;
164 if (param_type_ == VT_INTEGER) {
165 iIt->set_value(atoi(val));
166 } else if (param_type_ == VT_BOOLEAN) {
167 bIt->set_value(atoi(val));
168 } else if (param_type_ == VT_DOUBLE) {
169 std::stringstream stream(val);
170 // Use "C" locale for reading double value.
171 stream.imbue(std::locale::classic());
172 double d = 0;
173 stream >> d;
174 dIt->set_value(d);
175 } else if (param_type_ == VT_STRING) {
176 sIt->set_value(val);
177 }
178}
void set_value(int32_t value)
Definition: params.h:166
void set_value(bool value)
Definition: params.h:208
void set_value(const std::string &value)
Definition: params.h:263
void set_value(double value)
Definition: params.h:305

Member Data Documentation

◆ bIt

tesseract::BoolParam* tesseract::ParamContent::bIt

Definition at line 86 of file paramsd.h.

◆ dIt

tesseract::DoubleParam* tesseract::ParamContent::dIt

Definition at line 87 of file paramsd.h.

◆ iIt

tesseract::IntParam* tesseract::ParamContent::iIt

Definition at line 85 of file paramsd.h.

◆ sIt

tesseract::StringParam* tesseract::ParamContent::sIt

Definition at line 84 of file paramsd.h.


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