DiaDes  0.1
DIAgnosisofDiscrete-EventSystem
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Diades::Altarica::Expression Class Referenceabstract

#include <Expression.hh>

Inherited by Diades::Altarica::ArrayExpression, Diades::Altarica::ArrayMemberExpression, Diades::Altarica::BinaryExpression, Diades::Altarica::CaseExpression, Diades::Altarica::ExistExpression, Diades::Altarica::FalseExpression, Diades::Altarica::ForAllExpression, Diades::Altarica::FunctionCallExpression, Diades::Altarica::IdExpression, Diades::Altarica::IntegerExpression, Diades::Altarica::IteExpression, Diades::Altarica::MinMaxExpression, Diades::Altarica::NullExpression, Diades::Altarica::StructExpression, Diades::Altarica::StructMemberExpression, Diades::Altarica::TrueExpression, Diades::Altarica::UnaryExpression, and Diades::Altarica::VarExpression.

Public Types

enum  Category {
  IfThenElse =0, Case =1, Or =2, And =3,
  Eq =4, Neq =5, Imply =6, Lt =7,
  Gt =8, Leq =9, Geq =10, Add =11,
  Sub =12, Mul =13, Div =14, Mod =15,
  Neg =16, Not =17, Paren =18, StructMember =19,
  ArrayMember =20, Var =21, Id =22, Min =23,
  Max =24, True =25, False =26, Integer =27,
  ForAll =28, Exist =29, FunctionCall =30, Struct =31,
  Array =32
}
 
typedef reference_wrapper< Expression const > ConstReference
 
typedef reference_wrapper< ExpressionReference
 
typedef std::vector< ConstReferenceExprVector
 
typedef Utils::Exception< ExpressionException
 
typedef std::vector< VariableDecl::ConstReference >::const_iterator VariableIterator
 
typedef std::vector< VariableDecl::ConstReference >::size_type SizeType
 
typedef std::vector< VariableDecl::ConstReferenceSupport
 

Public Member Functions

virtual ~Expression ()
 
const AltaricaModelmodel () const
 
const NodeDeclowner () const
 
bool operator== (const Expression &e) const
 
 Expression (const NodeDecl &owner, unsigned id)
 
virtual Category category () const =0
 
unsigned id () const
 
virtual bool valid () const =0
 
VariableIterator variableBegin () const
 
VariableIterator variableEnd () const
 
SizeType supportSize () const
 
const Supportsupport () const
 
virtual const TypevalueType () const =0
 
virtual bool isConstant () const =0
 

Static Public Member Functions

static string typeName ()
 

Protected Attributes

Support _varSupport
 
const NodeDecl_owner
 VariableDecls that are supporting the Expression. More...
 
unsigned _id
 

Friends

ostream & operator<< (ostream &os, const Expression &expr)
 

Detailed Description

This class represents the internal structure of an Altarica expression This class is a virtual class.

Definition at line 26 of file Expression.hh.

Member Typedef Documentation

◆ ConstReference

typedef reference_wrapper<Expression const> Diades::Altarica::Expression::ConstReference

ExprRef copiable reference of an Expression Here we use a reference_wrapper to access any Expression available in a model The basic idea is that any Expression of a given AltaricaModel is created into the ExpressionFactory of the model. Once created, the factory returns a constant reference that is stored whereever it is required. Especially, if it is required to store such reference into an STL-vector, it is then required to a reference_wrapper. Hence the use of ExprRef for that purpose.

Definition at line 48 of file Expression.hh.

◆ Exception

Definition at line 59 of file Expression.hh.

◆ ExprVector

ExprVector vector of expression references.

Definition at line 54 of file Expression.hh.

◆ Reference

Definition at line 49 of file Expression.hh.

◆ SizeType

Definition at line 64 of file Expression.hh.

◆ Support

Definition at line 65 of file Expression.hh.

◆ VariableIterator

Definition at line 63 of file Expression.hh.

Member Enumeration Documentation

◆ Category

Category the category of an expression

Enumerator
IfThenElse 
Case 
Or 
And 
Eq 
Neq 
Imply 
Lt 
Gt 
Leq 
Geq 
Add 
Sub 
Mul 
Div 
Mod 
Neg 
Not 
Paren 
StructMember 
ArrayMember 
Var 
Id 
Min 
Max 
True 
False 
Integer 
ForAll 
Exist 
FunctionCall 
Struct 
Array 

Definition at line 34 of file Expression.hh.

Constructor & Destructor Documentation

◆ ~Expression()

virtual Diades::Altarica::Expression::~Expression ( )
inlinevirtual

Destructor

Definition at line 82 of file Expression.hh.

References model(), and owner().

◆ Expression()

Diades::Altarica::Expression::Expression ( const NodeDecl owner,
unsigned  id 
)

Parmetrised constructor

Parameters
ownerthe owner of the Expression
idthe id of the Expression (provided by ExpressionFactory for internal use only)

Referenced by operator==().

Member Function Documentation

◆ category()

virtual Category Diades::Altarica::Expression::category ( ) const
pure virtual

Expression evaluation: this operation evaluates the expression with the current value associated to the variables that support the Expression. The evaluation is failing if there is a variable of the support that is still free (that is an unassigned variable).

Parameters
valuethe Value resulting from the evaluation of the current Expression.
Returns
true if the operation succeeds, false otherwise.Category of an expression
the category o of the Expression. It is way to avoid the use of RTTI and gets a lighter implementation.

