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

Input archive for packed heterogeneous binary data. More...

#include <MemoryIArchive.h>

Public Member Functions

 MemoryIArchive ()
 Constructor. More...
 
 ~MemoryIArchive ()
 Destructor. More...
 
void allocate (size_t capacity)
 Allocate memory block. More...
 
MemoryIArchiveoperator= (MemoryOArchive &other)
 Assignment from MemoryOArchive. More...
 
void reset ()
 Reset the cursor to the beginning (for rereading). More...
 
void clear ()
 Reset to empty state. More...
 
void release ()
 Release memory obtained by assignment. More...
 
template<typename T >
MemoryIArchiveoperator& (T &data)
 Load one object. More...
 
template<typename T >
MemoryIArchiveoperator>> (T &data)
 Load one object. More...
 
template<typename T >
void unpack (T &data)
 Unpack one object of type T. More...
 
template<typename T >
void unpack (T *array, int n)
 Read a C-array of objects of type T. More...
 
template<typename T >
void unpack (T *array, int m, int n, int np)
 Unpack a 2D C array. More...
 
void recv (MPI::Intracomm &comm, int source)
 Receive packed data via MPI. More...
 
Bytebegin () const
 Return pointer to beginning of block. More...
 
Bytecursor () const
 Return pointer to current position (cursor). More...
 
Byteend () const
 Return pointer to end of packed block (one Byte past the last). More...
 
size_t capacity () const
 Return capacity in Bytes. More...
 
bool isAllocated () const
 Has memory been allocated? More...
 

Static Public Member Functions

static bool is_saving ()
 Returns true;. More...
 
static bool is_loading ()
 Returns false;. More...
 

Detailed Description

Input archive for packed heterogeneous binary data.

Definition at line 31 of file MemoryIArchive.h.

Constructor & Destructor Documentation

◆ MemoryIArchive()

Util::MemoryIArchive::MemoryIArchive ( )

Constructor.

Definition at line 20 of file MemoryIArchive.cpp.

◆ ~MemoryIArchive()

Util::MemoryIArchive::~MemoryIArchive ( )

Destructor.

Definition at line 35 of file MemoryIArchive.cpp.

Member Function Documentation

◆ is_saving()

bool Util::MemoryIArchive::is_saving ( )
inlinestatic

Returns true;.

Definition at line 196 of file MemoryIArchive.h.

◆ is_loading()

bool Util::MemoryIArchive::is_loading ( )
inlinestatic

Returns false;.

Definition at line 199 of file MemoryIArchive.h.

◆ allocate()

void Util::MemoryIArchive::allocate ( size_t  capacity)

Allocate memory block.

Parameters
capacitysizeof of block, in Bytes.

Definition at line 46 of file MemoryIArchive.cpp.

References capacity(), and UTIL_THROW.

◆ operator=()

MemoryIArchive & Util::MemoryIArchive::operator= ( MemoryOArchive other)

Assignment from MemoryOArchive.

Definition at line 64 of file MemoryIArchive.cpp.

References isAllocated(), and UTIL_THROW.

◆ reset()

void Util::MemoryIArchive::reset ( )

Reset the cursor to the beginning (for rereading).

Definition at line 84 of file MemoryIArchive.cpp.

References begin(), isAllocated(), and UTIL_THROW.

◆ clear()

void Util::MemoryIArchive::clear ( )

Reset to empty state.

Resets cursor and end pointers to beginning of memory block.

Definition at line 95 of file MemoryIArchive.cpp.

References begin(), isAllocated(), and UTIL_THROW.

◆ release()

void Util::MemoryIArchive::release ( )

Release memory obtained by assignment.

Definition at line 110 of file MemoryIArchive.cpp.

References UTIL_THROW.

◆ operator&()

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

Load one object.

Parameters
dataobject to be loaded from this archive.

Definition at line 240 of file MemoryIArchive.h.

◆ operator>>()

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

Load one object.

Parameters
dataobject to be loaded from this archive.

Definition at line 250 of file MemoryIArchive.h.

◆ unpack() [1/3]

template<typename T >
void Util::MemoryIArchive::unpack ( T &  data)

Unpack one object of type T.

Parameters
dataobject to be loaded from this archive.

Definition at line 260 of file MemoryIArchive.h.

References UTIL_THROW.

◆ unpack() [2/3]

template<typename T >
void Util::MemoryIArchive::unpack ( T *  array,
int  n 
)

Read a C-array of objects of type T.

Parameters
arrayarray into which data should be loaded.
nexpected number of elements in the array.

Definition at line 275 of file MemoryIArchive.h.

References UTIL_THROW.

◆ unpack() [3/3]

template<typename T >
void Util::MemoryIArchive::unpack ( T *  array,
int  m,
int  n,
int  np 
)

Unpack a 2D C array.

Unpack m rows of n elements into array of type T array[mp][np], with m <= mp and n <= np.

Parameters
arraypointer to [0][0] element of 2D array
mlogical number of rows
nlogical number of columns
npphysical number of columns

Definition at line 292 of file MemoryIArchive.h.

References UTIL_THROW.

◆ recv()

void Util::MemoryIArchive::recv ( MPI::Intracomm &  comm,
int  source 
)

Receive packed data via MPI.

Parameters
commMPI communicator
sourcerank of processor from which data is sent.

Definition at line 133 of file MemoryIArchive.cpp.

References UTIL_THROW.

◆ begin()

Byte * Util::MemoryIArchive::begin ( ) const
inline

Return pointer to beginning of block.

Definition at line 207 of file MemoryIArchive.h.

Referenced by clear(), and reset().

◆ cursor()

Byte * Util::MemoryIArchive::cursor ( ) const
inline

Return pointer to current position (cursor).

Definition at line 213 of file MemoryIArchive.h.

◆ end()

Byte * Util::MemoryIArchive::end ( ) const
inline

Return pointer to end of packed block (one Byte past the last).

Definition at line 219 of file MemoryIArchive.h.

◆ capacity()

size_t Util::MemoryIArchive::capacity ( ) const
inline

Return capacity in Bytes.

Definition at line 225 of file MemoryIArchive.h.

Referenced by allocate().

◆ isAllocated()

bool Util::MemoryIArchive::isAllocated ( ) const
inline

Has memory been allocated?

Definition at line 231 of file MemoryIArchive.h.

Referenced by clear(), operator=(), and reset().


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