1 #ifndef UTIL_MEMORY_COUNTER_H 2 #define UTIL_MEMORY_COUNTER_H 11 #include "serialize.h" 13 #include <util/space/Vector.h> 14 #include <util/space/IntVector.h> 85 void count(
const T& data);
95 void count(T* array,
int n);
122 friend void serialize<>(
MemoryCounter&, std::string&,
const unsigned int);
129 template <
typename T>
134 return counter.
size();
154 template <
typename T>
157 serialize(*
this, data, version_);
164 template <
typename T>
167 serialize(*
this, data, version_);
176 template <
typename T>
178 { size_ +=
sizeof(T); }
183 template <
typename T>
185 { size_ += n*
sizeof(T); }
197 const unsigned int version)
205 const unsigned int version)
213 const unsigned int version)
221 const unsigned int version)
228 inline void serialize(
MemoryCounter& ar,
unsigned long& data,
229 const unsigned int version)
237 const unsigned int version)
245 const unsigned int version)
253 const unsigned int version)
262 inline void serialize(
MemoryCounter& ar, std::complex<float>& data,
263 const unsigned int version)
270 inline void serialize(
MemoryCounter& ar, std::complex<double>& data,
271 const unsigned int version)
279 const unsigned int version)
280 { ar.size_ +=
sizeof(size_t) + (data.size() + 1)*
sizeof(
char); }
289 const unsigned int version)
297 const unsigned int version)
A Vector is a Cartesian vector.
int memorySize(T &data)
Function template to compute memory size of one object.
MemoryCounter()
Constructor.
void count(const T &data)
Add size of one object in memory.
static bool is_saving()
Returns true.
Utility classes for scientific computation.
~MemoryCounter()
Destructor.
size_t size() const
Return size required for archive, in Bytes.
Archive to computed packed size of a sequence of objects, in bytes.
An IntVector is an integer Cartesian vector.
static bool is_loading()
Returns false.
void clear()
Resets the size counter to zero.
MemoryCounter & operator&(T &data)
Add packed size of one object.
MemoryCounter & operator<<(T &data)
Add packed size of one object.