bpp-core  2.1.0
ParameterList.h
Go to the documentation of this file.
00001 //
00002 // File: ParameterList.h
00003 // Created by: Julien Dutheil
00004 // Created on: Wed Oct 15 18:17:29 2003
00005 //
00006 
00007 /*
00008    Copyright or © or Copr. Bio++ Development Team, (November 19, 2004)
00009 
00010    This software is a computer program whose purpose is to provide classes
00011    for numerical calculus.
00012 
00013    This software is governed by the CeCILL  license under French law and
00014    abiding by the rules of distribution of free software.  You can  use,
00015    modify and/ or redistribute the software under the terms of the CeCILL
00016    license as circulated by CEA, CNRS and INRIA at the following URL
00017    "http://www.cecill.info".
00018 
00019    As a counterpart to the access to the source code and  rights to copy,
00020    modify and redistribute granted by the license, users are provided only
00021    with a limited warranty  and the software's author,  the holder of the
00022    economic rights,  and the successive licensors  have only  limited
00023    liability.
00024 
00025    In this respect, the user's attention is drawn to the risks associated
00026    with loading,  using,  modifying and/or developing or reproducing the
00027    software by the user in light of its specific status of free software,
00028    that may mean  that it is complicated to manipulate,  and  that  also
00029    therefore means  that it is reserved for developers  and  experienced
00030    professionals having in-depth computer knowledge. Users are therefore
00031    encouraged to load and test the software's suitability as regards their
00032    requirements in conditions enabling the security of their systems and/or
00033    data to be ensured and,  more generally, to use and operate it in the
00034    same conditions as regards security.
00035 
00036    The fact that you are presently reading this means that you have had
00037    knowledge of the CeCILL license and that you accept its terms.
00038  */
00039 
00040 #ifndef _PARAMETERLIST_H_
00041 #define _PARAMETERLIST_H_
00042 
00043 #include "Parameter.h"
00044 #include "../Clonable.h"
00045 #include "../Io/OutputStream.h"
00046 
00047 // From STL:
00048 #include <vector>
00049 #include <string>
00050 #include <iostream>
00051 
00052 namespace bpp
00053 {
00061 class ParameterList :
00062   public Clonable
00063 {
00064 private:
00065   std::vector<Parameter*> parameters_;
00066 
00067 public:
00071   ParameterList() : parameters_() {}
00072 
00078   ParameterList(const ParameterList& pl);
00079 
00080   ParameterList& operator=(const ParameterList& pl);
00081 
00082   ParameterList* clone() const { return new ParameterList(*this); }
00083 
00084   virtual ~ParameterList();
00085 
00086 public:
00090   size_t size() const { return parameters_.size(); }
00091 
00096   virtual const Parameter& operator[](size_t i) const { return *parameters_[i]; }
00097   virtual Parameter& operator[](size_t i) { return *parameters_[i]; }
00098 
00106   virtual const Parameter& getParameter(const std::string& name) const throw (ParameterNotFoundException);
00107 
00116   virtual double getParameterValue(const std::string& name) const throw (ParameterNotFoundException);
00117 
00125   virtual Parameter& getParameter(const std::string& name) throw (ParameterNotFoundException);
00126 
00134   virtual ParameterList subList(const std::vector<std::string>& names) const throw (ParameterNotFoundException);
00135 
00143   virtual ParameterList subList(const std::string& name) const throw (ParameterNotFoundException);
00144 
00151   virtual ParameterList subList(const std::vector<size_t>& parameters) const;
00152 
00159   virtual ParameterList subList(size_t parameter) const;
00160 
00167   virtual ParameterList getCommonParametersWith(const ParameterList& params) const;
00168 
00174   virtual std::vector<std::string> getParameterNames() const;
00175 
00184   virtual std::vector<std::string> getMatchingParameterNames(const std::string& pattern) const;
00185 
00191   virtual void addParameter(const Parameter& param) throw (ParameterException);
00192 
00202   virtual void addParameter(Parameter* param) throw (ParameterException);
00203 
00211   virtual void setParameter(size_t index, const Parameter& param) throw (IndexOutOfBoundsException);
00212 
00218   virtual void addParameters(const ParameterList& params) throw (ParameterException);
00219 
00227   virtual void includeParameters(const ParameterList& params);
00228 
00237   virtual void setParameterValue(const std::string& name, double value)
00238     throw (ParameterNotFoundException, ConstraintException);
00239 
00251   virtual void setAllParametersValues(const ParameterList& params)
00252     throw (ParameterNotFoundException, ConstraintException);
00253 
00262   virtual void setParametersValues(const ParameterList& params);
00263 
00269   virtual bool hasParameter(const std::string& name) const;
00270 
00279   virtual bool testParametersValues(const ParameterList& params) const;
00280 
00290   virtual bool matchParametersValues(const ParameterList& params)
00291     throw (ConstraintException);
00292 
00302   virtual void setAllParameters(const ParameterList& params)
00303     throw (ParameterNotFoundException);
00304 
00313   virtual void setParameters(const ParameterList& params)
00314     throw (ParameterNotFoundException);
00315 
00324   virtual void matchParameters(const ParameterList& params);
00325 
00331   virtual void deleteParameter(const std::string& name) throw (ParameterNotFoundException);
00332 
00338   virtual void deleteParameters(const std::vector<std::string>& names) throw (ParameterNotFoundException);
00339 
00345   virtual void deleteParameter(size_t index) throw (IndexOutOfBoundsException);
00346 
00353   virtual void deleteParameters(const std::vector<size_t>& indices) throw (IndexOutOfBoundsException);
00354 
00363   virtual size_t whichParameterHasName(const std::string& name) const throw (ParameterNotFoundException);
00364 
00368   virtual void printParameters(OutputStream& out) const;
00369 
00370   virtual void printParameters(std::ostream& out) const
00371   {
00372     StlOutputStreamWrapper os(&out);
00373     printParameters(os);
00374   }
00375 
00379   virtual void reset();
00380 };
00381 } // end of namespace bpp.
00382 
00383 #endif  // _PARAMETERLIST_H_
00384 
 All Classes Namespaces Files Functions Variables Typedefs Friends