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

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

#include <MemoryOArchive.h>

Public Member Functions

 MemoryOArchive ()
 Constructor. More...
 
virtual ~MemoryOArchive ()
 Destructor. More...
 
virtual void allocate (size_t capacity)
 Allocate memory. More...
 
void clear ()
 Resets the cursor to the beginning. More...
 
template<typename T >
void operator& (T &data)
 Save one object. More...
 
template<typename T >
MemoryOArchiveoperator<< (T &data)
 Save one object. More...
 
template<typename T >
void pack (const T &data)
 Pack a T object. More...
 
template<typename T >
void pack (const T *array, int n)
 Pack a C array. More...
 
template<typename T >
void pack (const T *array, int m, int n, int np)
 Pack a 2D C array. More...
 
void send (MPI::Intracomm &comm, int dest)
 Send packed data via MPI. More...
 
void iSend (MPI::Intracomm &comm, MPI::Request &req, int dest)
 Send packed data via MPI (non-blocking) More...
 
Bytebegin () const
 Return pointer to beginning of block. More...
 
Bytecursor () const
 Return pointer to current position (cursor). 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

Save archive for packed heterogeneous binary data.

Definition at line 31 of file MemoryOArchive.h.

Constructor & Destructor Documentation

◆ MemoryOArchive()

Util::MemoryOArchive::MemoryOArchive ( )

Constructor.

Definition at line 19 of file MemoryOArchive.cpp.

◆ ~MemoryOArchive()

Util::MemoryOArchive::~MemoryOArchive ( )
virtual

Destructor.

Definition at line 33 of file MemoryOArchive.cpp.

Member Function Documentation

◆ is_saving()

bool Util::MemoryOArchive::is_saving ( )
inlinestatic

Returns true;.

Definition at line 188 of file MemoryOArchive.h.

◆ is_loading()

bool Util::MemoryOArchive::is_loading ( )
inlinestatic

Returns false;.

Definition at line 191 of file MemoryOArchive.h.

◆ allocate()

void Util::MemoryOArchive::allocate ( size_t  capacity)
virtual

Allocate memory.

Parameters
capacitysize of memory block in bytes

Definition at line 44 of file MemoryOArchive.cpp.

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

◆ clear()

void Util::MemoryOArchive::clear ( )

Resets the cursor to the beginning.

Definition at line 62 of file MemoryOArchive.cpp.

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

◆ operator&()

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

Save one object.

Definition at line 224 of file MemoryOArchive.h.

◆ operator<<()

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

Save one object.

Definition at line 231 of file MemoryOArchive.h.

◆ pack() [1/3]

template<typename T >
void Util::MemoryOArchive::pack ( const T &  data)
inline

Pack a T object.

Definition at line 243 of file MemoryOArchive.h.

References UTIL_THROW.

◆ pack() [2/3]

template<typename T >
void Util::MemoryOArchive::pack ( const T *  array,
int  n 
)
inline

Pack a C array.

Parameters
arrayC array
nnumber of elements

Definition at line 261 of file MemoryOArchive.h.

References UTIL_THROW.

◆ pack() [3/3]

template<typename T >
void Util::MemoryOArchive::pack ( const T *  array,
int  m,
int  n,
int  np 
)
inline

Pack a 2D C array.

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

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

Definition at line 281 of file MemoryOArchive.h.

References UTIL_THROW.

◆ send()

void Util::MemoryOArchive::send ( MPI::Intracomm &  comm,
int  dest 
)

Send packed data via MPI.

Parameters
commMPI communicator
destrank of processor to which data is sent

Definition at line 74 of file MemoryOArchive.cpp.

References UTIL_THROW.

◆ iSend()

void Util::MemoryOArchive::iSend ( MPI::Intracomm &  comm,
MPI::Request &  req,
int  dest 
)

Send packed data via MPI (non-blocking)

Parameters
commMPI communicator
reqMPI request
destrank of processor to which data is sent

Definition at line 97 of file MemoryOArchive.cpp.

References UTIL_THROW.

◆ begin()

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

Return pointer to beginning of block.

Definition at line 211 of file MemoryOArchive.h.

Referenced by allocate(), and clear().

◆ cursor()

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

Return pointer to current position (cursor).

Definition at line 217 of file MemoryOArchive.h.

◆ capacity()

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

Return capacity in Bytes.

Definition at line 205 of file MemoryOArchive.h.

Referenced by allocate().

◆ isAllocated()

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

Has memory been allocated?

Definition at line 199 of file MemoryOArchive.h.

Referenced by clear().


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