bpp-core3  3.0.0
ParameterExceptions.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_NUMERIC_PARAMETEREXCEPTIONS_H
6 #define BPP_NUMERIC_PARAMETEREXCEPTIONS_H
7 
8 
9 // From Utils:
10 #include "../Exceptions.h"
11 
12 // From the STL:
13 #include <string>
14 
15 namespace bpp
16 {
17 class Parameter;
18 
25  public Exception
26 {
27 private:
29 
30 public:
31  // Class constructors and destructor:
38  ParameterException(const std::string& text, const Parameter* param);
39 
41  Exception(pe),
42  parameter_(pe.parameter_) {} // We explicitely do not want to make a hard copy of the pointer here.
43 
45  {
46  Exception::operator=(pe);
47  parameter_ = pe.parameter_;
48  return *this;
49  }
50 
51  virtual ~ParameterException() {}
52 
53 public:
59  virtual const Parameter* parameter() const;
60 };
61 
68 {
69 private:
70  double badValue_;
71 
72 public:
73  // Class constructor and destructor:
81  ConstraintException(const std::string& text, const Parameter* param, double badValue);
82 
83  virtual ~ConstraintException() {}
84 
85 public:
91  virtual double getBadValue() const;
92 };
93 
94 /*******************************************************************************/
95 
101 {
102 private:
103  const std::string parameter_;
104 
105 public:
106  // Class constructors and destructor:
113  ParameterNotFoundException(const std::string& text, const std::string& param = "");
114 
116 
117 public:
123  virtual std::string parameter() const;
124 };
125 } // end of namespace bpp.
126 #endif // BPP_NUMERIC_PARAMETEREXCEPTIONS_H
Exception thrown when a parameter is not found, for instance in a ParameterList.
ParameterException & operator=(const ParameterException &pe)
ParameterException(const std::string &text, const Parameter *param)
Build a new ParameterException object.
virtual const Parameter * parameter() const
Get the parameter that threw the exception.
const Parameter * parameter_
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:97
ParameterException(const ParameterException &pe)
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Definition: Exceptions.h:20
Exception thrown when a value do not match a given constraint.
The parameter exception base class.