Tesseract  3.02
ParamContent Class Reference

#include <paramsd.h>

Inheritance diagram for ParamContent:
ELIST_LINK

List of all members.

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 ()

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.

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

Definition at line 58 of file paramsd.cpp.

                                                   {
  my_id_ = nrParams;
  nrParams++;
  param_type_ = VT_STRING;
  sIt = it;
  vcMap[my_id_] = this;
}
ParamContent::ParamContent ( tesseract::IntParam it)

Definition at line 66 of file paramsd.cpp.

                                                {
  my_id_ = nrParams;
  nrParams++;
  param_type_ = VT_INTEGER;
  iIt = it;
  vcMap[my_id_] = this;
}
ParamContent::ParamContent ( tesseract::BoolParam it)

Definition at line 74 of file paramsd.cpp.

                                                 {
  my_id_ = nrParams;
  nrParams++;
  param_type_ = VT_BOOLEAN;
  bIt = it;
  vcMap[my_id_] = this;
}
ParamContent::ParamContent ( tesseract::DoubleParam it)

Definition at line 82 of file paramsd.cpp.

                                                   {
  my_id_ = nrParams;
  nrParams++;
  param_type_ = VT_DOUBLE;
  dIt = it;
  vcMap[my_id_] = this;
}

Member Function Documentation

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

Definition at line 185 of file paramsd.cpp.

                                                        {
  const ParamContent* one =
    *reinterpret_cast<const ParamContent* const *>(v1);
  const ParamContent* two =
    *reinterpret_cast<const ParamContent* const *>(v2);
  return strcmp(one->GetName(), two->GetName());
}
const char * ParamContent::GetDescription ( ) const

Definition at line 126 of file paramsd.cpp.

                                               {
  if (param_type_ == VT_INTEGER) { return iIt->info_str(); }
  else if (param_type_ == VT_BOOLEAN) { return bIt->info_str(); }
  else if (param_type_ == VT_DOUBLE) { return dIt->info_str(); }
  else if (param_type_ == VT_STRING) { return sIt->info_str(); }
  else return NULL;
}
int ParamContent::GetId ( ) [inline]

Definition at line 69 of file paramsd.h.

{ return my_id_; }
const char * ParamContent::GetName ( ) const

Definition at line 116 of file paramsd.cpp.

                                        {
  if (param_type_ == VT_INTEGER) { return iIt->name_str(); }
  else if (param_type_ == VT_BOOLEAN) { return bIt->name_str(); }
  else if (param_type_ == VT_DOUBLE) { return dIt->name_str(); }
  else if (param_type_ == VT_STRING) { return sIt->name_str(); }
  else
    return "ERROR: ParamContent::GetName()";
}
ParamContent * ParamContent::GetParamContentById ( int  id) [static]

Definition at line 91 of file paramsd.cpp.

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

Definition at line 135 of file paramsd.cpp.

                                         {
char* msg = new char[1024];
  if (param_type_ == VT_INTEGER) {
    sprintf(msg, "%d", ((inT32) *(iIt)));
  } else if (param_type_ == VT_BOOLEAN) {
    sprintf(msg, "%d", ((BOOL8) * (bIt)));
  } else if (param_type_ == VT_DOUBLE) {
    sprintf(msg, "%g", ((double) * (dIt)));
  } else if (param_type_ == VT_STRING) {
    if (((STRING) * (sIt)).string() != NULL) {
      sprintf(msg, "%s", ((STRING) * (sIt)).string());
    } else {
      sprintf(msg, "Null");
    }
  }
  return msg;
}
bool ParamContent::HasChanged ( ) [inline]

Definition at line 70 of file paramsd.h.

{ return changed_; }
void ParamContent::SetValue ( const char *  val)

Definition at line 154 of file paramsd.cpp.

                                           {
// TODO (wanke) Test if the values actually are properly converted.
// (Quickly visible impacts?)
  changed_ = TRUE;
  if (param_type_ == VT_INTEGER) {
    iIt->set_value(atoi(val));
  } else if (param_type_ == VT_BOOLEAN) {
    bIt->set_value(atoi(val));
  } else if (param_type_ == VT_DOUBLE) {
    dIt->set_value(strtod(val, NULL));
  } else if (param_type_ == VT_STRING) {
    sIt->set_value(val);
  }
}

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