]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java
Multiple readers and variable optimization
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / adapter / SCLExternalValue.java
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/SCLExternalValue.java
new file mode 100644 (file)
index 0000000..12e950c
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.db.layer0.adapter;
+
+import org.simantics.db.ConverterExternalValue;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.scl.CompileValueRequest;
+import org.simantics.layer0.Layer0;
+import org.simantics.scl.reflection.ReflectionUtils;
+import org.simantics.scl.reflection.ValueNotFoundException;
+import org.simantics.scl.runtime.function.Function1;
+
+public class SCLExternalValue implements ConverterExternalValue {
+
+       @Override
+       public <T> T getValue(ReadGraph graph, Resource resource) throws DatabaseException {
+               try {
+                       return (T)ReflectionUtils.getValue(Layer0.URIs.Functions_computeExpression).getValue();
+               } catch (ValueNotFoundException e) {
+                       throw new DatabaseException(e);
+               }
+       }
+
+       @Override
+       public Function1 getFunction(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException {
+               return CompileValueRequest.compile(graph, s, o, p);
+       }
+
+}