Class EvaluationVisitor.EvaluationContextImpl
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.EvaluationContext
-
- net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor.EvaluationContextImpl
-
- All Implemented Interfaces:
IConfiguration
- Enclosing class:
- EvaluationVisitor
private class EvaluationVisitor.EvaluationContextImpl extends EvaluationContext
Implements the evaluation context. The context may contain nested local configurations in order to represent the nested (recursive) execution of operations defining parameters or local variables (let). Decision variables are searched along this stack starting at the top.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanallowPropagationprivate java.util.Stack<IConfiguration>configStack
-
Constructor Summary
Constructors Constructor Description EvaluationContextImpl(IConfiguration config)Creates the context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessage(EvaluationVisitor.Message message)Adds an evaluation message.booleanallowAssignValues()Returns whether values shall be assigned, i.e., the configuration may be changed.booleanallowPropagation()Returns whether the expression to be evaluated is a propagation.(package private) Valuebind(IDatatype type)Binds the type to the first/closest definition of type.(package private) voidclear()Clears this instance for reuse.ValuegetAllInstances(IDatatype type)Returns all instances oftype.IAssignmentStategetAssignmentState()Returns the global (target) assignment state for the actual evaluation.IDecisionVariablegetDecision(AbstractVariable variable)Returns the specifiedIDecisionVariable.IAssignmentStategetTargetState(IDecisionVariable var)Returns the target state of the evaluation forvariable.voidissueWarning()Indicates that the evaluation of this constraint shall lead to a warning.voidnotifyChangeListener(IDecisionVariable variable, Value value, IAssignmentState oldState, IValueChangeListener.ChangeKind kind)Notifies the change listener, i.e., the value ofvariablehas changed.(package private) voidpopLevel()Pops the top-most configuration level.(package private) voidpushLevel(IConfiguration config)Pushes a level.(package private) EvaluationVisitor.EvaluationContextImplreset(IConfiguration config)Resets this instance for reuse.(package private) booleansetAllowPropagation(Operation op, boolean inPropagation)Changes the propagation state of this context.-
Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.EvaluationContext
addErrorMessage, addErrorMessage, addErrorMessage, getCollator, getDereferencedValue, getLocale, setLocale
-
-
-
-
Field Detail
-
configStack
private java.util.Stack<IConfiguration> configStack
-
allowPropagation
private boolean allowPropagation
-
-
Constructor Detail
-
EvaluationContextImpl
EvaluationContextImpl(IConfiguration config)
Creates the context.- Parameters:
config- the variability model configuration (outermost stack level)
-
-
Method Detail
-
reset
EvaluationVisitor.EvaluationContextImpl reset(IConfiguration config)
Resets this instance for reuse.- Parameters:
config- the variability model configuration (outermost stack level)- Returns:
- this
-
clear
void clear()
Clears this instance for reuse.- Overrides:
clearin classEvaluationContext
-
pushLevel
void pushLevel(IConfiguration config)
Pushes a level.- Parameters:
config- the configuration to be pushed
-
popLevel
void popLevel()
Pops the top-most configuration level.
-
allowAssignValues
public boolean allowAssignValues()
Description copied from class:EvaluationContextReturns whether values shall be assigned, i.e., the configuration may be changed.- Specified by:
allowAssignValuesin classEvaluationContext- Returns:
trueif values shall be assigned,falseelse
-
notifyChangeListener
public void notifyChangeListener(IDecisionVariable variable, Value value, IAssignmentState oldState, IValueChangeListener.ChangeKind kind)
Description copied from class:EvaluationContextNotifies the change listener, i.e., the value ofvariablehas changed.- Specified by:
notifyChangeListenerin classEvaluationContext- Parameters:
variable- the changed variablevalue- the value ofvariablebefore the change (may be null)oldState- the old state ofvariablebefore the changekind- the change kind
-
addMessage
public void addMessage(EvaluationVisitor.Message message)
Description copied from class:EvaluationContextAdds an evaluation message.- Specified by:
addMessagein classEvaluationContext- Parameters:
message- the message to be added
-
getTargetState
public IAssignmentState getTargetState(IDecisionVariable var)
Description copied from class:EvaluationContextReturns the target state of the evaluation forvariable.- Specified by:
getTargetStatein classEvaluationContext- Parameters:
var- the variable to return the target state for (do not modify!!!)- Returns:
- the target state (may be null if the actual value cannot be assigned do to a state conflict)
-
getDecision
public IDecisionVariable getDecision(AbstractVariable variable)
Description copied from interface:IConfigurationReturns the specifiedIDecisionVariable.- Parameters:
variable- The declaration for which the configuration entity should be returned.- Returns:
- The
IDecisionVariablefor the given declaration
-
getAllInstances
public Value getAllInstances(IDatatype type)
Description copied from interface:IConfigurationReturns all instances oftype.- Parameters:
type- the type to return the instances for- Returns:
- all instances of type in terms of a container value consisting of references (may be null if this is not possible, e.g., in case of Integer)
-
bind
Value bind(IDatatype type)
Binds the type to the first/closest definition of type.- Parameters:
type- the type to search for- Returns:
- the value (may be null if there is none)
-
issueWarning
public void issueWarning()
Description copied from class:EvaluationContextIndicates that the evaluation of this constraint shall lead to a warning.- Specified by:
issueWarningin classEvaluationContext
-
allowPropagation
public boolean allowPropagation()
Description copied from class:EvaluationContextReturns whether the expression to be evaluated is a propagation.- Specified by:
allowPropagationin classEvaluationContext- Returns:
trueif it is a propagation, i.e. propagation shall be allowed,falseelse
-
setAllowPropagation
boolean setAllowPropagation(Operation op, boolean inPropagation)
Changes the propagation state of this context.- Parameters:
inPropagation- whether we are currently in a propagationop- a filter for allowing propagation, basically implies is allow to change or null (no operation as filter)- Returns:
- the propagation state before
-
getAssignmentState
public IAssignmentState getAssignmentState()
Description copied from class:EvaluationContextReturns the global (target) assignment state for the actual evaluation. This may differ fromEvaluationContext.getTargetState(IDecisionVariable).- Specified by:
getAssignmentStatein classEvaluationContext- Returns:
- the assignment state
-
-