bpp-core  2.1.0
 All Classes Namespaces Files Functions Variables Typedefs Friends
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 
181  virtual void addParameter(const Parameter& param) throw (ParameterException);
182 
192  virtual void addParameter(Parameter* param) throw (ParameterException);
193 
201  virtual void setParameter(size_t index, const Parameter& param) throw (IndexOutOfBoundsException);
202 
208  virtual void addParameters(const ParameterList& params) throw (ParameterException);
209 
217  virtual void includeParameters(const ParameterList& params);
218 
227  virtual void setParameterValue(const std::string& name, double value)
229 
241  virtual void setAllParametersValues(const ParameterList& params)
243 
252  virtual void setParametersValues(const ParameterList& params);
253 
259  virtual bool hasParameter(const std::string& name) const;
260 
269  virtual bool testParametersValues(const ParameterList& params) const;
270 
280  virtual bool matchParametersValues(const ParameterList& params)
281  throw (ConstraintException);
282 
292  virtual void setAllParameters(const ParameterList& params)
294 
303  virtual void setParameters(const ParameterList& params)
305 
314  virtual void matchParameters(const ParameterList& params);
315 
321  virtual void deleteParameter(const std::string& name) throw (ParameterNotFoundException);
322 
328  virtual void deleteParameters(const std::vector<std::string>& names) throw (ParameterNotFoundException);
329 
335  virtual void deleteParameter(size_t index) throw (IndexOutOfBoundsException);
336 
343  virtual void deleteParameters(const std::vector<size_t>& indices) throw (IndexOutOfBoundsException);
344 
353  virtual size_t whichParameterHasName(const std::string& name) const throw (ParameterNotFoundException);
354 
358  virtual void printParameters(OutputStream& out) const;
359 
360  virtual void printParameters(std::ostream& out) const
361  {
362  StlOutputStreamWrapper os(&out);
363  printParameters(os);
364  }
365 
369  virtual void reset();
370 };
371 } // end of namespace bpp.
372 
373 #endif // _PARAMETERLIST_H_
374