bpp-core  2.2.0
ParameterList.h
Go to the documentation of this file.
1 //
2 // File: ParameterList.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Oct 15 18:17:29 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 _PARAMETERLIST_H_
41 #define _PARAMETERLIST_H_
42 
43 #include "Parameter.h"
44 #include "../Clonable.h"
45 #include "../Io/OutputStream.h"
46 
47 // From STL:
48 #include <vector>
49 #include <string>
50 #include <iostream>
51 
52 namespace bpp
53 {
62  public Clonable
63 {
64 private:
65  std::vector<Parameter*> parameters_;
66 
67 public:
72 
78  ParameterList(const ParameterList& pl);
79 
81 
82  ParameterList* clone() const { return new ParameterList(*this); }
83 
84  virtual ~ParameterList();
85 
86 public:
90  size_t size() const { return parameters_.size(); }
91 
96  virtual const Parameter& operator[](size_t i) const { return *parameters_[i]; }
97  virtual Parameter& operator[](size_t i) { return *parameters_[i]; }
98 
106  virtual const Parameter& getParameter(const std::string& name) const throw (ParameterNotFoundException);
107 
116  virtual double getParameterValue(const std::string& name) const throw (ParameterNotFoundException);
117 
125  virtual Parameter& getParameter(const std::string& name) throw (ParameterNotFoundException);
126 
134  virtual ParameterList subList(const std::vector<std::string>& names) const throw (ParameterNotFoundException);
135 
143  virtual ParameterList subList(const std::string& name) const throw (ParameterNotFoundException);
144 
151  virtual ParameterList subList(const std::vector<size_t>& parameters) const;
152 
159  virtual ParameterList subList(size_t parameter) const;
160 
167  virtual ParameterList getCommonParametersWith(const ParameterList& params) const;
168 
174  virtual std::vector<std::string> getParameterNames() const;
175 
184  virtual std::vector<std::string> getMatchingParameterNames(const std::string& pattern) const;
185 
191  virtual void addParameter(const Parameter& param) throw (ParameterException);
192 
202  virtual void addParameter(Parameter* param) throw (ParameterException);
203 
211  virtual void setParameter(size_t index, const Parameter& param) throw (IndexOutOfBoundsException);
212 
218  virtual void addParameters(const ParameterList& params) throw (ParameterException);
219 
227  virtual void includeParameters(const ParameterList& params);
228 
237  virtual void setParameterValue(const std::string& name, double value)
239 
251  virtual void setAllParametersValues(const ParameterList& params)
253 
262  virtual void setParametersValues(const ParameterList& params);
263 
269  virtual bool hasParameter(const std::string& name) const;
270 
279  virtual bool testParametersValues(const ParameterList& params) const;
280 
294  virtual bool matchParametersValues(const ParameterList& params, std::vector<size_t>* updatedParameters = 0)
295  throw (ConstraintException);
296 
306  virtual void setAllParameters(const ParameterList& params)
308 
317  virtual void setParameters(const ParameterList& params)
319 
328  virtual void matchParameters(const ParameterList& params);
329 
335  virtual void deleteParameter(const std::string& name) throw (ParameterNotFoundException);
336 
345  virtual void deleteParameters(const std::vector<std::string>& names, bool mustExist = true) throw (ParameterNotFoundException);
346 
352  virtual void deleteParameter(size_t index) throw (IndexOutOfBoundsException);
353 
360  virtual void deleteParameters(const std::vector<size_t>& indices) throw (IndexOutOfBoundsException);
361 
370  virtual size_t whichParameterHasName(const std::string& name) const throw (ParameterNotFoundException);
371 
375  virtual void printParameters(OutputStream& out) const;
376 
377  virtual void printParameters(std::ostream& out) const
378  {
379  StlOutputStreamWrapper os(&out);
380  printParameters(os);
381  }
382 
386  virtual void reset();
387 };
388 } // end of namespace bpp.
389 
390 #endif // _PARAMETERLIST_H_
391 
virtual const Parameter & operator[](size_t i) const
Definition: ParameterList.h:96
Exception thrown when a parameter is not found, for instance in a ParameterList.
virtual ~ParameterList()
virtual ParameterList subList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
virtual void includeParameters(const ParameterList &params)
Add parameters to the list. If the parameter already exists, only the value is updated, otherwise the new parameter is added at the end of the list.
virtual bool testParametersValues(const ParameterList &params) const
Tests the parameters from params.
virtual void reset()
Reset the list: delete all parameters.
virtual std::vector< std::string > getMatchingParameterNames(const std::string &pattern) const
Get all parameter names matching with the given name. Up to now, only "*" jokers are available...
virtual double getParameterValue(const std::string &name) const
Get the value of the parameter with name name.
This class allows to perform a correspondence analysis.
virtual bool matchParametersValues(const ParameterList &params, std::vector< size_t > *updatedParameters=0)
Update the parameters from params.
virtual void setAllParameters(const ParameterList &params)
Set the parameters to be equals to params.
virtual void deleteParameters(const std::vector< std::string > &names, bool mustExist=true)
Delete several parameters from the list.
ParameterList & operator=(const ParameterList &pl)
ParameterList()
Build a new ParameterList object.
Definition: ParameterList.h:71
size_t size() const
Definition: ParameterList.h:90
STL namespace.
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:135
virtual void setAllParametersValues(const ParameterList &params)
Set the parameters to be equals to params.
virtual void deleteParameter(const std::string &name)
Delete a parameter from the list.
virtual void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
virtual ParameterList getCommonParametersWith(const ParameterList &params) const
Get the sublist containing all common parameter between this list and pl.
virtual Parameter & operator[](size_t i)
Definition: ParameterList.h:97
The parameter list object.
Definition: ParameterList.h:61
virtual void addParameters(const ParameterList &params)
Add new parameters at the end of the list.
virtual std::vector< std::string > getParameterNames() const
Get all parameter names in the list.
ParameterList * clone() const
Create a copy of this object and send a pointer to it.
Definition: ParameterList.h:82
virtual bool hasParameter(const std::string &name) const
virtual size_t whichParameterHasName(const std::string &name) const
Get the position of a given parameter according to its name.
OutputStream interface.
Definition: OutputStream.h:64
virtual void setParameter(size_t index, const Parameter &param)
Change given parameter.
virtual void setParameters(const ParameterList &params)
Update the parameters from params.
virtual void addParameter(const Parameter &param)
Add a new parameter at the end of the list.
STL wrapper for output stream.
Definition: OutputStream.h:221
The Clonable interface (allow an object to be cloned).
Definition: Clonable.h:99
virtual void matchParameters(const ParameterList &params)
Update the parameters from params.
virtual const Parameter & getParameter(const std::string &name) const
Get the parameter with name name.
virtual void printParameters(OutputStream &out) const
Print all parameters.
std::vector< Parameter * > parameters_
Definition: ParameterList.h:65
Exception thrown when a value do not match a given constraint.
Index out of bounds exception class.
Definition: Exceptions.h:298
The parameter exception base class.
virtual void setParametersValues(const ParameterList &params)
Update the parameters from the ones in params that have matching names.