DiaDes  0.1
DIAgnosis of Discrete-Event System
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Diades::Sdmdl::Variable Class Reference

#include <Variable.hh>

Public Types

typedef Utils::Exception< VariableException
 
typedef std::reference_wrapper< Variable const > ConstReference
 
typedef std::reference_wrapper< VariableReference
 
typedef std::vector< ReferenceVariableVector
 
typedef VariablePointer
 

Public Member Functions

 ~Variable ()
 
const string & name () const
 
unsigned id () const
 
const VariableFactoryowner () const
 
VariableFactoryowner ()
 
bool isNull () const
 
bool operator== (const Variable &variable) const
 
bool operator!= (const Variable &variable) const
 
const ValueVectordomain () const
 
void setIndex (unsigned index)
 
unsigned index () const
 
const ValueaddValue (const string &label)
 
bool containsValueOfLabel (const string &label) const
 
bool contains (const Value &val) const
 
void setDefault (const Value &val)
 
void setObservable ()
 
void setUnObservable ()
 
bool isObservable () const
 
const ValuegetValue (const string &label) const
 
const ValuegetValue (unsigned id) const
 
const ValuedefaultValue () const
 
const Valuevalue () const
 
void assign (const Value &value)
 

Static Public Member Functions

static string typeName ()
 

Private Member Functions

 Variable (VariableFactory &owner)
 
 Variable (const string &name, unsigned id, VariableFactory &owner)
 

Private Attributes

string _name
 
unsigned _id
 
unsigned _index
 
VariableFactory_owner
 
ValueFactory _values
 
ValueVector _domain
 
ValueVector _default
 
ValueVector _current
 
bool _observable
 

Friends

class VariableFactory
 
ostream & operator<< (ostream &os, const Variable &variable)
 

Detailed Description

A Variable is an object to which it is possible to assign a finite set of Value. A Variable is created and is owned by a VariableFactory

Definition at line 24 of file Variable.hh.

Member Typedef Documentation

◆ ConstReference

typedef std::reference_wrapper<Variable const> Diades::Sdmdl::Variable::ConstReference

Definition at line 31 of file Variable.hh.

◆ Exception

Definition at line 27 of file Variable.hh.

◆ Pointer

Definition at line 34 of file Variable.hh.

◆ Reference

typedef std::reference_wrapper<Variable> Diades::Sdmdl::Variable::Reference

Definition at line 32 of file Variable.hh.

◆ VariableVector

Definition at line 33 of file Variable.hh.

Constructor & Destructor Documentation

◆ Variable() [1/2]

Diades::Sdmdl::Variable::Variable ( VariableFactory owner)
inlineprivate

Creation of a Null Variable

Parameters
ownerthe VariableFactory that creates its null variable

Definition at line 95 of file Variable.hh.

◆ Variable() [2/2]

Diades::Sdmdl::Variable::Variable ( const string &  name,
unsigned  id,
VariableFactory owner 
)
inlineprivate

Creation of a Variable

Parameters
namethe name of the Variable
idthe id of the Variable
ownerthe VariableFactory that creates this Variable
Postcondition
the Variable is not observable and has an empty domain

Definition at line 105 of file Variable.hh.

◆ ~Variable()

Diades::Sdmdl::Variable::~Variable ( )
inline

Desctructor

Definition at line 114 of file Variable.hh.

Member Function Documentation

◆ addValue()

const Value& Diades::Sdmdl::Variable::addValue ( const string &  label)
Parameters
labellabel of the Value to add
Returns
the created Value
Precondition
label must not be empty
there is no Value with such a label in the Variable domain yet

Referenced by index().

◆ assign()

void Diades::Sdmdl::Variable::assign ( const Value value)
inline

Assign a new Value to the current Variable

Parameters
valuethe new Value to assign

Definition at line 371 of file Variable.hh.

References contains(), name(), operator<<, and require.

◆ contains()

bool Diades::Sdmdl::Variable::contains ( const Value val) const
Parameters
valthe Value to look for
Returns
true if the Value is in the domain

Referenced by assign(), index(), and setDefault().

◆ containsValueOfLabel()

bool Diades::Sdmdl::Variable::containsValueOfLabel ( const string &  label) const
Parameters
labellabel of the Value to look for
Returns
true if the Value is in the domain

Referenced by index().

◆ defaultValue()

const Value& Diades::Sdmdl::Variable::defaultValue ( ) const
Returns
the default Value of Variable of the null Value if it does not exist
Precondition
non-null Variable

Referenced by isObservable(), and Diades::Sdmdl::Experimental::Assignment::setVariable().

◆ domain()

const ValueVector& Diades::Sdmdl::Variable::domain ( ) const
inline
Returns
the domain of the Variable

Definition at line 208 of file Variable.hh.

References _domain.

◆ getValue() [1/2]

const Value& Diades::Sdmdl::Variable::getValue ( const string &  label) const
Parameters
labelthe label of the Value to look for
Returns
the Value of the given label or the null value if such a Value does not exist
Precondition
the label must be non-empty

Referenced by Diades::Sdmdl::Experimental::BddStateMachine::addEvent(), Diades::Sdmdl::Experimental::encodeInitialStates(), Diades::Sdmdl::Experimental::encodeTransitions(), isObservable(), and runGlobalDiagnosisProblem().

◆ getValue() [2/2]

const Value& Diades::Sdmdl::Variable::getValue ( unsigned  id) const
Parameters
idthe id of the Value to look for
Returns
the Value of the given id

◆ id()

unsigned Diades::Sdmdl::Variable::id ( ) const
inline
Returns
the id of the Variable. The owner of the Variable owns only one Variable with this id

Definition at line 136 of file Variable.hh.

References _id.

◆ index()

unsigned Diades::Sdmdl::Variable::index ( ) const
inline
Returns
the encodingIndex

Definition at line 232 of file Variable.hh.

References _index, addValue(), contains(), and containsValueOfLabel().

Referenced by setIndex().

◆ isNull()

bool Diades::Sdmdl::Variable::isNull ( ) const

◆ isObservable()

bool Diades::Sdmdl::Variable::isObservable ( ) const
inline
Returns
true if the Variable is observable

Definition at line 324 of file Variable.hh.

References _observable, defaultValue(), getValue(), and value().

◆ name()

const string& Diades::Sdmdl::Variable::name ( ) const
inline
Returns
the name of the Variable

Definition at line 124 of file Variable.hh.

References _name.

Referenced by assign(), Diades::Sdmdl::Experimental::StateInfoEncoder::getVariableId(), and setDefault().

◆ operator!=()

bool Diades::Sdmdl::Variable::operator!= ( const Variable variable) const
inline
Parameters
variablethe Variable to compare
Returns
true if 'variable' is not the current Variable (reference equality)

Definition at line 195 of file Variable.hh.

◆ operator==()

bool Diades::Sdmdl::Variable::operator== ( const Variable variable) const
inline
Parameters
variablethe Variable to compare
Returns
true if 'variable' is the current Variable (reference equality)

Definition at line 181 of file Variable.hh.

◆ owner() [1/2]

const VariableFactory& Diades::Sdmdl::Variable::owner ( ) const
inline
Returns
the owner of the Variable

Definition at line 148 of file Variable.hh.

References _owner.

◆ owner() [2/2]

VariableFactory& Diades::Sdmdl::Variable::owner ( )
inline
Returns
the owner of the Variable

Definition at line 159 of file Variable.hh.

References _owner, and isNull().

◆ setDefault()

void Diades::Sdmdl::Variable::setDefault ( const Value val)
inline

Set the default Value of the Variable

Parameters
valthe new default Value
Precondition
val is not null
val belongs to the domain of the Variable

Definition at line 278 of file Variable.hh.

References contains(), Diades::Sdmdl::Value::isNull(), name(), and require.

◆ setIndex()

void Diades::Sdmdl::Variable::setIndex ( unsigned  index)
inline

Set the encoding index

Parameters
indexthe new encoding index

Definition at line 221 of file Variable.hh.

References index().

◆ setObservable()

void Diades::Sdmdl::Variable::setObservable ( )
inline

Set the Variable to be observable

Precondition
the Variable is not null

Definition at line 296 of file Variable.hh.

References isNull(), and require.

◆ setUnObservable()

void Diades::Sdmdl::Variable::setUnObservable ( )
inline

Set the Variable to be non-observable

Precondition
the Variable is not null

Definition at line 309 of file Variable.hh.

References isNull(), and require.

◆ typeName()

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

Definition at line 28 of file Variable.hh.

◆ value()

const Value& Diades::Sdmdl::Variable::value ( ) const
Returns
the current Value of the Variable

Referenced by isObservable().

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const Variable variable 
)
friend

Output stream operator

Parameters
osthe output stream
variablethe Variable to print out (name)
Returns
the output stream

Referenced by assign().

◆ VariableFactory

friend class VariableFactory
friend

Definition at line 394 of file Variable.hh.

Member Data Documentation

◆ _current

ValueVector Diades::Sdmdl::Variable::_current
private

_current the current Value if it exists

Definition at line 80 of file Variable.hh.

◆ _default

ValueVector Diades::Sdmdl::Variable::_default
private

_default the default Value if it exists

Definition at line 75 of file Variable.hh.

◆ _domain

ValueVector Diades::Sdmdl::Variable::_domain
private

_domain the set of assignable Value objects

Definition at line 70 of file Variable.hh.

Referenced by domain().

◆ _id

unsigned Diades::Sdmdl::Variable::_id
private

_id the ID of the variable created by the associated VariableFactory

Definition at line 45 of file Variable.hh.

Referenced by id().

◆ _index

unsigned Diades::Sdmdl::Variable::_index
private

_index the index associated to the encoding of this Variable in the associated FormulaFactory

Definition at line 51 of file Variable.hh.

Referenced by index().

◆ _name

string Diades::Sdmdl::Variable::_name
private

_name the name of the variable

Definition at line 40 of file Variable.hh.

Referenced by name().

◆ _observable

bool Diades::Sdmdl::Variable::_observable
private

_observable, is the Variable observable or not

Definition at line 85 of file Variable.hh.

Referenced by isObservable().

◆ _owner

VariableFactory& Diades::Sdmdl::Variable::_owner
private

_owner the VariableFactory that created this Variable.

Definition at line 58 of file Variable.hh.

Referenced by owner().

◆ _values

ValueFactory Diades::Sdmdl::Variable::_values
private

_values the associated ValueFactory. Each Variable has its own ValueFactory

Definition at line 63 of file Variable.hh.


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