]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SynchronizationEventHandler.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.structural.synchronization / src / org / simantics / structural / synchronization / protocol / SynchronizationEventHandler.java
diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SynchronizationEventHandler.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SynchronizationEventHandler.java
new file mode 100644 (file)
index 0000000..0a468e4
--- /dev/null
@@ -0,0 +1,57 @@
+package org.simantics.structural.synchronization.protocol;\r
+\r
+import java.util.Collection;\r
+\r
+/**\r
+ * Communicates synchronization events from the synchronizer\r
+ * browsing variable structure to the simulator.\r
+ * \r
+ * TODO:\r
+ * - which properties available in the variable are sent (based on classification)\r
+ * - what to do when resource ids change (export/import)\r
+ */\r
+public interface SynchronizationEventHandler {\r
+    \r
+    \r
+    /**\r
+     * Called at the beginning of synchronization. All other\r
+     * methods must be called between beginSynchronization/endSynchronization pair.\r
+     */\r
+    void beginSynchronization();\r
+    \r
+    /**\r
+     * Called at the end of synchronization.\r
+     */\r
+    void endSynchronization();\r
+    \r
+    /**\r
+     * Describes a component\r
+     */\r
+    void beginComponent(\r
+            String name,\r
+            String typeId,\r
+            Collection<SerializedVariable> properties,\r
+            Collection<Connection> connections,\r
+            Collection<ChildInfo> children) throws SynchronizationException;\r
+    \r
+    void endComponent();\r
+\r
+    /*\r
+     * TODO: maybe we require that whenever a type is updated all its instances are also updated\r
+     */\r
+    void beginType(\r
+            String id,\r
+            Collection<SerializedVariable> properties) throws SynchronizationException;\r
+    void endType();\r
+\r
+    void reportProblem(String description);\r
+\r
+    void reportProblem(String description, Exception e);\r
+    \r
+    /**\r
+     * Called when an error happens during synchronization that prevents its continuation.\r
+     * Returns true, if the handler was able to fix the state of the mapping. If false,\r
+     * the current state is unusable and should be discarded.\r
+     */\r
+    //boolean cleanUpAfterSynchronizationFailure();\r
+}\r