bpp-core3  3.0.0
bpp::Parameter Class Reference

This class is designed to facilitate the manipulation of parameters. More...

#include <Bpp/Numeric/Parameter.h>

+ Inheritance diagram for bpp::Parameter:
+ Collaboration diagram for bpp::Parameter:

Public Member Functions

 Parameter ()
 Default contructor. Creates a parameter with no name, no constraint, and a value of 0. More...
 
 Parameter (const std::string &name, double value, std::shared_ptr< ConstraintInterface > constraint=0, double precision=0)
 Build a new parameter. More...
 
 Parameter (const std::string &name, double value, std::shared_ptr< ConstraintInterface > constraint, bool precision)=delete
 
 Parameter (const Parameter &param)
 Copy constructor. More...
 
Parameteroperator= (const Parameter &param)
 Assignment operator. More...
 
virtual ~Parameter ()
 
Parameterclone () const
 Create a copy of this object and send a pointer to it. More...
 
virtual void setName (const std::string &name)
 Set the name of this parameter. More...
 
virtual void setValue (double value)
 Set the value of this parameter. More...
 
void setPrecision (double precision)
 Set the precision of this parameter. More...
 
virtual const std::string & getName () const
 Get the name of this parameter. More...
 
virtual double getValue () const
 Get the value of this parameter. More...
 
virtual double getPrecision () const
 Get the precision of this parameter. More...
 
virtual std::shared_ptr< const ConstraintInterfacegetConstraint () const
 Return the constraint associated to this parameter if there is one. More...
 
virtual const ConstraintInterfaceconstraint () const
 Return the constraint associated to this parameter if there is one. More...
 
virtual std::shared_ptr< ConstraintInterfacegetConstraint ()
 Return the constraint associated to this parameter if there is one. More...
 
virtual ConstraintInterfaceconstraint ()
 Return the constraint associated to this parameter if there is one. More...
 
virtual bool hasConstraint () const
 Tells if this parameter has a constraint. More...
 
virtual std::shared_ptr< ConstraintInterfaceremoveConstraint ()
 Remove the constraint associated to this parameter. More...
 
virtual void setConstraint (std::shared_ptr< ConstraintInterface > constraint)
 Set a constraint to this parameter. More...
 
virtual void addParameterListener (std::shared_ptr< ParameterListener > listener)
 Add a new listener to this parameter. More...
 
virtual void removeParameterListener (const std::string &listenerId)
 Remove all listeners with a given id from this parameter. More...
 
virtual bool hasParameterListener (const std::string &listenerId)
 Tell is there is a listener with a given id from this parameter. More...
 

Static Public Attributes

static const std::shared_ptr< IntervalConstraintR_PLUS
 
static const std::shared_ptr< IntervalConstraintR_PLUS_STAR
 
static const std::shared_ptr< IntervalConstraintR_MINUS
 
static const std::shared_ptr< IntervalConstraintR_MINUS_STAR
 
static const std::shared_ptr< IntervalConstraintPROP_CONSTRAINT_IN
 
static const std::shared_ptr< IntervalConstraintPROP_CONSTRAINT_EX
 

Protected Member Functions

void fireParameterNameChanged (ParameterEvent &event)
 
void fireParameterValueChanged (ParameterEvent &event)
 
void fireParameterConstraintChanged (ParameterEvent &event)
 

Protected Attributes

std::string name_
 
double value_
 
double precision_
 
std::shared_ptr< ConstraintInterfaceconstraint_
 
std::vector< std::shared_ptr< ParameterListener > > listeners_
 

Detailed Description

This class is designed to facilitate the manipulation of parameters.

A parameter object contains a value stored as a double. It also contains a name and optionaly a constraint. Constraint objects allows to apply restriction on the value of the parameter, for instance positive number, or a particular interval and so on.

See also
ParameterList, Parametrizable, Constraint.

Definition at line 97 of file Parameter.h.

Constructor & Destructor Documentation

