Empirical
|
Tools to save and load data from classes. More...
Go to the source code of this file.
Classes | |
class | emp::serialize::DataPod |
A DataPod managed information about another class for serialization. More... | |
struct | emp::serialize::internal::serial_impl< IGNORE > |
struct | emp::serialize::internal::serial_impl< FIRST_TYPE, OTHER_TYPES... > |
struct | emp::serialize::internal::serial_impl<> |
Namespaces | |
emp | |
If we are in emscripten, make sure to include the header. | |
emp::serialize | |
emp::serialize::internal | |
Functions | |
template<typename T > | |
auto | emp::serialize::StoreVar (DataPod &pod, const T &var, bool) -> typename T::emp_load_return_type & |
template<typename T > | |
void | emp::serialize::StoreVar (DataPod &pod, const emp::vector< T > &var, bool) |
template<typename T > | |
void | emp::serialize::StoreVar (DataPod &pod, const T &var, int) |
template<typename T > | |
auto | emp::serialize::SetupLoad (DataPod &pod, T *, bool) -> typename T::emp_load_return_type & |
template<typename T > | |
auto | emp::serialize::SetupLoad (DataPod &pod, const T *, int) -> T |
std::string | emp::serialize::SetupLoad (DataPod &pod, std::string *, bool) |
template<typename T > | |
emp::vector< T > | emp::serialize::SetupLoad (DataPod &pod, emp::vector< T > *, bool) |
template<typename... ARG_TYPES> | |
void | emp::serialize::Store (DataPod &pod, ARG_TYPES &...args) |
Tools to save and load data from classes.
All of the important information about a class is stored in a DataPod, which can be used to restore the class at a later time.
Why is this better than other serialization techniques?
In order to setup a target class to be able to be serialized into a pod, you must add a macro to include the needed functionality. For a basic class, use:
EMP_SETUP_DATAPOD(ClassName, var1, var2, ...)
Where ClassName is the target class' name and var1, var2, etc are the names of the member variables that also need to be stored. Note that member variables can either be either built-in types or custom types that have also had DataPods setup in them.
If the target class is a derived class, you must use either:
EMP_SETUP_DATAPOD_D(ClassName, BassClassName, var1, var2, ...)
-or-
EMP_SETUP_DATAPOD_D2(ClassName, BassClass1Name, BaseClass2Name, var1, var2, ...)
...depending on how many base classes it was derived from (currently max 2).
Note also that this macro must either go in the public section of the target class definition, or the target class must be made a friend to the emp::serialize::DataPod class.
Build custom load/store function for more STL objects (especially containers)
To deal with pointers we should recurse, but keep map to new pointer locations.
Setup a more robust method for dealing with arbitrary strings so we don't have to worry about collisions in streams (JSon format??)
Setup a (compressed) binary save formmat in DataPods in addition to JSon.
Setup promised synergistic interactions with config and tuple_struct to auto store and load without any additional effort on the part of the library user.