5 #ifndef BPP_NUMERIC_PARAMETER_H 6 #define BPP_NUMERIC_PARAMETER_H 9 #include "../Clonable.h" 63 virtual const std::string& getId()
const = 0;
84 virtual void parameterConstraintChanged(
ParameterEvent& event) = 0;
113 Parameter() : name_(
""), value_(0), precision_(0), constraint_(0), listeners_() {}
124 Parameter(
const std::string& name,
double value, std::shared_ptr<ConstraintInterface> constraint = 0,
double precision = 0);
126 Parameter(
const std::string& name,
double value, std::shared_ptr<ConstraintInterface> constraint,
bool precision) =
delete;
152 fireParameterNameChanged(event);
160 virtual void setValue(
double value);
167 void setPrecision(
double precision);
174 virtual const std::string&
getName()
const {
return name_; }
196 virtual std::shared_ptr<const ConstraintInterface>
getConstraint()
const {
return constraint_; }
208 throw NullPointerException(
"Parameter::constraint(). No contraint is associated to this parameter.");
218 virtual std::shared_ptr<ConstraintInterface>
getConstraint() {
return constraint_; }
230 throw NullPointerException(
"Parameter::constraint(). No contraint is associated to this parameter.");
247 virtual std::shared_ptr<ConstraintInterface> removeConstraint();
254 virtual void setConstraint(std::shared_ptr<ConstraintInterface> constraint);
263 listeners_.push_back(listener);
271 virtual void removeParameterListener(
const std::string& listenerId);
279 virtual bool hasParameterListener(
const std::string& listenerId);
284 for (
auto listener : listeners_)
286 listener->parameterNameChanged(event);
292 for (
auto listener : listeners_)
294 listener->parameterValueChanged(event);
300 for (
auto listener : listeners_)
302 listener->parameterConstraintChanged(event);
307 static const std::shared_ptr<IntervalConstraint>
R_PLUS;
309 static const std::shared_ptr<IntervalConstraint>
R_MINUS;
315 #endif // BPP_NUMERIC_PARAMETER_H
static const std::shared_ptr< IntervalConstraint > R_PLUS
The parameter listener interface.
Parameter * clone() const
Create a copy of this object and send a pointer to it.
Parameter()
Default contructor. Creates a parameter with no name, no constraint, and a value of 0...
virtual std::shared_ptr< ConstraintInterface > getConstraint()
Return the constraint associated to this parameter if there is one.
virtual void addParameterListener(std::shared_ptr< ParameterListener > listener)
Add a new listener to this parameter.
std::vector< std::shared_ptr< ParameterListener > > listeners_
ParameterEvent(Parameter *parameter)
The constraint interface.
void fireParameterValueChanged(ParameterEvent &event)
This class is designed to facilitate the manipulation of parameters.
ParameterEvent(const ParameterEvent &pe)
const Parameter * parameter() const
virtual bool hasConstraint() const
Tells if this parameter has a constraint.
virtual std::shared_ptr< const ConstraintInterface > getConstraint() const
Return the constraint associated to this parameter if there is one.
static const std::shared_ptr< IntervalConstraint > R_MINUS
static const std::shared_ptr< IntervalConstraint > R_MINUS_STAR
ParameterEvent * clone() const
Create a copy of this object and send a pointer to it.
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_EX
void fireParameterConstraintChanged(ParameterEvent &event)
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_IN
The base class exception for NULL pointer error. This exception may be thrown when an unexpected NULL...
virtual const std::string & getName() const
Get the name of this parameter.
virtual void setName(const std::string &name)
Set the name of this parameter.
The Clonable interface (allow an object to be cloned).
virtual ConstraintInterface & constraint()
Return the constraint associated to this parameter if there is one.
std::shared_ptr< ConstraintInterface > constraint_
virtual double getValue() const
Get the value of this parameter.
virtual const ConstraintInterface & constraint() const
Return the constraint associated to this parameter if there is one.
void fireParameterNameChanged(ParameterEvent &event)
virtual double getPrecision() const
Get the precision of this parameter.
ParameterEvent & operator=(const ParameterEvent &pe)
static const std::shared_ptr< IntervalConstraint > R_PLUS_STAR