◆ Parameter() [1/4]

bpp::Parameter::Parameter ( )
inline

Default contructor. Creates a parameter with no name, no constraint, and a value of 0.

Definition at line 113 of file Parameter.h.

References bpp::ParameterEvent::operator=().

◆ Parameter() [2/4]

Parameter::Parameter ( const std::string &  name,
double  value,
std::shared_ptr< ConstraintInterface constraint = 0,
double  precision = 0 
)

Build a new parameter.

Parameters
nameThe parameter name.
valueThe parameter value.
constraintAn optional pointer toward a constraint Object. The constraint will be copied and attached to this instance.
precisionAn optional parameter precision (default 0)
Exceptions
ConstraintExceptionIf the parameter value does not match the contraint.

Constructors:

Definition at line 24 of file Parameter.cpp.

References setPrecision(), and setValue().

◆ Parameter() [3/4]

bpp::Parameter::Parameter ( const std::string &  name,
double  value,
std::shared_ptr< ConstraintInterface constraint,
bool  precision 
)
delete

◆ Parameter() [4/4]

Parameter::Parameter ( const Parameter param)

Copy constructor.

Definition at line 31 of file Parameter.cpp.

◆ ~Parameter()

Parameter::~Parameter ( )
virtual

Destructor:

Definition at line 51 of file Parameter.cpp.

Member Function Documentation

◆ addParameterListener()

virtual void bpp::Parameter::addParameterListener ( std::shared_ptr< ParameterListener listener)
inlinevirtual

Add a new listener to this parameter.

Parameters
listenerThe listener to add.

Definition at line 261 of file Parameter.h.

Referenced by bpp::AbstractParameterAliasable::aliasParameters().

◆ clone()

Parameter* bpp::Parameter::clone ( ) const
inlinevirtual

◆ constraint() [1/2]

virtual const ConstraintInterface& bpp::Parameter::constraint ( ) const
inlinevirtual

Return the constraint associated to this parameter if there is one.

Returns
A referec toward the constraint if there is one, otherwise throw an exception.

Definition at line 203 of file Parameter.h.

Referenced by setConstraint().

◆ constraint() [2/2]

virtual ConstraintInterface& bpp::Parameter::constraint ( )
inlinevirtual

Return the constraint associated to this parameter if there is one.

Returns
A referec toward the constraint if there is one, otherwise throw an exception.

Definition at line 225 of file Parameter.h.

◆ fireParameterConstraintChanged()

void bpp::Parameter::fireParameterConstraintChanged ( ParameterEvent event)
inlineprotected

Definition at line 298 of file Parameter.h.

◆ fireParameterNameChanged()

void bpp::Parameter::fireParameterNameChanged ( ParameterEvent event)
inlineprotected

Definition at line 282 of file Parameter.h.

◆ fireParameterValueChanged()

void bpp::Parameter::fireParameterValueChanged ( ParameterEvent event)
inlineprotected

Definition at line 290 of file Parameter.h.

Referenced by setValue().

◆ getConstraint() [1/2]

virtual std::shared_ptr<const ConstraintInterface> bpp::Parameter::getConstraint ( ) const
inlinevirtual

Return the constraint associated to this parameter if there is one.

Returns
A shared pointer toward the constraint, or NULL if there is no constraint.

Definition at line 196 of file Parameter.h.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::AliasParameterListener::parameterConstraintChanged(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ getConstraint() [2/2]

virtual std::shared_ptr<ConstraintInterface> bpp::Parameter::getConstraint ( )
inlinevirtual

Return the constraint associated to this parameter if there is one.

Returns
A shared pointer toward the constraint, or NULL if there is no constraint.

Definition at line 218 of file Parameter.h.

◆ getName()

◆ getPrecision()

virtual double bpp::Parameter::getPrecision ( ) const
inlinevirtual

Get the precision of this parameter.

Returns
The precision value.

Definition at line 188 of file Parameter.h.

◆ getValue()

◆ hasConstraint()

virtual bool bpp::Parameter::hasConstraint ( ) const
inlinevirtual

Tells if this parameter has a constraint.

Returns
True if this parameter has a contraint.

Definition at line 238 of file Parameter.h.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ hasParameterListener()

bool Parameter::hasParameterListener ( const std::string &  listenerId)
virtual

Tell is there is a listener with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.
Returns
True if at list one listener with the given id was found.

Definition at line 104 of file Parameter.cpp.

References listeners_, PROP_CONSTRAINT_EX, PROP_CONSTRAINT_IN, R_MINUS, R_MINUS_STAR, R_PLUS, and R_PLUS_STAR.

◆ operator=()

Parameter & Parameter::operator= ( const Parameter param)

Assignment operator.

Definition at line 39 of file Parameter.cpp.

References constraint_, listeners_, name_, precision_, and value_.

Referenced by bpp::AutoParameter::operator=().

◆ removeConstraint()

std::shared_ptr< ConstraintInterface > Parameter::removeConstraint ( )
virtual

Remove the constraint associated to this parameter.

Warning! The contraint objet is not deleted.

Returns
A pointer toward the formerly used contraint.

Definition at line 85 of file Parameter.cpp.

References constraint_.

Referenced by bpp::AbstractParametrizable::removeConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().

◆ removeParameterListener()

void Parameter::removeParameterListener ( const std::string &  listenerId)
virtual

Remove all listeners with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.

Definition at line 94 of file Parameter.cpp.

References listeners_.

Referenced by bpp::AbstractParameterAliasable::unaliasParameters().

◆ setConstraint()

void Parameter::setConstraint ( std::shared_ptr< ConstraintInterface constraint)
virtual

◆ setName()

virtual void bpp::Parameter::setName ( const std::string &  name)
inlinevirtual

Set the name of this parameter.

Parameters
namethe new parameter name.

Definition at line 148 of file Parameter.h.

Referenced by bpp::ParametrizableCollection< N >::addObject(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().

◆ setPrecision()

void Parameter::setPrecision ( double  precision)

Set the precision of this parameter.

Parameters
precisionthe new parameter precision.

Precision:

Definition at line 69 of file Parameter.cpp.

References precision_.

Referenced by Parameter().

◆ setValue()

Member Data Documentation

◆ constraint_

std::shared_ptr<ConstraintInterface> bpp::Parameter::constraint_
protected

◆ listeners_

std::vector< std::shared_ptr<ParameterListener> > bpp::Parameter::listeners_
protected

Definition at line 105 of file Parameter.h.

Referenced by hasParameterListener(), operator=(), and removeParameterListener().

◆ name_

std::string bpp::Parameter::name_
protected

Definition at line 101 of file Parameter.h.

Referenced by operator=(), and bpp::AutoParameter::setValue().

◆ precision_

double bpp::Parameter::precision_
protected

Definition at line 103 of file Parameter.h.

Referenced by operator=(), setPrecision(), and setValue().

◆ PROP_CONSTRAINT_EX

const std::shared_ptr< IntervalConstraint > Parameter::PROP_CONSTRAINT_EX
static

◆ PROP_CONSTRAINT_IN

◆ R_MINUS

const std::shared_ptr< IntervalConstraint > Parameter::R_MINUS
static

Definition at line 309 of file Parameter.h.

Referenced by hasParameterListener().

◆ R_MINUS_STAR

const std::shared_ptr< IntervalConstraint > Parameter::R_MINUS_STAR
static

Definition at line 310 of file Parameter.h.

Referenced by hasParameterListener().

◆ R_PLUS

◆ R_PLUS_STAR

const std::shared_ptr< IntervalConstraint > Parameter::R_PLUS_STAR
static

◆ value_

double bpp::Parameter::value_
protected

Definition at line 102 of file Parameter.h.

Referenced by operator=(), setConstraint(), and setValue().


The documentation for this class was generated from the following files: