41 #ifndef BPP_NUMERIC_PARAMETER_H
42 #define BPP_NUMERIC_PARAMETER_H
45 #include "../Clonable.h"
99 virtual const std::string&
getId()
const = 0;
161 Parameter(
const std::string& name,
double value, std::shared_ptr<Constraint> constraint = 0,
double precision = 0);
163 Parameter(
const std::string& name,
double value, std::shared_ptr<Constraint> constraint,
bool precision) =
delete;
197 virtual void setValue(
double value);
267 virtual void setConstraint(std::shared_ptr<Constraint> constraint);
302 for (std::vector<ParameterListener*>::iterator it =
listeners_.begin(); it !=
listeners_.end(); it++)
304 (*it)->parameterNameChanged(event);
310 for (std::vector<ParameterListener*>::iterator it =
listeners_.begin(); it !=
listeners_.end(); it++)
312 (*it)->parameterValueChanged(event);
318 for (std::vector<ParameterListener*>::iterator it =
listeners_.begin(); it !=
listeners_.end(); it++)
320 (*it)->parameterConstraintChanged(event);
325 static const std::shared_ptr<IntervalConstraint>
R_PLUS;
327 static const std::shared_ptr<IntervalConstraint>
R_MINUS;
The Clonable interface (allow an object to be cloned).
ParameterEvent * clone() const
Create a copy of this object and send a pointer to it.
ParameterEvent & operator=(const ParameterEvent &pe)
ParameterEvent(const ParameterEvent &pe)
const Parameter * getParameter() const
ParameterEvent(Parameter *parameter)
Parameter * getParameter()
The parameter listener interface.
ParameterListener * clone() const =0
Create a copy of this object and send a pointer to it.
virtual void parameterNameChanged(ParameterEvent &event)=0
Notify a renaming action.
virtual const std::string & getId() const =0
virtual void parameterValueChanged(ParameterEvent &event)=0
Notify a value change.
virtual void parameterConstraintChanged(ParameterEvent &event)=0
Notify a constraint change.
This class is designed to facilitate the manipulation of parameters.
virtual void removeParameterListener(const std::string &listenerId)
Remove all listeners with a given id from this parameter.
virtual void setValue(double value)
Set the value of this parameter.
virtual std::shared_ptr< Constraint > removeConstraint()
Remove the constraint associated to this parameter.
std::vector< ParameterListener * > listeners_
virtual const std::shared_ptr< Constraint > getConstraint() const
Return the constraint associated to this parameter if there is one.
static const std::shared_ptr< IntervalConstraint > R_PLUS
static const std::shared_ptr< IntervalConstraint > R_MINUS
std::vector< bool > listenerAttach_
std::shared_ptr< Constraint > constraint_
Parameter(const std::string &name, double value, std::shared_ptr< Constraint > constraint, bool precision)=delete
void fireParameterNameChanged(ParameterEvent &event)
virtual std::shared_ptr< Constraint > getConstraint()
Return the constraint associated to this parameter if there is one.
virtual bool hasParameterListener(const std::string &listenerId)
Tell is there is a listener with a given id from this parameter.
virtual double getPrecision() const
Get the precision of this parameter.
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_IN
virtual double getValue() const
Get the value of this parameter.
virtual void setName(const std::string &name)
Set the name of this parameter.
Parameter * clone() const
Create a copy of this object and send a pointer to it.
virtual void setConstraint(std::shared_ptr< Constraint > constraint)
Set a constraint to this parameter.
void setPrecision(double precision)
Set the precision of this parameter.
static const std::shared_ptr< IntervalConstraint > R_MINUS_STAR
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_EX
static const std::shared_ptr< IntervalConstraint > R_PLUS_STAR
virtual void addParameterListener(ParameterListener *listener, bool attachListener=true)
Add a new listener to this parameter.
virtual const std::string & getName() const
Get the name of this parameter.
Parameter & operator=(const Parameter ¶m)
Assignment operator.
virtual bool hasConstraint() const
Tells if this parameter has a constraint.
void fireParameterConstraintChanged(ParameterEvent &event)
void fireParameterValueChanged(ParameterEvent &event)
Parameter()
Default contructor. Creates a parameter with no name, no constraint, and a value of 0.