DiaDes  0.1
DIAgnosisofDiscrete-EventSystem
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
Diades::Altarica::Variable Class Reference

#include <Variable.hh>

Inheritance diagram for Diades::Altarica::Variable:
Inheritance graph

Public Types

typedef FlatVariableIterator FlatIterator
 
typedef VariablePointer
 
typedef reference_wrapper< VariableReference
 
typedef reference_wrapper< Variable const > ConstReference
 
typedef vector< ReferenceVarVector
 
typedef vector< Variable >::iterator VariableIterator
 
typedef vector< Variable >::const_iterator VariableConstIterator
 
typedef unordered_map< Identifier, VarVector::size_type > SubVarDictionary
 

Public Member Functions

 Variable ()
 
virtual ~Variable ()
 
VariablegetVariableFromPath (const string &varPath)
 
const VariablegetVariableFromPath (const string &varPath) const
 
FlatIterator varBegin ()
 
FlatIterator varEnd ()
 
virtual void init (const Identifier &name, const VariableDecl &declaration, Variable &scope)
 
virtual void clear ()
 
const Variablescope () const
 
void assign (const Value &value)
 
const Typetype () const
 
const VariableDecldeclaration () const
 
const Identifiername () const
 
const string & fullname () const
 
bool isNull () const
 
bool isFree () const
 
void makeFree ()
 
bool operator== (const Variable &variable) const
 
bool operator!= (const Variable &variable) const
 
VariablegetVariable (const Identifier &name)
 
const VariablegetVariable (const Identifier &name) const
 
VariablegetVariable (unsigned index)
 
const VariablegetVariable (unsigned index) const
 
VariableIterator variableBegin ()
 
VariableIterator variableEnd ()
 
VariableConstIterator variableBegin () const
 
VariableConstIterator variableEnd () const
 
const Valuevalue () const
 

Protected Member Functions

VariableinitSubVariable (const Identifier &name) const
 
VariableinitSubVariable (unsigned index) const
 
void instanciateVariable () const
 

Private Attributes

Identifier _name
 
string _fullname
 
VarVector _scope
 
vector< VariableDecl::ConstReference_declaration
 
vector< Variable_subVariables
 
bool _isFree
 
vector< Value::ConstReference_current
 
SubVarDictionary _varDictionary
 

Friends

class FlatVariableIterator
 

Exception

Exception mechanism

typedef Utils::Exception< VariableException
 
static string typeName ()
 

Detailed Description

A Variable is an instance of a VariableDecl. A Variable is always in the scope of another Variable

Definition at line 27 of file Variable.hh.

Member Typedef Documentation

◆ ConstReference

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

ConstReference copiable constant reference

Definition at line 63 of file Variable.hh.

◆ Exception

Definition at line 35 of file Variable.hh.

◆ FlatIterator

Definition at line 40 of file Variable.hh.

◆ Pointer

Pointer pointer

Definition at line 47 of file Variable.hh.

◆ Reference

typedef reference_wrapper<Variable> Diades::Altarica::Variable::Reference

Reference copiable reference

Definition at line 55 of file Variable.hh.

◆ SubVarDictionary

typedef unordered_map<Identifier,VarVector::size_type> Diades::Altarica::Variable::SubVarDictionary

SubVarDictionary Dictionary of the field of the Variable

Definition at line 97 of file Variable.hh.

◆ VariableConstIterator

VariableConstIterator constant iterator of the sub variables

Definition at line 89 of file Variable.hh.

◆ VariableIterator

VariableIterator iterator of the sub variables

Definition at line 81 of file Variable.hh.

◆ VarVector

VarVector vector of Variable copiable References

Definition at line 72 of file Variable.hh.

Constructor & Destructor Documentation

◆ Variable()

Diades::Altarica::Variable::Variable ( )
inline

Default constructor Make an null Variable

Definition at line 209 of file Variable.hh.

◆ ~Variable()

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

Destructor

Todo:
test

Definition at line 217 of file Variable.hh.

Member Function Documentation

◆ assign()

void Diades::Altarica::Variable::assign ( const Value value)

