Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
Allow the external definition of functions in RuleEvaluation (#55)
Browse files Browse the repository at this point in the history
* Added function to count number of answered questions

* Moved CountDefinedElements from Archie to Chiron
  • Loading branch information
tanja-de-jong authored Oct 30, 2017
1 parent df091bd commit a1a9463
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class RuleEvaluation {
private Archetype archetype;
private List<Evaluator> evaluators = new ArrayList<>();
private HashMap<Class, Evaluator> classToEvaluator = new HashMap<>();
private FunctionEvaluator functionEvaluator;

//evaluation state
private Pathable root;
Expand All @@ -63,6 +64,7 @@ public class RuleEvaluation {

public RuleEvaluation(Archetype archetype) {
this.archetype = archetype;
this.functionEvaluator = new FunctionEvaluator();
add(new VariableDeclarationEvaluator());
add(new ConstantEvaluator());
add(new AssertionEvaluator());
Expand All @@ -71,7 +73,7 @@ public RuleEvaluation(Archetype archetype) {
add(new VariableReferenceEvaluator());
add(new ModelReferenceEvaluator());
add(new ForAllEvaluator());
add(new FunctionEvaluator());
add(functionEvaluator);
}

private void add(Evaluator evaluator) {
Expand Down Expand Up @@ -110,6 +112,10 @@ public ValueList evaluate(RuleElement rule) {
throw new UnsupportedOperationException("no evaluator present for rule type " + rule.getClass().getSimpleName());
}

public void registerFunction(FunctionImplementation function) {
functionEvaluator.registerFunction(function);
}

public Pathable getRMRoot() {
return root;
}
Expand Down

0 comments on commit a1a9463

Please sign in to comment.