iRoCS Toolbox  1.1.0
GridAxis.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: one axis for grid search
26 ** $RCSfile$
27 ** $Revision: 4820 $$Name$
28 ** $Date: 2011-11-08 10:57:01 +0100 (Tue, 08 Nov 2011) $
29 ** Copyright: GPL $Author: tschmidt $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.1 2004/08/26 08:36:58 ronneber
38 ** initital import
39 **
40 **
41 **
42 **************************************************************************/
43 
44 #ifndef GRIDAXIS_HH
45 #define GRIDAXIS_HH
46 
47 #ifdef HAVE_CONFIG_H
48 #include <config.hh>
49 #endif
50 
51 #include <string>
52 #include <vector>
53 #include <stdlib.h>
54 #include <cstddef>
55 
56 #include "SVMError.hh"
57 
58 namespace svt
59 {
60  class GridAxis
61  {
62  public:
64  :_changesKernel(true)
65  {}
66 
67  GridAxis( const std::string& params)
68  {
69  parseString( params);
70  }
71 
72 
73  /*======================================================================*/
91  /*======================================================================*/
92  void parseString( const std::string& params);
93 
94 
95  /*======================================================================*/
101  /*======================================================================*/
102  const std::string& keyName() const
103  {
104  return _keyName;
105  }
106 
107  /*======================================================================*/
113  /*======================================================================*/
114  size_t nValues() const
115  {
116  return _values.size();
117  }
118 
119  /*======================================================================*/
127  /*======================================================================*/
128  double value( size_t index) const
129  {
130  return _values[index];
131  }
132 
133  /*======================================================================*/
142  /*======================================================================*/
143  void setChangesKernel( bool f)
144  {
145  _changesKernel = f;
146  }
147 
148  /*======================================================================*/
154  /*======================================================================*/
155  bool changesKernel() const
156  {
157  return _changesKernel;
158  }
159 
160 
161  private:
162  double stringToDouble( const std::string& s, const std::string& param)
163  {
164  char* endptr;
165  double v = strtod( s.c_str(), &endptr);
166  size_t nInterpretedChars = static_cast<size_t>(endptr - s.c_str());
167  if(nInterpretedChars < s.size())
168  {
169  ParseError err;
170  err << "Could not convert '" << s << "' in '" << param << "' to double number\n";
171  throw err;
172  }
173  return v;
174 
175  }
176 
177 
178 
179 
180 
181  std::string _keyName;
182  std::vector<double> _values;
183  bool _changesKernel;
184 
185  };
186 }
187 
188 
189 #endif
const std::string & keyName() const
Name of key belonging to this axis.
Definition: GridAxis.hh:102
void parseString(const std::string &params)
parse specification for grid axis from string.
double value(size_t index) const
value[index]
Definition: GridAxis.hh:128
bool changesKernel() const
see setChangesKernel() for Details
Definition: GridAxis.hh:155
void setChangesKernel(bool f)
specify, wether kernel is affected from this key or not.
Definition: GridAxis.hh:143
size_t nValues() const
number of values that belong to this axis
Definition: GridAxis.hh:114
GridAxis(const std::string &params)
Definition: GridAxis.hh:67