Assignation of a value

Parameters
valueto be assigned
Precondition
value.type() == type()
Todo:
test

◆ clear()

virtual void Diades::Altarica::Variable::clear ( )
virtual

Clear the Variable

Reimplemented in Diades::Altarica::Node.

◆ declaration()

const VariableDecl& Diades::Altarica::Variable::declaration ( ) const
inline
Returns
the declaration associated to this Variable
Precondition
!isNull()
Todo:
test

Definition at line 332 of file Variable.hh.

References require.

Referenced by printVariableMap(), and Diades::Altarica::Node::transitions().

◆ fullname()

const string& Diades::Altarica::Variable::fullname ( ) const
Returns
the full name of the Variable
Todo:
test

Referenced by Diades::Altarica::Event::fullname(), and printVariableMap().

◆ getVariable() [1/4]

Variable& Diades::Altarica::Variable::getVariable ( const Identifier name)
Parameters
nameName of the sub variable
Returns
the sub variable with the name 'name' if it exists
Todo:
test

◆ getVariable() [2/4]

const Variable& Diades::Altarica::Variable::getVariable ( const Identifier name) const
Parameters
nameName of the sub variable
Returns
the sub variable with the name 'name' if it exists
Todo:
test

◆ getVariable() [3/4]

Variable& Diades::Altarica::Variable::getVariable ( unsigned  index)
Parameters
indexindex of the sub variable
Returns
the sub variable at this index if it exists
Todo:
test

◆ getVariable() [4/4]

const Variable& Diades::Altarica::Variable::getVariable ( unsigned  index) const
Parameters
indexindex of the sub variable
Returns
the sub variable at this index if it exists
Todo:
test

◆ getVariableFromPath() [1/2]

Variable& Diades::Altarica::Variable::getVariableFromPath ( const string &  varPath)
Parameters
varPaththe path from the current variable to a sub-variable
Returns
the sub-variable addressed by the given path
Todo:
implement

◆ getVariableFromPath() [2/2]

const Variable& Diades::Altarica::Variable::getVariableFromPath ( const string &  varPath) const
Parameters
varPaththe path from the current variable to a sub-variable
Returns
the sub-variable addressed by the given path
Todo:
implement

◆ init()

virtual void Diades::Altarica::Variable::init ( const Identifier name,
const VariableDecl declaration,
Variable scope 
)
virtual

initialisation

Parameters
name
declaration
scope
Todo:
implement

◆ initSubVariable() [1/2]

Variable& Diades::Altarica::Variable::initSubVariable ( const Identifier name) const
protected

Initialisation of a sub variable

Parameters
namename of the sub variable
Returns
the initialized variable

◆ initSubVariable() [2/2]

Variable& Diades::Altarica::Variable::initSubVariable ( unsigned  index) const
protected

Initialisation of a sub variable

Parameters
indexindex of the sub variable
Returns
the initialized variable

◆ instanciateVariable()

void Diades::Altarica::Variable::instanciateVariable ( ) const
protected

Full instanciation of the Variable

◆ isFree()

bool Diades::Altarica::Variable::isFree ( ) const
inline
Returns
true if the Variable is not assigned to any Value
Todo:
test

Definition at line 387 of file Variable.hh.

Referenced by printVariableMap().

◆ isNull()

bool Diades::Altarica::Variable::isNull ( ) const
inline

◆ makeFree()

void Diades::Altarica::Variable::makeFree ( )

Make the variable free, i.e. the Variable is not assigned to a Value

Todo:
test

◆ name()

const Identifier& Diades::Altarica::Variable::name ( ) const
inline
Returns
the short name of the Variable
Precondition
!isNull()
Todo:
test

Definition at line 351 of file Variable.hh.

References require.

Referenced by Diades::Altarica::Node::nodeDeclaration(), printNodes(), and printVariableMap().

◆ operator!=()

bool Diades::Altarica::Variable::operator!= ( const Variable variable) const
inline

Difference operator (reference)

Parameters
variablethe Variable to compare
Returns
true if the Variable are different
Todo:
test

Definition at line 424 of file Variable.hh.

◆ operator==()

bool Diades::Altarica::Variable::operator== ( const Variable variable) const
inline

Equality operator (reference)

Parameters
variablethe Variable to compare
Returns
true if the Variable are the same
Todo:
test

Definition at line 410 of file Variable.hh.

◆ scope()

const Variable& Diades::Altarica::Variable::scope ( ) const
inline
Returns
the current scope of the variable.
Precondition
!isNull()
Todo:
test

Definition at line 289 of file Variable.hh.

References require.

Referenced by printVariableMap().

◆ type()

const Type& Diades::Altarica::Variable::type ( ) const
inline
Returns
the Type of the Variable
Todo:
test

Definition at line 316 of file Variable.hh.

References require, and Diades::Altarica::VariableDecl::type().

Referenced by printVariableMap().

◆ typeName()

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

Definition at line 36 of file Variable.hh.

◆ value()

const Value& Diades::Altarica::Variable::value ( ) const
Returns
the current Value of the Variable if not free.
Precondition
!isFree()
Todo:
test

Referenced by printVariableMap().

◆ varBegin()

FlatIterator Diades::Altarica::Variable::varBegin ( )
Returns
the flat iterator on the first simple VariableDecl contained in this VariableDecl

Referenced by analyseComponent(), and main().

◆ varEnd()

FlatIterator Diades::Altarica::Variable::varEnd ( )
Returns
the flat iterator on the first simple VariableDecl contained in this VariableDecl

Referenced by analyseComponent(), and main().

◆ variableBegin() [1/2]

VariableIterator Diades::Altarica::Variable::variableBegin ( )
Returns
an iterator on the first sub-variable
Todo:
test

Referenced by printVariableMap().

◆ variableBegin() [2/2]

VariableConstIterator Diades::Altarica::Variable::variableBegin ( ) const
Returns
an iterator on the first sub-variable
Todo:
test

◆ variableEnd() [1/2]

VariableIterator Diades::Altarica::Variable::variableEnd ( )
Returns
an iterator on the item after the last sub-variable
Todo:
test

Referenced by printVariableMap().

◆ variableEnd() [2/2]

VariableConstIterator Diades::Altarica::Variable::variableEnd ( ) const
Returns
an iterator on the item after the last sub-variable
Todo:
test

Friends And Related Function Documentation

◆ FlatVariableIterator

friend class FlatVariableIterator
friend

Definition at line 202 of file Variable.hh.

Member Data Documentation

◆ _current

vector<Value::ConstReference> Diades::Altarica::Variable::_current
private

_current the current assigned value if it exists and if it is a simple Variable

Definition at line 162 of file Variable.hh.

◆ _declaration

vector<VariableDecl::ConstReference> Diades::Altarica::Variable::_declaration
private

_scope the declaration of the Variable

Definition at line 137 of file Variable.hh.

◆ _fullname

string Diades::Altarica::Variable::_fullname
mutableprivate

_fullname the full name (path) of the Variable

Definition at line 118 of file Variable.hh.

◆ _isFree

bool Diades::Altarica::Variable::_isFree
private

_isFree Is the Variable free?

Definition at line 154 of file Variable.hh.

◆ _name

Identifier Diades::Altarica::Variable::_name
private

_name the name of the Variable

Definition at line 108 of file Variable.hh.

◆ _scope

VarVector Diades::Altarica::Variable::_scope
private

_scope the scope of the Variable. Here it is tricky. I use a vector of one element at most. But I do not want to use pointers and I want the VariableFactory to be able to create a null Variable whose scope is itself.

Definition at line 128 of file Variable.hh.

◆ _subVariables

vector<Variable> Diades::Altarica::Variable::_subVariables
mutableprivate

_subVariables the set of sub variables if they exists (mutable feature for lazy evaluation)

Definition at line 146 of file Variable.hh.

◆ _varDictionary

SubVarDictionary Diades::Altarica::Variable::_varDictionary
mutableprivate

_varDictionary the dictionary of the filed of the Variable

Definition at line 171 of file Variable.hh.


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