--- /dev/null
+package org.simantics.interop.scl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.simantics.scl.runtime.function.Function;
+import org.simantics.utils.datastructures.MapList;
+
+@SuppressWarnings({"rawtypes","unchecked"})
+public class FunctionRegistry {
+
+
+ static Map<Object, MapList<String, Function>> map = new HashMap<Object, MapList<String,Function>>();
+
+ public static void register(Object key, String name, Function f) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null) {
+ fmap = new MapList<>();
+ map.put(key, fmap);
+ }
+ fmap.add(name, f);
+ }
+
+ public static void call0 (Object key, String name) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ for (Function f : fmap.getValues(name)) {
+ f.apply(null);
+ }
+ }
+
+
+ public static void call1 (Object key, String name, Object o1) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ for (Function f : fmap.getValues(name)) {
+ f.apply(o1);
+ }
+ }
+
+ public static void call2 (Object key, String name, Object o1, Object o2) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ for (Function f : fmap.getValues(name)) {
+ f.apply(o1,o2);
+ }
+ }
+
+ public static void call3 (Object key, String name, Object o1, Object o2, Object o3) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ for (Function f : fmap.getValues(name)) {
+ f.apply(o1,o2,o3);
+ }
+ }
+
+ public static void call4 (Object key, String name, Object o1, Object o2, Object o3, Object o4) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ for (Function f : fmap.getValues(name)) {
+ f.apply(o1,o2,o3,o4);
+ }
+ }
+
+ public static void clear(Object key) {
+ map.remove(key);
+ }
+
+ public static void clear(Object key, String name) {
+ MapList<String, Function> fmap = map.get(key);
+ if (fmap == null)
+ return;
+ fmap.remove(name);
+ }
+
+
+}