| | 11 | == Protocols == |
| | 12 | |
| | 13 | === Saving protocol: === |
| | 14 | 1. visit all session state and record: |
| | 15 | * what tool is responsible for the state |
| | 16 | * what data it refers to and |
| | 17 | * only referred to data needs to be named |
| | 18 | 1. save the list of used tools |
| | 19 | * need tool's state version, not tool version |
| | 20 | 1. serialize state |
| | 21 | * keep track of named data that was saved |
| | 22 | 1. confirm that all referred to data was saved |
| | 23 | * if not, then the session is incomplete/corrupt |
| | 24 | |
| | 25 | === Restoring protocol: === |
| | 26 | 1. Read the list of used tools |
| | 27 | * if installed tools are insufficient, then give user option to cancel or load tools |
| | 28 | 1. deserialze state inside block/unblock of triggers |
| | 29 | |
| | 30 | |
| 52 | | Saving protocol: |
| 53 | | 1. visit all session state and record: |
| 54 | | * what tool is responsible for the state |
| 55 | | * what data it refers to and |
| 56 | | * only referred to data needs to be named |
| 57 | | 1. save the list of used tools |
| 58 | | 1. serialize state |
| 59 | | * keep track of named data that was saved |
| 60 | | 1. confirm that all referred to data was saved |
| | 73 | Two competing solutions: |
| | 74 | 1. allow circular references via two-phase initialization |
| | 75 | * like Python's pickle |
| | 76 | 2. Specify dependencies and save/restore in the right order |
| | 80 | * molecular data needs to be saved early |
| | 81 | * molecular data is in a model |
| | 82 | * session gets a model from its list of models |
| | 83 | * a tool may provide a new model that depends on molecular data and tool state |
| | 84 | * so some models will need to saved before others |
| | 85 | * so some tools may need to saved before associated model |
| | 86 | * does that mean that tools are saved first? |
| | 87 | * ordering is complicated |
| | 88 | |
| | 89 | === The Solution === |
| | 90 | |
| | 91 | Circular dependencies are natural. So use two-phase initialization when deserializing a session. |
| | 92 | |
| | 93 | Really don't want to use two-phase initialization for C++ objects. So don't. As long as the C++ objects are restored all together (i.e., atomic structures and pseudobonds), we can avoid two-phase initialization for them. If the C++ objects refer to Python objects, that part would need to follow a two-phase protocol. |
| | 94 | |
| | 95 | On the Python side, it is possible to provide an API that takes "simple" data and implements all of the individual save and restore steps. |