PSCF v1.1
Public Member Functions | Static Public Member Functions | List of all members
Util::MemoryCounter Class Reference

Archive to computed packed size of a sequence of objects, in bytes. More...

#include <MemoryCounter.h>

Public Member Functions

 MemoryCounter ()
 Constructor. More...
 
 ~MemoryCounter ()
 Destructor. More...
 
void clear ()
 Resets the size counter to zero. More...
 
template<typename T >
MemoryCounteroperator& (T &data)
 Add packed size of one object. More...
 
template<typename T >
MemoryCounteroperator<< (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MemoryCounter()

Util::MemoryCounter::MemoryCounter ( )

Constructor.

Definition at line 16 of file MemoryCounter.cpp.

◆ ~MemoryCounter()

Util::MemoryCounter::~MemoryCounter ( )

Destructor.

Definition at line 24 of file MemoryCounter.cpp.

Member Function Documentation

◆ is_saving()

bool Util::MemoryCounter::is_saving ( )
inlinestatic

Returns true.

Definition at line 139 of file MemoryCounter.h.

◆ is_loading()

bool Util::MemoryCounter::is_loading ( )
inlinestatic

Returns false.

Definition at line 142 of file MemoryCounter.h.

◆ clear()

void Util::MemoryCounter::clear ( )

Resets the size counter to zero.

Definition at line 30 of file MemoryCounter.cpp.

◆ operator&()

template<typename T >
MemoryCounter & Util::MemoryCounter::operator& ( T &  data)
inline

Add packed size of one object.

Definition at line 155 of file MemoryCounter.h.

◆ operator<<()

template<typename T >
MemoryCounter & Util::MemoryCounter::operator<< ( T &  data)
inline

Add packed size of one object.

Definition at line 165 of file MemoryCounter.h.

◆ count() [1/2]

template<typename T >
void Util::MemoryCounter::count ( const T &  data)
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.

◆ count() [2/2]

template<typename T >
void Util::MemoryCounter::count ( T *  array,
int  n 
)
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.

◆ size()

size_t Util::MemoryCounter::size ( ) const
inline

The documentation for this class was generated from the following files: