tesseract  4.00.00dev
ParamContent Class Reference

#include <paramsd.h>

Inheritance diagram for ParamContent:
ELIST_LINK

Public Member Functions

 ParamContent ()
 
 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 46 of file paramsd.h.

Constructor & Destructor Documentation

◆ ParamContent() [1/5]

ParamContent::ParamContent ( )
inline

Definition at line 55 of file paramsd.h.

55  {
56  }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

Member Function Documentation

◆ Compare()

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

Definition at line 185 of file paramsd.cpp.

185  {
186  const ParamContent* one =
187  *static_cast<const ParamContent* const *>(v1);
188  const ParamContent* two =
189  *static_cast<const ParamContent* const *>(v2);
190  return strcmp(one->GetName(), two->GetName());
191 }
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 NULL;
132 }
const char * info_str() const
Definition: params.h:117

◆ GetId()

int ParamContent::GetId ( )
inline

Definition at line 69 of file paramsd.h.

69 { 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:116

◆ 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() != NULL) {
145  result = sIt->string();
146  } else {
147  result = "Null";
148  }
149  }
150  return result;
151 }
void add_str_int(const char *str, int number)
Definition: strngs.cpp:381
Definition: strngs.h:45
void add_str_double(const char *str, double number)
Definition: strngs.cpp:391
const char * string() const
Definition: params.h:202

◆ HasChanged()

bool ParamContent::HasChanged ( )
inline

Definition at line 70 of file paramsd.h.

70 { 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  dIt->set_value(strtod(val, NULL));
164  } else if (param_type_ == VT_STRING) {
165  sIt->set_value(val);
166  }
167 }
#define TRUE
Definition: capi.h:45
void set_value(const STRING &value)
Definition: params.h:207
void set_value(BOOL8 value)
Definition: params.h:178
void set_value(inT32 value)
Definition: params.h:154
void set_value(double value)
Definition: params.h:231

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