+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