IBAMR  IBAMR version 0.19.
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SAMRAI::tbox::MessageStream Class Reference

#include <tbox/MessageStream.h>

Inheritance diagram for SAMRAI::tbox::MessageStream:
Inheritance graph
[legend]

Public Types

enum  StreamMode { Read, Write }
 

Public Member Functions

 MessageStream ()
 
 MessageStream (const int bytes, const StreamMode mode)
 
 MessageStream (const int bytes, const StreamMode mode, const bool use_xdr)
 
 MessageStream (const MessageStream &)=default
 
MessageStreamoperator= (const MessageStream &)=default
 
 MessageStream (MessageStream &&)=default
 
MessageStreamoperator= (MessageStream &&)=default
 
virtual ~MessageStream ()
 
void * getBufferStart ()
 
int getCurrentSize () const
 
int getCurrentIndex () const
 
void setCurrentIndex (const int index)
 
void resetIndex ()
 
Boolean Stream Primitives

Pack and unpack booleans into and out of the message stream.

virtual AbstractStreamoperator<< (const bool &data)
 Pack a single bool into the message stream. More...
 
virtual AbstractStreamoperator>> (bool &data)
 Remove a single bool from the message stream. More...
 
virtual void pack (const bool *data, const int n=1)
 Pack an array of bools into the message stream. More...
 
virtual void unpack (bool *data, const int n=1)
 Remove an array of bools from the message stream. More...
 
Character Stream Primitives

Pack and unpack chars into and out of the message stream.

virtual AbstractStreamoperator<< (const char &data)
 Pack a single char into the message stream. More...
 
virtual AbstractStreamoperator>> (char &data)
 Remove a single char from the message stream. More...
 
virtual void pack (const char *data, const int n=1)
 Pack an array of chars into the message stream. More...
 
virtual void unpack (char *data, const int n=1)
 Remove an array of chars from the message stream. More...
 
Double Complex Stream Primitives

Pack and unpack double complex into and out of the message stream.

virtual AbstractStreamoperator<< (const dcomplex &data)
 Pack a single double complex into the message stream. More...
 
virtual AbstractStreamoperator>> (dcomplex &data)
 Remove a single double complex from the message stream. More...
 
virtual void pack (const dcomplex *data, const int n=1)
 Pack an array of double complex into the message stream. More...
 
virtual void unpack (dcomplex *data, const int n=1)
 Remove an array of double complex from the message stream. More...
 
Double Stream Primitives

Pack and unpack doubles into and out of the message stream.

virtual AbstractStreamoperator<< (const double &data)
 Pack a single double into the message stream. More...
 
virtual AbstractStreamoperator>> (double &data)
 Remove a single double from the message stream. More...
 
virtual void pack (const double *data, const int n=1)
 Pack an array of doubles into the message stream. More...
 
virtual void unpack (double *data, const int n=1)
 Remove an array of doubles from the message stream. More...
 
Float Stream Primitives

Pack and unpack floats into and out of the message stream.

virtual AbstractStreamoperator<< (const float &data)
 Pack a single float into the message stream. More...
 
virtual AbstractStreamoperator>> (float &data)
 Remove a single float from the message stream. More...
 
virtual void pack (const float *data, const int n=1)
 Pack an array of floats into the message stream. More...
 
virtual void unpack (float *data, const int n=1)
 Remove an array of floats from the message stream. More...
 
Integer Stream Primitives

Pack and unpack integers into and out of the message stream.

virtual AbstractStreamoperator<< (const int &data)
 Pack a single integer into the message stream. More...
 
virtual AbstractStreamoperator>> (int &data)
 Remove a single integer from the message stream. More...
 
virtual void pack (const int *data, const int n=1)
 Pack an array of integers into the message stream. More...
 
virtual void unpack (int *data, const int n=1)
 Remove an array of integers from the message stream. More...
 

Static Public Member Functions

static void useXDR (const bool flag)
 
Stream Space Calculation Primitives

Calculate the stream space needed for various data types.

static int sizeofBool (const int n=1)
 Calculate the stream space needed for n bools. More...
 