Implemented in Diades::Altarica::ArrayExpression, Diades::Altarica::StructExpression, Diades::Altarica::FunctionCallExpression, Diades::Altarica::ExistExpression, Diades::Altarica::ForAllExpression, Diades::Altarica::IntegerExpression, Diades::Altarica::FalseExpression, Diades::Altarica::TrueExpression, Diades::Altarica::MinMaxExpression, Diades::Altarica::IdExpression, Diades::Altarica::VarExpression, Diades::Altarica::ArrayMemberExpression, Diades::Altarica::StructMemberExpression, Diades::Altarica::UnaryExpression, Diades::Altarica::BinaryExpression, Diades::Altarica::CaseExpression, Diades::Altarica::IteExpression, and Diades::Altarica::NullExpression.

Referenced by Diades::Altarica::castExpr(), and operator==().

◆ id()

unsigned Diades::Altarica::Expression::id ( ) const
inline

Id of the Expression

Returns
Id of the Expression

Definition at line 140 of file Expression.hh.

References _id, and valid().

◆ isConstant()

virtual bool Diades::Altarica::Expression::isConstant ( ) const
pure virtual

◆ model()

const AltaricaModel& Diades::Altarica::Expression::model ( ) const

model of the current expression

Returns
the AltaricaModel that owns this expression

Referenced by ~Expression().

◆ operator==()

bool Diades::Altarica::Expression::operator== ( const Expression e) const
inline

Definition at line 100 of file Expression.hh.

References category(), and Expression().

◆ owner()

const NodeDecl& Diades::Altarica::Expression::owner ( ) const

node declaration of the current expression

Returns
the node declaration that owns this expression

Referenced by BOOST_AUTO_TEST_CASE(), and ~Expression().

◆ support()

const Support& Diades::Altarica::Expression::support ( ) const
inline
Returns
the variable support of the expression

Definition at line 175 of file Expression.hh.

References _varSupport, Diades::Altarica::appendExpressionSupports(), isConstant(), Diades::Altarica::mergeExpressionSupports(), operator<<, and valueType().

◆ supportSize()

SizeType Diades::Altarica::Expression::supportSize ( ) const
inline

VariableDecl support size

Returns
the number of variables involved in this Expression

Definition at line 164 of file Expression.hh.

Referenced by BOOST_AUTO_TEST_CASE().

◆ typeName()

static string Diades::Altarica::Expression::typeName ( )
inlinestatic

Definition at line 60 of file Expression.hh.

◆ valid()

virtual bool Diades::Altarica::Expression::valid ( ) const
pure virtual

◆ valueType()

virtual const Type& Diades::Altarica::Expression::valueType ( ) const
pure virtual

Type of the Value returned by the Expression (lazy computation)

Returns
the Type of the Value.

Implemented in Diades::Altarica::ArrayExpression, Diades::Altarica::StructExpression, Diades::Altarica::FunctionCallExpression, Diades::Altarica::ExistExpression, Diades::Altarica::ForAllExpression, Diades::Altarica::IntegerExpression, Diades::Altarica::FalseExpression, Diades::Altarica::TrueExpression, Diades::Altarica::MinMaxExpression, Diades::Altarica::IdExpression, Diades::Altarica::VarExpression, Diades::Altarica::ArrayMemberExpression, Diades::Altarica::StructMemberExpression, Diades::Altarica::UnaryExpression, Diades::Altarica::BinaryExpression, Diades::Altarica::CaseExpression, Diades::Altarica::IteExpression, and Diades::Altarica::NullExpression.

Referenced by BOOST_AUTO_TEST_CASE(), Diades::Altarica::BinaryExpression::category(), Diades::Altarica::IdExpression::category(), Diades::Altarica::FalseExpression::category(), Diades::Altarica::ForAllExpression::category(), Diades::Altarica::ExistExpression::category(), Diades::Altarica::FunctionCallExpression::category(), Diades::Altarica::StructMemberExpression::getMember(), Diades::Altarica::NullExpression::isConstant(), support(), Diades::Altarica::ArrayMemberExpression::valid(), Diades::Altarica::MinMaxExpression::valid(), Diades::Altarica::TrueExpression::valid(), Diades::Altarica::IntegerExpression::valid(), Diades::Altarica::StructExpression::valid(), Diades::Altarica::ArrayExpression::valid(), Diades::Altarica::IteExpression::valueType(), and Diades::Altarica::UnaryExpression::valueType().

◆ variableBegin()

VariableIterator Diades::Altarica::Expression::variableBegin ( ) const
inline

VariableDecl iterator

Returns
the iterator in the first variable that supports the current Expression

Definition at line 152 of file Expression.hh.

Referenced by BOOST_AUTO_TEST_CASE(), and Diades::Altarica::VarExpression::getVariableDecl().

◆ variableEnd()

VariableIterator Diades::Altarica::Expression::variableEnd ( ) const
inline

VariableDecl iterator

Returns
the iterator after the last variable that supports the current Expression

Definition at line 158 of file Expression.hh.

Referenced by BOOST_AUTO_TEST_CASE().

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const Expression expr 
)
friend

Member Data Documentation

◆ _id

unsigned Diades::Altarica::Expression::_id
protected

Definition at line 74 of file Expression.hh.

Referenced by id().

◆ _owner

const NodeDecl& Diades::Altarica::Expression::_owner
protected

VariableDecls that are supporting the Expression.

Type of the Value returned by the Expression. The VariableDecl is mutable because of lazy computation (may be not initialised at construction time but is constant characteristics of an Expression)

Definition at line 73 of file Expression.hh.

◆ _varSupport

Support Diades::Altarica::Expression::_varSupport
protected

Definition at line 67 of file Expression.hh.

Referenced by support(), and Diades::Altarica::VarExpression::valid().


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