bpp-core  2.2.0
Parametrizable.h
Go to the documentation of this file.
1 //
2 // File: Parametrizable.h
3 // Created by: Julien Dutheil
4 // Created on: Sun Oct 19 23:06:42 2003
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 19, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for numerical calculus.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _PARAMETRIZABLE_H_
41 #define _PARAMETRIZABLE_H_
42 
43 // From Utils:
44 #include "../Clonable.h"
45 
46 // From the STL:
47 #include <string>
48 
49 #include "ParameterList.h"
50 
51 namespace bpp
52 {
53 
60  public virtual Clonable
61 {
62  public:
64  virtual ~Parametrizable() {}
65 
66  public:
73  virtual bool hasParameter(const std::string& name) const = 0;
74 
81  virtual const ParameterList& getParameters() const = 0;
82 
90  virtual const Parameter& getParameter(const std::string& name) const throw (ParameterNotFoundException) = 0;
91 
98  virtual double getParameterValue(const std::string& name) const
99  throw (ParameterNotFoundException) = 0;
100 
112  virtual void setAllParametersValues(const ParameterList& parameters)
114 
124  virtual void setParameterValue(const std::string& name, double value)
126 
137  virtual void setParametersValues(const ParameterList& parameters)
139 
150  virtual bool matchParametersValues(const ParameterList& parameters)
151  throw (ConstraintException) = 0;
152 
159  virtual size_t getNumberOfParameters() const = 0;
160 
167  virtual void setNamespace(const std::string& prefix) = 0;
168 
172  virtual std::string getNamespace() const = 0;
173 
179  virtual std::string getParameterNameWithoutNamespace(const std::string& name) const = 0;
180 
181 };
182 
189  public virtual Parametrizable
190 {
191  protected:
194 
195  public:
198 
199  public:
200 
206  bool hasParameter(const std::string & name) const { return parameters_.hasParameter(name); }
207  const ParameterList & getParameters() const { return parameters_; }
208  const Parameter & getParameter(const std::string & name) const throw (ParameterNotFoundException) { return parameter_; }
209  double getParameterValue(const std::string & name) const
210  throw (ParameterNotFoundException) { return 0; };
211  void setAllParametersValues(const ParameterList & parameters)
213  void setParameterValue(const std::string & name, double value)
215  void setParametersValues(const ParameterList & parameters)
217  bool matchParametersValues(const ParameterList & parameters)
218  throw (ConstraintException) { return false ;}
219  size_t getNumberOfParameters() const{ return 0; }
220  void setNamespace(const std::string& prefix) {}
221  std::string getNamespace() const { return ""; }
222  std::string getParameterNameWithoutNamespace(const std::string& name) const { return name; }
225 };
226 
227 } //end of namespace bpp.
228 
229 #endif //_PARAMETRIZABLE_H_
230 
virtual bool matchParametersValues(const ParameterList &parameters)=0
Update the parameters from parameters.
Exception thrown when a parameter is not found, for instance in a ParameterList.
std::string getNamespace() const
virtual void setParameterValue(const std::string &name, double value)=0
Set the value of parameter with name name to be equal to value.
This class allows to perform a correspondence analysis.
virtual double getParameterValue(const std::string &name) const =0
Get the value for parameter of name &#39;name&#39;.
virtual std::string getNamespace() const =0
size_t getNumberOfParameters() const
Get the number of parameters.
virtual const ParameterList & getParameters() const =0
Get all parameters available.
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:135
virtual void setParametersValues(const ParameterList &parameters)=0
Update the parameters from parameters.
A low-level implementation of the Parametrizable interface with void functions.
This is the interface for all objects that imply parameters.
bool hasParameter(const std::string &name) const
Tell if there is a parameter with specified name.
The parameter list object.
Definition: ParameterList.h:61
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
std::string getParameterNameWithoutNamespace(const std::string &name) const
Resolves a parameter name according to the current namespace.
double getParameterValue(const std::string &name) const
Get the value for parameter of name &#39;name&#39;.
virtual bool hasParameter(const std::string &name) const
virtual void setAllParametersValues(const ParameterList &parameters)=0
Set the parameters values to be equals to those of parameters.
bool matchParametersValues(const ParameterList &parameters)
Update the parameters from parameters.
const ParameterList & getParameters() const
Get all parameters available.
virtual std::string getParameterNameWithoutNamespace(const std::string &name) const =0
Resolves a parameter name according to the current namespace.
void setParametersValues(const ParameterList &parameters)
Update the parameters from parameters.
The Clonable interface (allow an object to be cloned).
Definition: Clonable.h:99
virtual ~Parametrizable()
virtual const Parameter & getParameter(const std::string &name) const =0
Get the parameter with specified name.
Exception thrown when a value do not match a given constraint.
virtual void setNamespace(const std::string &prefix)=0
Set the namespace for the parameter names.
void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
void setAllParametersValues(const ParameterList &parameters)
Set the parameters values to be equals to those of parameters.
virtual bool hasParameter(const std::string &name) const =0
Tell if there is a parameter with specified name.
const Parameter & getParameter(const std::string &name) const
Get the parameter with specified name.
virtual size_t getNumberOfParameters() const =0
Get the number of parameters.