DUECA/DUSIME
|
A Snapshot object can be used to send the data from a state snapshot, i.e. More...
#include <Snapshot.hxx>
Public Types | |
enum | SnapCoding { UnSpecified , Base64 , JSON , XML , Floats , Doubles , BinaryFile , FloatFile , DoubleFile , JSONFile , XMLFile , Base64File } |
Enumerated type for an automatically generated object class. More... | |
typedef Snapshot | __ThisDCOType__ |
typedef for internal reference | |
Public Member Functions | |
Snapshot () | |
default constructor. | |
Snapshot (const dueca::smartstring &data, const NameSet &originator, const SnapCoding &coding) | |
Constructor with arguments. | |
Snapshot (const Snapshot &o) | |
copy constructor. | |
Snapshot (::dueca::AmorphReStore &r) | |
constructor to restore an Snapshot from amorphous storage. | |
~Snapshot () | |
destructor. | |
void | packData (::dueca::AmorphStore &s) const |
packs the Snapshot into amorphous storage. | |
void | packDataDiff (::dueca::AmorphStore &s, const Snapshot &ref) const |
packs the Snapshot into amorphous storage. | |
void | unPackData (::dueca::AmorphReStore &s) |
unpacks the Snapshot from an amorphous storage. | |
void | unPackDataDiff (::dueca::AmorphReStore &s) |
unpacks the differences for Snapshot from an amorphous storage. | |
bool | operator== (const Snapshot &o) const |
Test for equality. | |
bool | operator!= (const Snapshot &o) const |
Test for inequality. | |
Snapshot & | operator= (const Snapshot &o) |
Assignment operator. | |
std::ostream & | print (std::ostream &s) const |
prints the Snapshot to a stream. | |
Static Public Member Functions | |
static void * | operator new (size_t size) |
new operator "new", which places objects not on a heap, but in one of the memory arenas. | |
static void | operator delete (void *p) |
new operator "delete", to go with the new version of operator new. | |
static void * | operator new (size_t size, Snapshot *&o) |
placement "new", needed for stl. | |
Public Attributes | |
dueca::smartstring | data |
A place for the data, variable size. | |
NameSet | originator |
Identifies the object that sent the snapshot. | |
SnapCoding | coding |
Snapshot encoding, if specified. | |
Static Public Attributes | |
static const char *const | classname |
The name of this class. | |
static const uint32_t | magic_check_number |
a "magic" number, hashed out of the class definition, that will be used to check consistency of the sent objects across the dueca nodes. | |
A Snapshot object can be used to send the data from a state snapshot, i.e.
the data describing a (piece of) your model state in time, to a repository for snapshot, and conversely, for sending this data back to a SimulationModule, for restoration of an old state.
The Snapshot object allocates a data buffer for you. It is possible to use an AmorphStore object to pack the data in this buffer, like:
Alternatively, the snapshot can be packed with JSON or XML data. The "data" member in the snapshot is a smart string that can be easily fed with data, first a JSON example, using rapidjson:
The same can be done with XML, using pugixml. Of course, you might encounter code with the "old" XMLSnapshot approach, that produces equally valid XML
Enumerated type for an automatically generated object class.
Enumerator | |
---|---|
UnSpecified | old-style, no indication about coding. Treated as Base64 |
Base64 | probably AmorphStore coded binary, stored in Base64 in toml |
JSON | data directly encoded and stored as JSON string in inco toml |
XML | data directly encoded and stored as XML string in inco toml |
Floats | data encoded in AmorphStore, all floats, stored in toml |
Doubles | data encoded in AmorphStore, all doubles, stored in toml |
BinaryFile | External binary file, binary storage, no information on format. |
FloatFile | External ASCII formatted file, data AmorphStore packed as floats. |
DoubleFile | External ASCII formatted file, data AmorphStore packed as double. |
JSONFile | data directly encoded and stored as JSON string in external file |
XMLFile | data directly encoded and stored as XML string in external file |
Base64File | data stored in Base64 in external file |
new operator "new", which places objects not on a heap, but in one of the memory arenas.
This to speed up memory management.
void dueca::Snapshot::packDataDiff | ( | ::dueca::AmorphStore & | s, |
const Snapshot & | ref ) const |
packs the Snapshot into amorphous storage.
only differences with a previous object are packed.
dueca::smartstring dueca::Snapshot::data |
A place for the data, variable size.
Use this with ASCII converted data (XML, JSON), or use an AmorphStore to pack as binary data.