46 #include "../Text/TextTools.h"
59 Parameter::Parameter(
const std::string& name,
double value, std::shared_ptr<Constraint> constraint,
double precision) :
60 name_(name), value_(0), precision_(0), constraint_(constraint), listeners_(), listenerAttach_()
69 precision_(p.precision_),
70 constraint_(p.constraint_ ? std::shared_ptr<
Constraint>(p.constraint_->clone()) : 0),
71 listeners_(p.listeners_),
72 listenerAttach_(p.listenerAttach_)
101 for (
size_t i = 0; i <
listeners_.size(); i++)
133 if (constraint != 0 && !constraint->isCorrect(
value_))
151 for (
unsigned int i = 0; i <
listeners_.size(); i++)
167 for (
unsigned int i = 0; i <
listeners_.size(); i++)
Exception thrown when a value do not match a given constraint.
The constraint interface.
An interval, either bounded or not, which can also have infinite bounds.
ParameterEvent(Parameter *parameter)
The parameter listener interface.
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_
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_
virtual bool hasParameterListener(const std::string &listenerId)
Tell is there is a listener with a given id from this parameter.
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_IN
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
Parameter & operator=(const Parameter ¶m)
Assignment operator.
void fireParameterValueChanged(ParameterEvent &event)
Parameter()
Default contructor. Creates a parameter with no name, no constraint, and a value of 0.