DUECA/DUSIME
|
Amorphous storage object of variable size. More...
#include <AmorphStore.hxx>
Public Member Functions | |
AmorphStore () | |
Constructor for an un-initialised store, has no memory. | |
AmorphStore (char *store, unsigned capacity) | |
Constructor for an initial store, with memory borrowed somewhere else. | |
~AmorphStore () | |
Destructor. | |
void | acceptBuffer (char *store, unsigned capacity) |
initialise a store with borrowed memory. | |
void | renewBuffer (unsigned capacity) |
re-initialise the store's memory. | |
const char * | getToData () const |
access to the data of the store. | |
void | startMark () |
Ask for a mark, a 2-byte (uint16_t) number that contains the size of the data up to the end mark. | |
template<class T > | |
StoreMark< T > | createMark (T dum) |
Ask for a mark, a 2-byte (uint16_t) number that contains the size of the data or the number of data items up to the end mark. | |
template<class T > | |
unsigned | finishMark (const StoreMark< T > &m) |
Finish the mark, this codes the size of the packed data since the mark. | |
template<class T > | |
void | finishMark (const StoreMark< T > &m, T n) |
Finish the mark, this codes the number supplied to the call. | |
void | endMark () |
Call this after packing all data after the startMark() call. | |
void | startBigMark () |
Ask for a big mark, a 4-byte (uint32_t) number that contains the size of the data up to the end mark. | |
void | endBigMark () |
Call this after packing all data after the startBigMark() call. | |
const unsigned | getSize () const |
query the current size of the stored data. | |
unsigned | roundSize4 () |
round off the size of the store to a multiple of four, necessary for word-wide communications hardware. | |
void | setSize (unsigned p_index) |
Modify the current size of the stored data. | |
void | reUse () |
Reuse the store, meaning to flush it completely and start packing new data. | |
void | reUse (unsigned capacity) |
Reuse the store, meaning to flush it completely and start packing new data. | |
bool | isChoked () const |
If this returns true, there is no more room in the store. | |
void | setChoked () |
Flag the store as choked, i.e. | |
bool | checkForRoom (const unsigned size) const |
Check for room in the store. | |
void | packData (const float &f) |
Pack a float into the store. | |
void | packData (const double &d) |
Pack a double into the store. | |
void | packData (const char &i) |
Pack a char into the store. | |
void | packData (const int8_t &i) |
Pack an int8_t into the store. | |
void | packData (const int16_t &i) |
Pack an int16_t into the store. | |
void | packData (const int32_t &i) |
Pack an int32_t into the store. | |
void | packData (const int64_t &i) |
Pack an int64_t into the store. | |
void | packData (const uint8_t &i) |
Pack an uint8_t into the store. | |
void | packData (const uint16_t &i) |
Pack an uint16_t into the store. | |
void | packData (const uint32_t &i) |
Pack an uint32_t into the store. | |
void | placeData (const uint8_t &i, unsigned index2) |
Pack an uint8_t into the store at a specific spot; only for specialty work! | |
void | placeData (const uint16_t &i, unsigned index2) |
Pack an uint16_t into the store. | |
void | placeData (const uint32_t &i, unsigned index2) |
Pack an uint32_t into the store. | |
void | packData (const uint64_t &i) |
Pack an uint64_t into the store. | |
void | packData (const bool &b) |
Pack a bool into the store, fits in a byte. | |
void | packData (const vstring &t) |
Pack a string of variable length into the store. | |
void | packData (const char *c) |
Pack a 0-terminated c-string into the store. | |
void | packData (const char *c, const unsigned length) |
Pack a string of certain known length into the store. | |
ostream & | print (ostream &o) const |
Print to stream, just for debugging purposed. | |
Amorphous storage object of variable size.
The data from this object can be transported and unpacked again, using an AmorphReStore object. This is commonly used for network communication within DUECA. One application-level use is common, in combination with Snapshot handling.
dueca::AmorphStore::AmorphStore | ( | ) |
Constructor for an un-initialised store, has no memory.
Use acceptBuffer or renewBuffer to supply memory to this store.
Constructor for an initial store, with memory borrowed somewhere else.
This may be used to pack data in a buffer that is already present.
store | Array for the data. |
capacity | Maximum capacity of the storage. |
initialise a store with borrowed memory.
store | Array for the data. |
capacity | Maximum capacity of the storage. |
re-initialise the store's memory.
Note that this operation can be quite wasteful, it frees the memory previously allocated (if any, and if self-allocated), and allocates new memory.
capacity | Maximum capacity of the storage. |
access to the data of the store.
Ask for a mark, a 2-byte (uint16_t) number that contains the size of the data or the number of data items up to the end mark.
AmorphStoreBoundary | when no room. |
Finish the mark, this codes the size of the packed data since the mark.
m | StoreMark, created with createMark |
MarkRange | when mark too big for coded size |
Finish the mark, this codes the number supplied to the call.
m | StoreMark, created with createMark |
n | Value to be stored |
void dueca::AmorphStore::endMark | ( | ) |
Call this after packing all data after the startMark() call.
It writes the size of the data packed after the startMark call into the mark location.
void dueca::AmorphStore::startBigMark | ( | ) |
Ask for a big mark, a 4-byte (uint32_t) number that contains the size of the data up to the end mark.
AmorphStoreBoundary | when no room. |
void dueca::AmorphStore::endBigMark | ( | ) |
Call this after packing all data after the startBigMark() call.
It writes the size of the data packed after the startBigMark call into the mark location.
query the current size of the stored data.
|
inline |
round off the size of the store to a multiple of four, necessary for word-wide communications hardware.
Modify the current size of the stored data.
Use this with extreme care, if you must.
p_index | New size of the packed data. |
Reuse the store, meaning to flush it completely and start packing new data.
capacity | If non-zero, indicates the new capacity of the buffer. Use with care, you are responsible for ensuring enough buffer size. |
|
inline |
If this returns true, there is no more room in the store.
|
inline |
Flag the store as choked, i.e.
don't pack anything in it anymore.
Check for room in the store.
Pack a string of certain known length into the store.
It is your own responsibility to know the length when unpacking it again.