Otawa  0.10
otawa::ilp::ConstraintImpl Class Referenceabstract

Provide a simple implementation of a constraint using expression. More...

#include <otawa/ilp/impl.h>

Inheritance diagram for otawa::ilp::ConstraintImpl:
otawa::ilp::Constraint

Public Types

enum  comparator_t {
  UNDEF = -3, LT = -2, LE = -1, EQ = 0,
  GE = 1, GT = 2
}
 
typedef enum
otawa::ilp::Constraint::comparator_t 
comparator_t
 
typedef otawa::ilp::Term Term
 

Public Member Functions

 ConstraintImpl (comparator_t comparator, string label="")
 Build an empty constraint. More...
 
virtual double coefficient (Var *var)
 
virtual double constant (void) const
 
virtual comparator_t comparator (void) const
 Get the constraint comparator. More...
 
virtual const stringlabel (void) const
 
virtual void add (double coef, Var *var)
 Add a term to the constraint to the left part of constraint. More...
 
virtual void sub (double coef, Var *var)
 Substact a factor from the constraint. More...
 
virtual
elm::datastruct::IteratorInst
< Term > * 
terms (void)
 
virtual double coefficient (Var *var=0) const =0
 Get the coefficient for the given variable. More...
 
void add (const Term &t)
 
void add (const Expression &e)
 void Constraint::setComparator(comparator_t comp); Change the comparator of the constraint. More...
 
void sub (const Term &t)
 
void sub (const Expression &e)
 Subtract an expression from the left part of the constraint. More...
 
void addLeft (double coef, Var *var=0)
 Add a factor on the left side. More...
 
void addRight (double coef, Var *var=0)
 Add a factor on the right side. More...
 
virtual void setComparator (comparator_t comp)=0
 
virtual void setLabel (const string &label)=0
 

Private Attributes

Expression expr
 
comparator_t comp
 
string lab
 

Detailed Description

Provide a simple implementation of a constraint using expression.

The stored expression e states only that: e {=|<|>|<=|>=} 0. It is relatively easy to push back the constant to the right of the constraint.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
UNDEF 
LT 
LE 
EQ 
GE 
GT 

Constructor & Destructor Documentation

otawa::ilp::ConstraintImpl::ConstraintImpl ( comparator_t  comparator,
string  label = "" 
)

Build an empty constraint.

Parameters
comparatorComparator to use.
labelLabel of the constraint.

Member Function Documentation

void otawa::ilp::ConstraintImpl::add ( double  coef,
Var var 
)
virtual

Add a term to the constraint to the left part of constraint.

If var is null, sum the coefficient to the right part of the constraint.

Parameters
coefCoefficient of the factor.
varVariable of the factor. When null, modify the constant.

Implements otawa::ilp::Constraint.

References otawa::ilp::Expression::add(), and expr.

void otawa::ilp::Constraint::add ( const Term t)
inlineinherited
void otawa::ilp::Constraint::add ( const Expression e)
inherited

void Constraint::setComparator(comparator_t comp); Change the comparator of the constraint.

Parameters
compComparator to set.
Since
ILP interface 1.2.0 void Constraint::setLabel(const string& label); Change the label of the constraint.
Parameters
labelLabel to set.
Since
ILP interface 1.2.0 Add an expression to the left part of the constraint.
Parameters
eAdded expression.

References otawa::ilp::Constraint::add().

double otawa::ilp::ConstraintImpl::coefficient ( Var var)
virtual

References expr.

double otawa::ilp::Constraint::coefficient ( Var var = 0) const
pure virtualinherited

Get the coefficient for the given variable.

Parameters
varVariable to get the coefficent of. Null variable allows getting the constant part.
Returns
Variable coefficient.

Implemented in otawa::ilp::AbstractConstraint.

Constraint::comparator_t otawa::ilp::ConstraintImpl::comparator ( void  ) const
virtual

Get the constraint comparator.

Returns
Constraint comparator.

Implements otawa::ilp::Constraint.

References comp.

double otawa::ilp::ConstraintImpl::constant ( void  ) const
virtual

Implements otawa::ilp::Constraint.

References expr.

const string & otawa::ilp::ConstraintImpl::label ( void  ) const
virtual

Implements otawa::ilp::Constraint.

References lab.

virtual void otawa::ilp::Constraint::setComparator ( comparator_t  comp)
pure virtualinherited

Referenced by otawa::ilp::cons::set().

virtual void otawa::ilp::Constraint::setLabel ( const string label)
pure virtualinherited
void otawa::ilp::ConstraintImpl::sub ( double  coef,
Var var 
)
virtual

Substact a factor from the constraint.

Parameters
coefCoefficient of the factor.
varVariable of the factor.

Implements otawa::ilp::Constraint.

References otawa::ilp::Expression::add(), and expr.

void otawa::ilp::Constraint::sub ( const Term t)
inlineinherited
void otawa::ilp::Constraint::sub ( const Expression e)
inherited

Subtract an expression from the left part of the constraint.

Parameters
eSubtracted expression.

References otawa::ilp::Constraint::sub().

elm::datastruct::IteratorInst< Term > * otawa::ilp::ConstraintImpl::terms ( void  )
virtual

Implements otawa::ilp::Constraint.

References expr.

Member Data Documentation

comparator_t otawa::ilp::ConstraintImpl::comp
private

Referenced by comparator().

Expression otawa::ilp::ConstraintImpl::expr
private

Referenced by add(), coefficient(), constant(), sub(), and terms().

string otawa::ilp::ConstraintImpl::lab
private

Referenced by label().


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