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

#include <StateInfoEncoder.hh>

Public Types

using VariableEncoderId = VariableVector::size_type
 
using StateInfoId = size_t
 

Public Member Functions

 StateInfoEncoder (VariableFactory &varFactory)
 
template<typename StateInfoIdIterator >
VariableEncoderId encodeStateInfoRange (StateInfoIdIterator first, StateInfoIdIterator last)
 
VariablegetVariable (VariableEncoderId id) const
 
VariableEncoderId numberOfEncodedVariables () const
 
VariableEncoderId getVariableId (const Variable &variable) const
 
std::vector< StateInfoId > & getDomain (VariableEncoderId id)
 
std::pair< StateInfoId, bool > getStateInfoId (const Assignment &assignment) const
 

Private Member Functions

const ValueencodeStateInfoInVariable (VariableEncoderId varId, StateInfoId id)
 

Private Attributes

VariableFactory_variables
 
VariableVector _encodedVariables
 
std::unordered_map< std::string, VariableEncoderId_varDictionnary
 
std::vector< std::vector< StateInfoId > > _domains
 
std::vector< std::unordered_map< std::string, size_t > > _valueIndexes
 

Detailed Description

This class encodes ranges of StateInfo as a Variable with a domain that encode the given range It might encode several ranges. For each range a new Variable is created. To access a Variable and its non-encoded domain (set of StateInfoIds) the encoder provides an Id.

Definition at line 34 of file StateInfoEncoder.hh.

Member Typedef Documentation

◆ StateInfoId

Parameters
StateInfoIda classical StateInfoId represented as a size_t
See also
StateInfoManger

Definition at line 46 of file StateInfoEncoder.hh.

◆ VariableEncoderId

Definition at line 41 of file StateInfoEncoder.hh.

Constructor & Destructor Documentation

◆ StateInfoEncoder()

Diades::Sdmdl::Experimental::StateInfoEncoder::StateInfoEncoder ( VariableFactory varFactory)
inline

Constructor

Parameters
varFactorythe permanent reference to a VariableFactory

Definition at line 90 of file StateInfoEncoder.hh.

Member Function Documentation

◆ encodeStateInfoInVariable()

const Value& Diades::Sdmdl::Experimental::StateInfoEncoder::encodeStateInfoInVariable ( VariableEncoderId  varId,
StateInfoId  id 
)
inlineprivate

Encode a StateInfoId into predefined variable

Parameters
varIdthe VariableEncoderId that is already created by the encode
ida new StateInfoId to encode in the domain of the variable
Returns
the encoded Value corresponding to the StateInfoId

Definition at line 107 of file StateInfoEncoder.hh.

Referenced by encodeStateInfoRange().

◆ encodeStateInfoRange()

template<typename StateInfoIdIterator >
VariableEncoderId Diades::Sdmdl::Experimental::StateInfoEncoder::encodeStateInfoRange ( StateInfoIdIterator  first,
StateInfoIdIterator  last 
)
inline

Encode a range of StateInfoIds. Creation of a new Variable for this range

Parameters
firstFirst StateInfoId of the range
lastSecond StateInfoId of the range
Returns
the index of the new Variable

Definition at line 127 of file StateInfoEncoder.hh.

References encodeStateInfoInVariable(), Diades::Sdmdl::VariableFactory::newVariable(), and Diades::Sdmdl::VariableFactory::numberOfAllocatedVariables().

Referenced by runGlobalDiagnosisProblem().

◆ getDomain()

std::vector<StateInfoId>& Diades::Sdmdl::Experimental::StateInfoEncoder::getDomain ( VariableEncoderId  id)
inline
Parameters
ida Variable Id given by the StateInfoEncoder
Returns
the domain (set of StateInfoId) associated with the Variable of the given id

Definition at line 198 of file StateInfoEncoder.hh.

◆ getStateInfoId()

std::pair<StateInfoId,bool> Diades::Sdmdl::Experimental::StateInfoEncoder::getStateInfoId ( const Assignment assignment) const
inline

Return the StateInfoId encoded with the Assignment

Parameters
assignmentthe Assignemt to decode
Returns
a std::pair<StateInfoId,bool> where bool is false if the the Assignment cannot be decoded.

Definition at line 210 of file StateInfoEncoder.hh.

References getVariableId(), Diades::Sdmdl::Value::label(), numberOfEncodedVariables(), Diades::Sdmdl::Experimental::Assignment::value(), and Diades::Sdmdl::Experimental::Assignment::variable().

Referenced by printSolution().

◆ getVariable()

Variable& Diades::Sdmdl::Experimental::StateInfoEncoder::getVariable ( VariableEncoderId  id) const
inline
Parameters
ida Variable Id given by the StateInfoEncoder
Returns
the Variable associated with the id

Definition at line 155 of file StateInfoEncoder.hh.

Referenced by getVariableId(), and runGlobalDiagnosisProblem().

◆ getVariableId()

VariableEncoderId Diades::Sdmdl::Experimental::StateInfoEncoder::getVariableId ( const Variable variable) const
inline
Parameters
variable
Returns
the id of the Variable if it can find it otherwise returns numberOfVariables()

Definition at line 176 of file StateInfoEncoder.hh.

References getVariable(), Diades::Sdmdl::Variable::name(), and numberOfEncodedVariables().

Referenced by getStateInfoId().

◆ numberOfEncodedVariables()

VariableEncoderId Diades::Sdmdl::Experimental::StateInfoEncoder::numberOfEncodedVariables ( ) const
inline
Returns
the number of encoded variables

Definition at line 165 of file StateInfoEncoder.hh.

Referenced by getStateInfoId(), and getVariableId().

Member Data Documentation

◆ _domains

std::vector<std::vector<StateInfoId> > Diades::Sdmdl::Experimental::StateInfoEncoder::_domains
private

Definition at line 75 of file StateInfoEncoder.hh.

◆ _encodedVariables

VariableVector Diades::Sdmdl::Experimental::StateInfoEncoder::_encodedVariables
private

Definition at line 60 of file StateInfoEncoder.hh.

◆ _valueIndexes

std::vector< std::unordered_map<std::string,size_t> > Diades::Sdmdl::Experimental::StateInfoEncoder::_valueIndexes
private

Definition at line 82 of file StateInfoEncoder.hh.

◆ _varDictionnary

std::unordered_map<std::string,VariableEncoderId> Diades::Sdmdl::Experimental::StateInfoEncoder::_varDictionnary
private

Definition at line 67 of file StateInfoEncoder.hh.

◆ _variables

VariableFactory& Diades::Sdmdl::Experimental::StateInfoEncoder::_variables
private

Definition at line 54 of file StateInfoEncoder.hh.


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