static int sizeofChar (const int n=1)
 Calculate the stream space needed for n chars. More...
 
static int sizeofDoubleComplex (const int n=1)
 Calculate the stream space needed for n double complex. More...
 
static int sizeofDouble (const int n=1)
 Calculate the stream space needed for n doubles. More...
 
static int sizeofFloat (const int n=1)
 Calculate the stream space needed for n floats. More...
 
static int sizeofInt (const int n=1)
 Calculate the stream space needed for n ints. More...
 
Stream Space Calculation Primitives

Calculate the stream space needed for various data types.

static int sizeofBool (const int n=1)
 Calculate the stream space needed for n bools. More...
 
static int sizeofChar (const int n=1)
 Calculate the stream space needed for n chars. More...
 
static int sizeofDoubleComplex (const int n=1)
 Calculate the stream space needed for n double complex. More...
 
static int sizeofDouble (const int n=1)
 Calculate the stream space needed for n doubles. More...
 
static int sizeofFloat (const int n=1)
 Calculate the stream space needed for n floats. More...
 
static int sizeofInt (const int n=1)
 Calculate the stream space needed for n ints. More...
 
Stream Space Calculation Primitives

Calculate the stream space needed for various data types.

static int sizeofBool (const int n=1)
 Calculate the stream space needed for n bools. More...
 
static int sizeofChar (const int n=1)
 Calculate the stream space needed for n chars. More...
 
static int sizeofDoubleComplex (const int n=1)
 Calculate the stream space needed for n double complex. More...
 
static int sizeofDouble (const int n=1)
 Calculate the stream space needed for n doubles. More...
 
static int sizeofFloat (const int n=1)
 Calculate the stream space needed for n floats. More...
 
static int sizeofInt (const int n=1)
 Calculate the stream space needed for n ints. More...
 
Stream Space Calculation Primitives

Calculate the stream space needed for various data types.

static int sizeofBool (const int n=1)
 Calculate the stream space needed for n bools. More...
 
static int sizeofChar (const int n=1)
 Calculate the stream space needed for n chars. More...
 
static int sizeofDoubleComplex (const int n=1)
 Calculate the stream space needed for n double complex. More...
 
static int sizeofDouble (const int n=1)
 Calculate the stream space needed for n doubles. More...
 
static int sizeofFloat (const int n=1)
 Calculate the stream space needed for n floats. More...
 
static int sizeofInt (const int n=1)
 Calculate the stream space needed for n ints. More...
 
Stream Space Calculation Primitives

Calculate the stream space needed for various data types.

static int sizeofBool (const int n=1)
 Calculate the stream space needed for n bools. More...
 
static int sizeofChar (const int n=1)
 Calculate the stream space needed for n chars. More...
 
static int sizeofDoubleComplex (const int n=1)
 Calculate the stream space needed for n double complex. More...
 
static int sizeofDouble (const int n=1)
 Calculate the stream space needed for n doubles. More...
 
static int sizeofFloat (const int n=1)
 Calculate the stream space needed for n floats. More...
 
static int sizeofInt (const int n=1)
 Calculate the stream space needed for n ints. More...
 

Static Private Member Functions

Integer Stream Primitives

Pack and unpack integers into and out of the abstract stream.

static int roundXDR (const int n)
 
Integer Stream Primitives

Pack and unpack integers into and out of the abstract stream.

static int roundXDR (const int n)
 
Integer Stream Primitives

Pack and unpack integers into and out of the abstract stream.

static int roundXDR (const int n)
 
Integer Stream Primitives

Pack and unpack integers into and out of the abstract stream.

static int roundXDR (const int n)
 

ArrayData Primitives

Pack and unpack ArrayData into and out of the message stream.

int d_current_size
 
int d_buffer_index
 
int d_use_xdr
 
tbox::Array< char > d_buffer
 
static bool s_use_xdr_translation
 
template<int DIM, class TYPE >
void packArrayData (const pdat::ArrayData< DIM, TYPE > &arraydata, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_shift)
 
