bpp-core3  3.0.0
Parametrizable.h
Go to the documentation of this file.
1 //
2 // File: Parametrizable.h
3 // Authors:
4 // Julien Dutheil
5 // Created: 2003-10-19 23:06:42
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 19, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for numerical calculus.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_NUMERIC_PARAMETRIZABLE_H
42 #define BPP_NUMERIC_PARAMETRIZABLE_H
43 
44 
45 
46 // From Utils:
47 #include "../Clonable.h"
48 
49 // From the STL:
50 #include <string>
51 
52 #include "ParameterList.h"
53 
54 namespace bpp
55 {
62  public virtual Clonable
63 {
64 public:
66  virtual ~Parametrizable() {}
67 
68 public:
75  virtual bool hasParameter(const std::string& name) const = 0;
76 
83  virtual const ParameterList& getParameters() const = 0;
84 
92  virtual const Parameter& getParameter(const std::string& name) const = 0;
93 
100  virtual double getParameterValue(const std::string& name) const
101  = 0;
102 
114  virtual void setAllParametersValues(const ParameterList& parameters) = 0;
115 
125  virtual void setParameterValue(const std::string& name, double value) = 0;
126 
137  virtual void setParametersValues(const ParameterList& parameters) = 0;
138 
149  virtual bool matchParametersValues(const ParameterList& parameters) = 0;
150 
157  virtual size_t getNumberOfParameters() const = 0;
158 
165  virtual void setNamespace(const std::string& prefix) = 0;
166 
170  virtual std::string getNamespace() const = 0;
171 
177  virtual std::string getParameterNameWithoutNamespace(const std::string& name) const = 0;
178 
179 protected:
188 };
189 
196  public virtual Parametrizable
197 {
198 protected:
201 
202 public:
205 
206 public:
212  bool hasParameter(const std::string& name) const { return parameters_.hasParameter(name); }
213  const ParameterList& getParameters() const { return parameters_; }
214  const Parameter& getParameter(const std::string& name) const { return parameter_; }
215  double getParameterValue(const std::string& name) const { return 0; }
216  void setAllParametersValues(const ParameterList& parameters) {}
217  void setParameterValue(const std::string& name, double value) {}
218  void setParametersValues(const ParameterList& parameters) {}
219  bool matchParametersValues(const ParameterList& parameters) { return false; }
220  size_t getNumberOfParameters() const { return 0; }
221  void setNamespace(const std::string& prefix) {}
222  std::string getNamespace() const { return ""; }
223  std::string getParameterNameWithoutNamespace(const std::string& name) const { return name; }
225 };
226 } // end of namespace bpp.
227 #endif // BPP_NUMERIC_PARAMETRIZABLE_H
The Clonable interface (allow an object to be cloned).
Definition: Clonable.h:103
The parameter list object.
Definition: ParameterList.h:65
virtual bool hasParameter(const std::string &name) const
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:135
A low-level implementation of the Parametrizable interface with void functions.
void setParametersValues(const ParameterList &parameters)
Update the parameters from parameters.
bool hasParameter(const std::string &name) const
Tell if there is a parameter with specified name.
size_t getNumberOfParameters() const
Get the number of parameters.
std::string getNamespace() const
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 'name'.
void setNamespace(const std::string &prefix)
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.
const ParameterList & getParameters() const
Get all parameters available.
bool matchParametersValues(const ParameterList &parameters)
Update the parameters from parameters.
const Parameter & getParameter(const std::string &name) const
Get the parameter with specified name.
This is the interface for all objects that imply parameters.
virtual std::string getParameterNameWithoutNamespace(const std::string &name) const =0
Resolves a parameter name according to the current namespace.
virtual size_t getNumberOfParameters() const =0
Get the number of parameters.
virtual ~Parametrizable()
virtual bool matchParametersValues(const ParameterList &parameters)=0
Update the parameters from parameters.
virtual std::string getNamespace() const =0
virtual void setAllParametersValues(const ParameterList &parameters)=0
Set the parameters values to be equals to those of parameters.
virtual double getParameterValue(const std::string &name) const =0
Get the value for parameter of name 'name'.
virtual const Parameter & getParameter(const std::string &name) const =0
Get the parameter with specified name.
virtual const ParameterList & getParameters() const =0
Get all parameters available.
virtual ParameterList & getParameters_()=0
Get all parameters available.
virtual bool hasParameter(const std::string &name) const =0
Tell if there is a parameter with specified name.
virtual void setParameterValue(const std::string &name, double value)=0
Set the value of parameter with name name to be equal to value.
virtual void setParametersValues(const ParameterList &parameters)=0
Update the parameters from parameters.
virtual void setNamespace(const std::string &prefix)=0
Set the namespace for the parameter names.