]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SynchronizationEventHandler.java
Separate DB and non-DB code to different structural sync bundles
[simantics/platform.git] / bundles / org.simantics.structural.synchronization / src / org / simantics / structural / synchronization / protocol / SynchronizationEventHandler.java
1 package org.simantics.structural.synchronization.protocol;
2
3 import java.util.Collection;
4
5 /**
6  * Communicates synchronization events from the synchronizer
7  * browsing variable structure to the simulator.
8  * 
9  * TODO:
10  * - which properties available in the variable are sent (based on classification)
11  * - what to do when resource ids change (export/import)
12  */
13 public interface SynchronizationEventHandler {
14     
15     
16     /**
17      * Called at the beginning of synchronization. All other
18      * methods must be called between beginSynchronization/endSynchronization pair.
19      */
20     void beginSynchronization();
21     
22     /**
23      * Called at the end of synchronization.
24      */
25     void endSynchronization();
26     
27     /**
28      * Describes a component
29      */
30     void beginComponent(
31             String name,
32             String typeId,
33             Collection<SerializedVariable> properties,
34             Collection<Connection> connections,
35             Collection<ChildInfo> children) throws SynchronizationException;
36     
37     void endComponent();
38
39     /*
40      * TODO: maybe we require that whenever a type is updated all its instances are also updated
41      */
42     void beginType(
43             String id,
44             Collection<SerializedVariable> properties) throws SynchronizationException;
45     void endType();
46
47     void reportProblem(String description);
48
49     void reportProblem(String description, Exception e);
50     
51     /**
52      * Called when an error happens during synchronization that prevents its continuation.
53      * Returns true, if the handler was able to fix the state of the mapping. If false,
54      * the current state is unusable and should be discarded.
55      */
56     //boolean cleanUpAfterSynchronizationFailure();
57 }