-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable exporting and importing subsimulator state #769
base: dev/state-persistence
Are you sure you want to change the base?
Enable exporting and importing subsimulator state #769
Conversation
This is a follow-up to #765 and the second and final step to close #756. Here, I've implemented functionality to export the internal state of individual subsimulators in a generic, structured form, and to import them again later. This exported form is intended as an intermediate step before serialisation and disk storage. The idea was to create a type that can be inspected and serialised to almost any file format we'd like. The type is defined by `cosim::serialization::node` in `cosim/serialization.hpp`. It is a hierarchical, dynamic data type with support for a variety of primitive scalar types and a few aggregate types: strings, arrays of nodes, dictionaries of nodes, and binary blobs. (Think JSON, only with more types.)
Hm. Seems like my little trick of storing an incomplete |
Ok, I made it work now. It seems that to make a recursive map-like data type in standard C++, one has to hide the internal type, for example by messing about with |
@@ -290,8 +291,6 @@ class slave | |||
* `state_index`. The index is only valid for this particular slave. | |||
* | |||
* The function may be called at any point after `setup()` has been called. | |||
* | |||
* \pre `this->model_description().can_save_state` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the removal on lines 304–305 was just something I missed in #765.
This is a follow-up to #765 and the second and final step to close #756. It is part of a PR series which will culminate in the implementation of #757, and until that point, I am targeting the
dev/state-persistence
branch rather thanmaster
.Here, I've implemented functionality to export the internal state of individual subsimulators in a generic, structured form, and to import it again later.
This exported form is intended as an intermediate step before serialisation to disk. The idea was to create a type that can be inspected and serialised to almost any file format we'd like.
The type is defined by
cosim::serialization::node
incosim/serialization.hpp
. It is a hierarchical, dynamic data type with support for a variety of primitive scalar types and a few aggregate types: strings, arrays of nodes, dictionaries of nodes, and binary blobs. (Think JSON-like structure, only in-memory and with more types.)Edit:
node
was originally a homebrew type. Now, it is based on Boost.PropertyTree. Otherwise, the description above still fits pretty well.