All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 48 of file paramsd.h.

Constructor & Destructor Documentation

ParamContent::ParamContent ( )
inline

Definition at line 57 of file paramsd.h.

57  {
58  }
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::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::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::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

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

Definition at line 185 of file paramsd.cpp.

185  {
186  const ParamContent* one =
187  *reinterpret_cast<const ParamContent* const *>(v1);
188  const ParamContent* two =
189  *reinterpret_cast<const ParamContent* const *>(v2);
190  return strcmp(one->GetName(), two->GetName());
191 }
const char * GetName() const
Definition: paramsd.cpp:116
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:118
#define NULL
Definition: host.h:144
int ParamContent::GetId ( )
inline

Definition at line 71 of file paramsd.h.

71 { return my_id_; }
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:117
ParamContent * ParamContent::GetParamContentById ( int  id)
static

Definition at line 91 of file paramsd.cpp.

91  {
92  return vcMap[id];
93 }
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:376
Definition: strngs.h:44
void add_str_double(const char *str, double number)
Definition: strngs.cpp:386
#define NULL
Definition: host.h:144
const char * string() const
Definition: params.h:203
bool ParamContent::HasChanged ( )
inline

Definition at line 72 of file paramsd.h.

72 { return changed_; }
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 }
void set_value(BOOL8 value)
Definition: params.h:179
void set_value(double value)
Definition: params.h:232
void set_value(inT32 value)
Definition: params.h:155
#define TRUE
Definition: capi.h:28
#define NULL
Definition: host.h:144
void set_value(const STRING &value)
Definition: params.h:208

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