tesseract  4.0.0-1-g2a2b
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 54 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 57 of file paramsd.cpp.

57  {
58  my_id_ = nrParams;
59  nrParams++;
60  param_type_ = VT_STRING;
61  sIt = it;
62  vcMap[my_id_] = this;
63 }

◆ ParamContent() [3/5]

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

Definition at line 65 of file paramsd.cpp.

65  {
66  my_id_ = nrParams;
67  nrParams++;
68  param_type_ = VT_INTEGER;
69  iIt = it;
70  vcMap[my_id_] = this;
71 }

◆ ParamContent() [4/5]

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

Definition at line 73 of file paramsd.cpp.

73  {
74  my_id_ = nrParams;
75  nrParams++;
76  param_type_ = VT_BOOLEAN;
77  bIt = it;
78  vcMap[my_id_] = this;
79 }

◆ ParamContent() [5/5]

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

Definition at line 81 of file paramsd.cpp.

81  {
82  my_id_ = nrParams;
83  nrParams++;
84  param_type_ = VT_DOUBLE;
85  dIt = it;
86  vcMap[my_id_] = this;
87 }

Member Function Documentation

◆ Compare()

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

Definition at line 183 of file paramsd.cpp.

183  {
184  const ParamContent* one = *static_cast<const ParamContent* const*>(v1);
185  const ParamContent* two = *static_cast<const ParamContent* const*>(v2);
186  return strcmp(one->GetName(), two->GetName());
187 }
const char * GetName() const
Definition: paramsd.cpp:115

◆ GetDescription()

const char * ParamContent::GetDescription ( ) const

Definition at line 125 of file paramsd.cpp.

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

◆ GetId()

int ParamContent::GetId ( )
inline

Definition at line 76 of file paramsd.h.

76 { return my_id_; }

◆ GetName()

const char * ParamContent::GetName ( ) const

Definition at line 115 of file paramsd.cpp.

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

◆ GetParamContentById()

ParamContent * ParamContent::GetParamContentById ( int  id)
static

Definition at line 90 of file paramsd.cpp.

90  {
91  return vcMap[id];
92 }

◆ GetValue()

STRING ParamContent::GetValue ( ) const

Definition at line 134 of file paramsd.cpp.

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

◆ HasChanged()

bool ParamContent::HasChanged ( )
inline

Definition at line 77 of file paramsd.h.

77 { return changed_; }

◆ SetValue()

void ParamContent::SetValue ( const char *  val)

Definition at line 153 of file paramsd.cpp.

153  {
154 // TODO (wanke) Test if the values actually are properly converted.
155 // (Quickly visible impacts?)
156  changed_ = true;
157  if (param_type_ == VT_INTEGER) {
158  iIt->set_value(atoi(val));
159  } else if (param_type_ == VT_BOOLEAN) {
160  bIt->set_value(atoi(val));
161  } else if (param_type_ == VT_DOUBLE) {
162  dIt->set_value(strtod(val, nullptr));
163  } else if (param_type_ == VT_STRING) {
164  sIt->set_value(val);
165  }
166 }
void set_value(const STRING &value)
Definition: params.h:207
void set_value(int32_t value)
Definition: params.h:154
void set_value(BOOL8 value)
Definition: params.h:178
void set_value(double value)
Definition: params.h:231

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