diff options
author | 2021-08-16 00:38:53 +0200 | |
---|---|---|
committer | 2021-08-16 00:38:53 +0200 | |
commit | 2ecb097b5d5af7edfe9ad38179beff1d14029f29 (patch) | |
tree | 28dfe996aa0286ee19af92712dd53ebbd3d9a110 /model-data | |
parent | renaming (diff) | |
download | refinery-2ecb097b5d5af7edfe9ad38179beff1d14029f29.tar.gz refinery-2ecb097b5d5af7edfe9ad38179beff1d14029f29.tar.zst refinery-2ecb097b5d5af7edfe9ad38179beff1d14029f29.zip |
changend the visibility of view.arity
Diffstat (limited to 'model-data')
3 files changed, 20 insertions, 3 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java index 2f4661ae..713673e2 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.query.relationView; | 1 | package org.eclipse.viatra.solver.data.query.view; |
2 | 2 | ||
3 | import org.eclipse.viatra.solver.data.model.Model; | 3 | import org.eclipse.viatra.solver.data.model.Model; |
4 | import org.eclipse.viatra.solver.data.model.Tuple; | 4 | import org.eclipse.viatra.solver.data.model.Tuple; |
@@ -32,4 +32,9 @@ public abstract class FilteredRelationView<D> extends RelationView<D>{ | |||
32 | } | 32 | } |
33 | return result; | 33 | return result; |
34 | } | 34 | } |
35 | |||
36 | @Override | ||
37 | public int getArity() { | ||
38 | return this.representation.getSymbol().getArity(); | ||
39 | } | ||
35 | } | 40 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java index 69001606..03c25641 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.query.relationView; | 1 | package org.eclipse.viatra.solver.data.query.view; |
2 | 2 | ||
3 | import org.eclipse.viatra.solver.data.model.Model; | 3 | import org.eclipse.viatra.solver.data.model.Model; |
4 | import org.eclipse.viatra.solver.data.model.Tuple; | 4 | import org.eclipse.viatra.solver.data.model.Tuple; |
@@ -42,4 +42,9 @@ public class FunctionalRelationView<D> extends RelationView<D> { | |||
42 | result[t.getSize()] = value; | 42 | result[t.getSize()] = value; |
43 | return result; | 43 | return result; |
44 | } | 44 | } |
45 | |||
46 | @Override | ||
47 | public int getArity() { | ||
48 | return this.representation.getSymbol().getArity()+1; | ||
49 | } | ||
45 | } | 50 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java index 08296705..efd8e990 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java | |||
@@ -1,9 +1,10 @@ | |||
1 | package org.eclipse.viatra.solver.data.query.relationView; | 1 | package org.eclipse.viatra.solver.data.query.view; |
2 | 2 | ||
3 | import org.eclipse.viatra.solver.data.map.CursorAsIterator; | 3 | import org.eclipse.viatra.solver.data.map.CursorAsIterator; |
4 | import org.eclipse.viatra.solver.data.model.Model; | 4 | import org.eclipse.viatra.solver.data.model.Model; |
5 | import org.eclipse.viatra.solver.data.model.Tuple; | 5 | import org.eclipse.viatra.solver.data.model.Tuple; |
6 | import org.eclipse.viatra.solver.data.model.representation.Relation; | 6 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
7 | import org.eclipse.viatra.solver.data.query.internal.RelationViewKey; | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * Represents a view of a {@link Relation} that can be queried. | 10 | * Represents a view of a {@link Relation} that can be queried. |
@@ -14,6 +15,7 @@ import org.eclipse.viatra.solver.data.model.representation.Relation; | |||
14 | public abstract class RelationView<D>{ | 15 | public abstract class RelationView<D>{ |
15 | protected final Model model; | 16 | protected final Model model; |
16 | protected final Relation<D> representation; | 17 | protected final Relation<D> representation; |
18 | RelationViewKey<D> key = new RelationViewKey<>(this, getArity()); | ||
17 | 19 | ||
18 | protected RelationView(Model model, Relation<D> representation) { | 20 | protected RelationView(Model model, Relation<D> representation) { |
19 | this.model = model; | 21 | this.model = model; |
@@ -27,6 +29,7 @@ public abstract class RelationView<D>{ | |||
27 | return representation; | 29 | return representation; |
28 | } | 30 | } |
29 | 31 | ||
32 | public abstract int getArity(); | ||
30 | protected abstract boolean filter(Tuple key, D value); | 33 | protected abstract boolean filter(Tuple key, D value); |
31 | protected abstract Object[] forwardMap(Tuple key, D value); | 34 | protected abstract Object[] forwardMap(Tuple key, D value); |
32 | public abstract boolean get(Object[] tuple); | 35 | public abstract boolean get(Object[] tuple); |
@@ -40,4 +43,8 @@ public abstract class RelationView<D>{ | |||
40 | public Iterable<Object[]> getAll() { | 43 | public Iterable<Object[]> getAll() { |
41 | return (()->new CursorAsIterator<>(model.getAll(representation), (k,v)->forwardMap(k,v), (k,v)->filter(k,v))); | 44 | return (()->new CursorAsIterator<>(model.getAll(representation), (k,v)->forwardMap(k,v), (k,v)->filter(k,v))); |
42 | } | 45 | } |
46 | |||
47 | public RelationViewKey<D> getKey() { | ||
48 | return key; | ||
49 | } | ||
43 | } | 50 | } |