dune-pdelab  2.7-git
Public Types | Public Member Functions | List of all members
Dune::PDELab::PolymorphicBufferWrapper< Buffer > Class Template Reference

Wrapper for message buffers of grid DataHandles that allows for sending different types of data. More...

#include <dune/pdelab/common/polymorphicbufferwrapper.hh>

Public Types

enum  Mode { Mode::send, Mode::receive }
 

Public Member Functions

template<typename T >
void write (const T &data)
 
template<typename T >
void read (T &data)
 
 PolymorphicBufferWrapper (Buffer &buffer, Mode mode, int rank=-1, bool transmit_rank=false)
 
Mode mode () const
 
bool transmitRank () const
 
int senderRank () const
 

Detailed Description

template<typename Buffer>
class Dune::PDELab::PolymorphicBufferWrapper< Buffer >

Wrapper for message buffers of grid DataHandles that allows for sending different types of data.

The standard message buffers passed to the callbacks of the grid DataHandles are templated on a specific data type and do not support writing data of other types.

This wrapper takes a MessageBuffer for char and allows you to write any kind of POD data into it. It works by simply interpreting the data as a byte stream and serializing / deserializing it. Be aware that this implementation may create problems on heterogeneous architectures with different byte orderings.

Moreover, the buffer can optionally take care of providing information about the MPI rank of the sender through the method senderRank() if the rank of the current process and transmit_rank = true are passed to the constructor of the buffer.

Warning
The underlying MessageBuffer must use char as its data type, otherwise you will probably get compile or runtime errors!

Member Enumeration Documentation

◆ Mode

template<typename Buffer >
enum Dune::PDELab::PolymorphicBufferWrapper::Mode
strong
Enumerator
send 
receive 

Constructor & Destructor Documentation

◆ PolymorphicBufferWrapper()

template<typename Buffer >
Dune::PDELab::PolymorphicBufferWrapper< Buffer >::PolymorphicBufferWrapper ( Buffer &  buffer,
Mode  mode,
int  rank = -1,
bool  transmit_rank = false 
)
inline

Member Function Documentation

◆ mode()

template<typename Buffer >
Mode Dune::PDELab::PolymorphicBufferWrapper< Buffer >::mode ( ) const
inline

◆ read()

template<typename Buffer >
template<typename T >
void Dune::PDELab::PolymorphicBufferWrapper< Buffer >::read ( T &  data)
inline

◆ senderRank()

template<typename Buffer >
int Dune::PDELab::PolymorphicBufferWrapper< Buffer >::senderRank ( ) const
inline

◆ transmitRank()

template<typename Buffer >
bool Dune::PDELab::PolymorphicBufferWrapper< Buffer >::transmitRank ( ) const
inline

◆ write()

template<typename Buffer >
template<typename T >
void Dune::PDELab::PolymorphicBufferWrapper< Buffer >::write ( const T &  data)
inline

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