Class DelegatingReasonerInstance
- java.lang.Object
-
- net.ssehub.easy.reasoning.core.reasoner.DelegatingReasonerInstance
-
- All Implemented Interfaces:
IReasonerInstance
public class DelegatingReasonerInstance extends java.lang.Object implements IReasonerInstance
Provides a default implementation for reasoner instances by delegating the respective calls to a given delegate reasoner. Use this class to simplify calls forIReasoner#createInstance( net.ssehub.easy.varModel.model.Project, net.ssehub.easy.varModel.confModel.Configuration, ReasonerConfiguration), i.e., to avoid null pointer returns.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private Configurationconfigprivate IReasonerdelegateprivate booleanisRunningprivate ReasonerConfigurationrConfig
-
Constructor Summary
Constructors Constructor Description DelegatingReasonerInstance(Configuration config, ReasonerConfiguration rConfig, IReasoner delegate)Creates a delegating reasoner instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReasoningResultcheck(ProgressObserver observer)Checks the configuration according to the given project structure and does not affect the configuration.ValueCreationResultcreateValue(AbstractVariable var, IDatatype type, ProgressObserver observer)Creates the value for a certain IVML type/variable.EvaluationResultevaluate(java.util.List<Constraint> constraints, ProgressObserver observer)Evaluates a given list of constraints (in the sense of boolean conditions) which are related to and valid in the context of the given project and configuration.ReasonerDescriptorgetDescriptor()Returns a descriptor stating common information about this reasoner.ProjectgetProject()Returns the project this instance is attached to.ReasonerConfigurationgetReasonerConfiguration()Returns the reasoner configuration this project is running with.ReasoningResultisConsistent(ProgressObserver observer)Checks whether a given variability model (project) is satisfiable.booleanisRunning()Returns whether the reasoner is (still) operating.voidnotify(IReasonerMessage message)Is called when a reasoner message is issued.ReasoningResultpropagate(ProgressObserver observer)Checks the configuration according to the given model and propagates values, if possible.booleanstop()Stops/terminates reasoning.
-
-
-
Field Detail
-
delegate
private IReasoner delegate
-
config
private Configuration config
-
rConfig
private ReasonerConfiguration rConfig
-
isRunning
private boolean isRunning
-
-
Constructor Detail
-
DelegatingReasonerInstance
public DelegatingReasonerInstance(Configuration config, ReasonerConfiguration rConfig, IReasoner delegate)
Creates a delegating reasoner instance.- Parameters:
config- the configuration to reason bound to this instancerConfig- the reasoner configurationdelegate- the delegate
-
-
Method Detail
-
getDescriptor
public ReasonerDescriptor getDescriptor()
Description copied from interface:IReasonerInstanceReturns a descriptor stating common information about this reasoner.- Specified by:
getDescriptorin interfaceIReasonerInstance- Returns:
- the descriptor
-
isConsistent
public ReasoningResult isConsistent(ProgressObserver observer)
Description copied from interface:IReasonerInstanceChecks whether a given variability model (project) is satisfiable.- Specified by:
isConsistentin interfaceIReasonerInstance- Parameters:
observer- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
check
public ReasoningResult check(ProgressObserver observer)
Description copied from interface:IReasonerInstanceChecks the configuration according to the given project structure and does not affect the configuration.- Specified by:
checkin interfaceIReasonerInstance- Parameters:
observer- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
propagate
public ReasoningResult propagate(ProgressObserver observer)
Description copied from interface:IReasonerInstanceChecks the configuration according to the given model and propagates values, if possible.- Specified by:
propagatein interfaceIReasonerInstance- Parameters:
observer- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
evaluate
public EvaluationResult evaluate(java.util.List<Constraint> constraints, ProgressObserver observer)
Description copied from interface:IReasonerInstanceEvaluates a given list of constraints (in the sense of boolean conditions) which are related to and valid in the context of the given project and configuration.- Specified by:
evaluatein interfaceIReasonerInstance- Parameters:
constraints- the constraints (expressions which evaluate to a boolean value)observer- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
createValue
public ValueCreationResult createValue(AbstractVariable var, IDatatype type, ProgressObserver observer)
Description copied from interface:IReasonerInstanceCreates the value for a certain IVML type/variable.- Specified by:
createValuein interfaceIReasonerInstance- Parameters:
var- the variable to create the value for (may be null iftypeis given, may imply additional constraints)type- the type to create the value for (may be null ifvaris given)observer- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- the value creation result
-
notify
public void notify(IReasonerMessage message)
Description copied from interface:IReasonerInstanceIs called when a reasoner message is issued.- Specified by:
notifyin interfaceIReasonerInstance- Parameters:
message- the message sent
-
isRunning
public boolean isRunning()
Description copied from interface:IReasonerInstanceReturns whether the reasoner is (still) operating.- Specified by:
isRunningin interfaceIReasonerInstance- Returns:
truefor operating,falseelse
-
stop
public boolean stop()
Description copied from interface:IReasonerInstanceStops/terminates reasoning. If possible, a reasoner shall stop the reasoning operations as quick as possible. A reasoner must not implement this operation.- Specified by:
stopin interfaceIReasonerInstance- Returns:
trueif the reasoner tries to stop,falseelse (operation not implemented)- See Also:
ReasoningResult.setStopped(boolean)
-
getProject
public Project getProject()
Description copied from interface:IReasonerInstanceReturns the project this instance is attached to.- Specified by:
getProjectin interfaceIReasonerInstance- Returns:
- the project
-
getReasonerConfiguration
public ReasonerConfiguration getReasonerConfiguration()
Description copied from interface:IReasonerInstanceReturns the reasoner configuration this project is running with.- Specified by:
getReasonerConfigurationin interfaceIReasonerInstance- Returns:
- the reasoner configuration
-
-