Simpatico
v1.10
|
Archive to computed packed size of a sequence of objects, in bytes.
This class computes the number of bytes required to pack a sequence of objects within a MemoryOArchive. The interface is that of a loading Archive, but the << and & operators are overloaded to compute the size required for an object and to increment a size counter, rather than to actually save data.
The size() method returns the number of bytes required to pack all of the objects serialized thus far. The size counter is set to zero upon construction. The clear() method resets the size counter to zero.
Definition at line 35 of file MemoryCounter.h.
#include <MemoryCounter.h>
Public Member Functions | |
MemoryCounter () | |
Constructor. More... | |
~MemoryCounter () | |
Destructor. More... | |
void | clear () |
Resets the size counter to zero. More... | |
template<typename T > | |
MemoryCounter & | operator& (T &data) |
Add packed size of one object. More... | |
template<typename T > | |
MemoryCounter & | operator<< (T &data) |
Add packed size of one object. More... | |
template<typename T > | |
void | count (const T &data) |
Add size of one object in memory. More... | |
template<typename T > | |
void | count (T *array, int n) |
Compute the size in memory of a C array. More... | |
size_t | size () const |
Return size required for archive, in Bytes. More... | |
Static Public Member Functions | |
static bool | is_saving () |
Returns true. More... | |
static bool | is_loading () |
Returns false. More... | |
Util::MemoryCounter::MemoryCounter | ( | ) |
Constructor.
Definition at line 16 of file MemoryCounter.cpp.
Util::MemoryCounter::~MemoryCounter | ( | ) |
Destructor.
Definition at line 24 of file MemoryCounter.cpp.
|
inlinestatic |
Returns true.
Definition at line 139 of file MemoryCounter.h.
|
inlinestatic |
Returns false.
Definition at line 142 of file MemoryCounter.h.
void Util::MemoryCounter::clear | ( | ) |
Resets the size counter to zero.
Definition at line 30 of file MemoryCounter.cpp.
|
inline |
Add packed size of one object.
Definition at line 155 of file MemoryCounter.h.
|
inline |
Add packed size of one object.
Definition at line 165 of file MemoryCounter.h.
|
inline |
Add size of one object in memory.
This method just increments the size by sizeof(T). It is appropriate only for primitive C++ variables and POD types for which a bitwise copy is appropriate.
Definition at line 177 of file MemoryCounter.h.
Referenced by count().
|
inline |
Compute the size in memory of a C array.
This method increments the size by n*sizeof(T). It is appropriate for C arrays of primitive variables and of POD types for which a bitwise copy is appropriate.
Definition at line 184 of file MemoryCounter.h.
References count().
|
inline |
Return size required for archive, in Bytes.
Definition at line 148 of file MemoryCounter.h.
Referenced by Util::memorySize().