Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
|
#include <SerializableSingleton.hpp>
Public Member Functions | |
SerializableSingleton< SINGLETON_CLASS > * | GetSerializationWrapper () const |
Private Member Functions | |
template<class Archive > | |
void | save (Archive &archive, const unsigned int version) const |
template<class Archive > | |
void | load (Archive &archive, const unsigned int version) |
Friends | |
class | boost::serialization::access |
This is a "wrapper" allowing more straightforward serialization of singleton classes. Any singleton class which needs to be serialized should inherit from this base. It provides both part of the "singleton-ness" (by inheriting from boost::noncopyable), and also a method GetSerializationWrapper(). Users of the singleton which wish to serialize it should not do so directly. Instead, they should call GetSerializationWrapper and serialize the returned pointer. Doing so will ensure that only a single global instance of the singleton is maintained when loading from an archive.
Note that if this is not done, and the singleton is serialized directly via the instance pointer, then objects loaded from the archive will refer to a different instance of the singleton from other code!
Usage examples:
For saving:
For loading:
Within a serialize method:
Note that immediately after a load the wrapper pointer loaded into becomes invalid; call GetSerializationWrapper again if you need a new wrapper for a subsequent save.
Definition at line 80 of file SerializableSingleton.hpp.
|
inline |
Definition at line 86 of file SerializableSingleton.hpp.
Referenced by AbstractCellCycleModel::serialize(), BernoulliTrialCellCycleModel::serialize(), BiasedBernoulliTrialCellCycleModel::serialize(), ExponentialG1GenerationalCellCycleModel::serialize(), FixedSequenceCellCycleModel::serialize(), GammaG1CellCycleModel::serialize(), LabelDependentBernoulliTrialCellCycleModel::serialize(), StochasticOxygenBasedCellCycleModel::serialize(), UniformCellCycleModel::serialize(), UniformG1GenerationalCellCycleModel::serialize(), AbstractSrnModel::serialize(), RandomCellKiller< DIM >::serialize(), AbstractCellBasedSimulation< ELEMENT_DIM, SPACE_DIM >::serialize(), StochasticWntCellCycleModel::serialize(), CryptSimulation1d::serialize(), and CryptSimulation2d::serialize().
|
inlineprivate |
Load the wrapped singleton.
archive | the archive |
version | the saved version of this class |
Definition at line 115 of file SerializableSingleton.hpp.
|
inlineprivate |
Save the wrapped singleton.
archive | the archive |
version | the current version of this class |
Definition at line 101 of file SerializableSingleton.hpp.
|
friend |
Definition at line 92 of file SerializableSingleton.hpp.