Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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)
 
const char * 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::ParamContent ( )
inline

Definition at line 55 of file paramsd.h.

55  {
56  }
ParamContent::ParamContent ( tesseract::StringParam it)

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)

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)

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)

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 }
#define NULL
Definition: host.h:144
const char * info_str() const
Definition: params.h:115
int ParamContent::GetId ( )
inline

Definition at line 69 of file paramsd.h.

69 { 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:114
ParamContent * ParamContent::GetParamContentById ( int  id)
static

Definition at line 91 of file paramsd.cpp.

91  {
92  return vcMap[id];
93 }
const char * ParamContent::GetValue ( ) const

Definition at line 135 of file paramsd.cpp.

135  {
136 char* msg = new char[1024];
137  if (param_type_ == VT_INTEGER) {
138  sprintf(msg, "%d", ((inT32) *(iIt)));
139  } else if (param_type_ == VT_BOOLEAN) {
140  sprintf(msg, "%d", ((BOOL8) * (bIt)));
141  } else if (param_type_ == VT_DOUBLE) {
142  sprintf(msg, "%g", ((double) * (dIt)));
143  } else if (param_type_ == VT_STRING) {
144  if (((STRING) * (sIt)).string() != NULL) {
145  sprintf(msg, "%s", ((STRING) * (sIt)).string());
146  } else {
147  sprintf(msg, "Null");
148  }
149  }
150  return msg;
151 }
unsigned char BOOL8
Definition: host.h:113
#define NULL
Definition: host.h:144
int inT32
Definition: host.h:102
Definition: strngs.h:40
bool ParamContent::HasChanged ( )
inline

Definition at line 70 of file paramsd.h.

70 { 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(const STRING &value)
Definition: params.h:189
#define NULL
Definition: host.h:144
void set_value(BOOL8 value)
Definition: params.h:168
void set_value(inT32 value)
Definition: params.h:150
void set_value(double value)
Definition: params.h:207
#define TRUE
Definition: capi.h:27

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