]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/VariableStructuralContext.java
Multiple readers and variable optimization
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / VariableStructuralContext.java
1 package org.simantics.modeling;
2
3 import org.simantics.databoard.adapter.AdaptException;
4 import org.simantics.databoard.binding.Binding;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.db.layer0.variable.Variable;
9
10 public class VariableStructuralContext extends org.simantics.structural2.scl.VariableStructuralContext {
11
12         final private Variable selfVariable;
13         
14         public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException {
15                 super(graph, selfVariable);
16                 this.selfVariable = selfVariable;
17         }
18
19     public VariableStructuralContext(Variable selfVariable, Variable variable) throws DatabaseException {
20         super(variable);
21         this.selfVariable = selfVariable;
22     }
23
24         @Override
25         public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException {
26                 ModelingResources MOD = ModelingResources.getInstance(g);
27                 if(MOD.self.equals(attribute)) return selfVariable;
28                 return super.getValue(g, attribute, binding);
29         }
30
31 }