template<int DIM, class TYPE >
void unpackArrayData (pdat::ArrayData< DIM, TYPE > &arraydata, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_shift)
 
template<int DIM, class TYPE >
void unpackAndSumArrayData (pdat::ArrayData< DIM, TYPE > &arraydata, const hier::Box< DIM > &dest_box, const hier::IntVector< DIM > &src_shift)
 
virtual void printClassData (std::ostream &os) const
 
void * getPointerAndAdvanceCursor (const int bytes)
 

Detailed Description

Class MessageStream implements a message buffer of fixed size used by the communication routines. It is a subclass of AbstractStream. Class MessageStream defines two mechanisms can be used to pack or unpack a message stream: (1) XDR and (2) a straight-forward byte copy. XDR has the advantage of machine independence for heterogenous networks but is much slower than a simple copy.

See also
tbox::AbstractStream
tbox::XDRStream

Member Enumeration Documentation

◆ StreamMode

Enumerator
Read 
Write 

Constructor & Destructor Documentation

◆ MessageStream() [1/5]

SAMRAI::tbox::MessageStream::MessageStream ( )

Default constructor. Sets up an empty message.

◆ MessageStream() [2/5]

SAMRAI::tbox::MessageStream::MessageStream ( const int  bytes,
const StreamMode  mode 
)

Create a message stream of the specified size in bytes and the stream mode (one of MessageStream::Read or MessageStream::Write). The choice of XDR translation is based on the current value of the class-wide useXDR() flag.

◆ MessageStream() [3/5]

SAMRAI::tbox::MessageStream::MessageStream ( const int  bytes,
const StreamMode  mode,
const bool  use_xdr 
)

Create a message stream of the specified size in bytes and the stream mode (either MessageStream::Read or MessageStream::Write). The choice of XDR translation is based on the argument to the constructor, which is independent of the class-wide XDR flag.

◆ MessageStream() [4/5]

SAMRAI::tbox::MessageStream::MessageStream ( const MessageStream )
default

Copy constructor.

◆ MessageStream() [5/5]

SAMRAI::tbox::MessageStream::MessageStream ( MessageStream &&  )
default

Move constructor.

◆ ~MessageStream()

virtual SAMRAI::tbox::MessageStream::~MessageStream ( )
virtual

Virtual destructor for a message stream.

Member Function Documentation

◆ operator=() [1/2]

MessageStream& SAMRAI::tbox::MessageStream::operator= ( const MessageStream )
default

Copy assignment operator.

◆ operator=() [2/2]

MessageStream& SAMRAI::tbox::MessageStream::operator= ( MessageStream &&  )
default

Move assignment operator.

◆ useXDR()

static void SAMRAI::tbox::MessageStream::useXDR ( const bool  flag)
static

Whether to use XDR translation when communicating via message streams. XDR translation is slower but provides portability across heterogenous machine networks. By default, XDR translation is turned on.

◆ getBufferStart()

void* SAMRAI::tbox::MessageStream::getBufferStart ( )

Return a pointer to the start of the message buffer.

◆ getCurrentSize()

int SAMRAI::tbox::MessageStream::getCurrentSize ( ) const

Return the current size of the buffer in bytes.

◆ getCurrentIndex()

int SAMRAI::tbox::MessageStream::getCurrentIndex ( ) const

Return the current index into the buffer.

◆ setCurrentIndex()

void SAMRAI::tbox::MessageStream::setCurrentIndex ( const int  index)

Set the current index into the buffer. Further packing/unpacking will begin at this new location.

◆ resetIndex()

void SAMRAI::tbox::MessageStream::resetIndex ( )

Reset the index to the beginning of the buffer. This is the same as setting the buffer index to zero via setCurrentIndex().

◆ operator<<() [1/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const bool data)
virtual

