X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fprotocol%2FSynchronizationEventHandler.java;fp=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fprotocol%2FSynchronizationEventHandler.java;h=0a468e42ace5dd5a75503c858cfa3272a5c0a24f;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 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 index 000000000..0a468e42a --- /dev/null +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SynchronizationEventHandler.java @@ -0,0 +1,57 @@ +package org.simantics.structural.synchronization.protocol; + +import java.util.Collection; + +/** + * Communicates synchronization events from the synchronizer + * browsing variable structure to the simulator. + * + * TODO: + * - which properties available in the variable are sent (based on classification) + * - what to do when resource ids change (export/import) + */ +public interface SynchronizationEventHandler { + + + /** + * Called at the beginning of synchronization. All other + * methods must be called between beginSynchronization/endSynchronization pair. + */ + void beginSynchronization(); + + /** + * Called at the end of synchronization. + */ + void endSynchronization(); + + /** + * Describes a component + */ + void beginComponent( + String name, + String typeId, + Collection properties, + Collection connections, + Collection children) throws SynchronizationException; + + void endComponent(); + + /* + * TODO: maybe we require that whenever a type is updated all its instances are also updated + */ + void beginType( + String id, + Collection properties) throws SynchronizationException; + void endType(); + + void reportProblem(String description); + + void reportProblem(String description, Exception e); + + /** + * Called when an error happens during synchronization that prevents its continuation. + * Returns true, if the handler was able to fix the state of the mapping. If false, + * the current state is unusable and should be discarded. + */ + //boolean cleanUpAfterSynchronizationFailure(); +}