DUECA/DUSIME
|
A Snapshot object can be used to send the data from a state snapshot, i.e. More...
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. More... | |
Snapshot (const dueca::smartstring &data, const NameSet &originator, const SnapCoding &coding) | |
Constructor with arguments. | |
Snapshot (const Snapshot &o) | |
copy constructor. More... | |
Snapshot (::dueca::AmorphReStore &r) | |
constructor to restore an Snapshot from amorphous storage. More... | |
~Snapshot () | |
destructor. More... | |
void | packData (::dueca::AmorphStore &s) const |
packs the Snapshot into amorphous storage. More... | |
void | packDataDiff (::dueca::AmorphStore &s, const Snapshot &ref) const |
packs the Snapshot into amorphous storage. More... | |
void | unPackData (::dueca::AmorphReStore &s) |
unpacks the Snapshot from an amorphous storage. More... | |
void | unPackDataDiff (::dueca::AmorphReStore &s) |
unpacks the differences for Snapshot from an amorphous storage. More... | |
bool | operator== (const Snapshot &o) const |
Test for equality. More... | |
bool | operator!= (const Snapshot &o) const |
Test for inequality. More... | |
Snapshot & | operator= (const Snapshot &o) |
Assignment operator. More... | |
std::ostream & | print (std::ostream &s) const |
prints the Snapshot to a stream. More... | |
Snapshot (size_t data_size, SnapCoding coding=UnSpecified) | |
Constructor. More... | |
Snapshot (dueca::DataWriterArraySize data_size, SnapCoding coding=UnSpecified) | |
Constructor. More... | |
Snapshot (size_t data_size, const NameSet &originator, SnapCoding coding=UnSpecified) | |
Constructor. More... | |
Snapshot (const toml::value &coded) | |
Constructor from a toml-parsed object. | |
toml::value | tomlCode (const std::string &fname=std::string()) const |
Create a toml object. | |
bool | saveExternal () const |
return true if the snapshot is to be saved in an external file | |
const char * | fileExtension () const |
Return an appropriate extension for an external file. | |
const char * | accessData () const |
This directly accesses the data area of the snapshot. More... | |
char * | accessData () |
This directly accesses the data area of the snapshot. More... | |
char * | AllocAndAccessData (uint32_t dsize) |
This initializes, and subsequently accesses the data area of the snapshot. More... | |
uint32_t | getDataSize () const |
Read back the maximum size of the data. | |
std::string | getSample (unsigned size=20) const |
Return the complete snapshot, or a sample. More... | |
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. More... | |
static void | operator delete (void *p) |
new operator "delete", to go with the new version of operator new. More... | |
static void * | operator new (size_t size, Snapshot *&o) |
placement "new", needed for stl. More... | |
Public Attributes | |
dueca::smartstring | data |
A place for the data, variable size. More... | |
NameSet | originator |
Identifies the object that sent the snapshot. | |
SnapCoding | coding |
Snapshot encoding, if specified. | |
size_t | data_size |
For convenience, additional data_size member. | |
Static Public Attributes | |
static const char *const | classname |
The name of this class. More... | |
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. More... | |
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 |
dueca::Snapshot::Snapshot | ( | ) |
default constructor.
dueca::Snapshot::Snapshot | ( | const Snapshot & | o | ) |
copy constructor.
dueca::Snapshot::Snapshot | ( | ::dueca::AmorphReStore & | r | ) |
constructor to restore an Snapshot from amorphous storage.
dueca::Snapshot::~Snapshot | ( | ) |
destructor.
dueca::Snapshot::Snapshot | ( | size_t | data_size, |
SnapCoding | coding = UnSpecified |
||
) |
Constructor.
The Snapshot constructor at this point allocates room for the data you want to send. Use the accessData() method to access this room. Careful! There is no protection here, please don't mis-use or your application might fail.
dueca::Snapshot::Snapshot | ( | dueca::DataWriterArraySize | data_size, |
SnapCoding | coding = UnSpecified |
||
) |
Constructor.
The Snapshot constructor at this point allocates room for the data you want to send. Use the accessData() method to access this room. Careful! There is no protection here, please don't mis-use or your application might fail.
dueca::Snapshot::Snapshot | ( | size_t | data_size, |
const NameSet & | originator, | ||
SnapCoding | coding = UnSpecified |
||
) |
Constructor.
The Snapshot constructor at this point allocates room for the data you want to send. Use the accessData() method to access this room. Careful! There is no protection here, please don't mis-use or your application might fail.
|
static |
new operator "new", which places objects not on a heap, but in one of the memory arenas.
This to speed up memory management.
|
static |
new operator "delete", to go with the new version of operator new.
|
inlinestatic |
placement "new", needed for stl.
void dueca::Snapshot::packData | ( | ::dueca::AmorphStore & | s | ) | const |
packs the Snapshot into amorphous storage.
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.
void dueca::Snapshot::unPackData | ( | ::dueca::AmorphReStore & | s | ) |
unpacks the Snapshot from an amorphous storage.
void dueca::Snapshot::unPackDataDiff | ( | ::dueca::AmorphReStore & | s | ) |
unpacks the differences for Snapshot from an amorphous storage.
bool dueca::Snapshot::operator== | ( | const Snapshot & | o | ) | const |
Test for equality.
|
inline |
Test for inequality.
std::ostream& dueca::Snapshot::print | ( | std::ostream & | s | ) | const |
prints the Snapshot to a stream.
|
inline |
This directly accesses the data area of the snapshot.
Please be careful, there is no protection here.
|
inline |
This directly accesses the data area of the snapshot.
Please be careful, there is no protection here.
|
inline |
This initializes, and subsequently accesses the data area of the snapshot.
Please be careful, there is no protection here.
std::string dueca::Snapshot::getSample | ( | unsigned | size = 20 | ) | const |
Return the complete snapshot, or a sample.
|
static |
The name of this class.
dueca::smartstring dueca::Snapshot::data |
A place for the data, variable size.
Use this with ASCII converted data, or use an AmorphStore to pack. The intention for the future developments is to use snapshots that derive from a base type, allowing more freedom for the user's code
|
static |
a "magic" number, hashed out of the class definition, that will be used to check consistency of the sent objects across the dueca nodes.