◆ operator>>() [1/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( bool data)
virtual

◆ pack() [1/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const bool data,
const int  n = 1 
)
virtual

◆ unpack() [1/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( bool data,
const int  n = 1 
)
virtual

◆ operator<<() [2/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const char &  data)
virtual

◆ operator>>() [2/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( char &  data)
virtual

◆ pack() [2/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const char *  data,
const int  n = 1 
)
virtual

◆ unpack() [2/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( char *  data,
const int  n = 1 
)
virtual

◆ operator<<() [3/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const dcomplex data)
virtual

◆ operator>>() [3/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( dcomplex data)
virtual

◆ pack() [3/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const dcomplex data,
const int  n = 1 
)
virtual

◆ unpack() [3/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( dcomplex data,
const int  n = 1 
)
virtual

◆ operator<<() [4/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const double data)
virtual

◆ operator>>() [4/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( double data)
virtual

◆ pack() [4/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const double data,
const int  n = 1 
)
virtual

◆ unpack() [4/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( double data,
const int  n = 1 
)
virtual

◆ operator<<() [5/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const float &  data)
virtual

◆ operator>>() [5/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( float &  data)
virtual

◆ pack() [5/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const float *  data,
const int  n = 1 
)
virtual

◆ unpack() [5/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( float *  data,
const int  n = 1 
)
virtual

◆ operator<<() [6/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator<< ( const int data)
virtual

◆ operator>>() [6/6]

virtual AbstractStream& SAMRAI::tbox::MessageStream::operator>> ( int data)
virtual

◆ pack() [6/6]

virtual void SAMRAI::tbox::MessageStream::pack ( const int data,
const int  n = 1 
)
virtual

◆ unpack() [6/6]

virtual void SAMRAI::tbox::MessageStream::unpack ( int data,
const int  n = 1 
)
virtual

◆ packArrayData()

template<int DIM, class TYPE >
void SAMRAI::tbox::MessageStream::packArrayData ( const pdat::ArrayData< DIM, TYPE > &  arraydata,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_shift 
)

◆ unpackArrayData()

template<int DIM, class TYPE >
void SAMRAI::tbox::MessageStream::unpackArrayData ( pdat::ArrayData< DIM, TYPE > &  arraydata,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_shift 
)

◆ unpackAndSumArrayData()

template<int DIM, class TYPE >
void SAMRAI::tbox::MessageStream::unpackAndSumArrayData ( pdat::ArrayData< DIM, TYPE > &  arraydata,
const hier::Box< DIM > &  dest_box,
const hier::IntVector< DIM > &  src_shift 
)

◆ printClassData()

virtual void SAMRAI::tbox::MessageStream::printClassData ( std::ostream &  os) const
virtual

Print out internal class data for debugging.

◆ getPointerAndAdvanceCursor()

void* SAMRAI::tbox::MessageStream::getPointerAndAdvanceCursor ( const int  bytes)
private

◆ sizeofBool()

static int SAMRAI::tbox::AbstractStream::sizeofBool ( const int  n = 1)
staticinherited

◆ sizeofChar()

static int SAMRAI::tbox::AbstractStream::sizeofChar ( const int  n = 1)
staticinherited

◆ sizeofDoubleComplex()

static int SAMRAI::tbox::AbstractStream::sizeofDoubleComplex ( const int  n = 1)
staticinherited

◆ sizeofDouble()

static int SAMRAI::tbox::AbstractStream::sizeofDouble ( const int  n = 1)
staticinherited

◆ sizeofFloat()

static int SAMRAI::tbox::AbstractStream::sizeofFloat ( const int  n = 1)
staticinherited

◆ sizeofInt()

static int SAMRAI::tbox::AbstractStream::sizeofInt ( const int  n = 1)
staticinherited

◆ roundXDR()

static int SAMRAI::tbox::AbstractStream::roundXDR ( const int  n)
staticprivateinherited

Member Data Documentation

◆ d_current_size

int SAMRAI::tbox::MessageStream::d_current_size
private

◆ d_buffer_index

int SAMRAI::tbox::MessageStream::d_buffer_index
private

◆ d_use_xdr

int SAMRAI::tbox::MessageStream::d_use_xdr
private

◆ d_buffer

tbox::Array<char> SAMRAI::tbox::MessageStream::d_buffer
private

◆ s_use_xdr_translation

bool SAMRAI::tbox::MessageStream::s_use_xdr_translation
staticprivate

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