1 #ifndef MUSTER_PACKABLE_VECTOR_H
2 #define MUSTER_PACKABLE_VECTOR_H
6 #include <boost/shared_ptr.hpp>
28 _packables = boost::shared_ptr< std::vector<T> >(packables);
44 if (
this == &other)
return *
this;
56 for (
size_t i=0; i <
_packables->size(); i++) {
57 size += (*_packables)[i].packed_size(comm);
65 void pack(
void *buf,
int bufsize,
int *pos, MPI_Comm comm)
const {
69 for (
size_t i=0; i < num_packables; i++) {
70 (*_packables)[i].pack(buf, bufsize, pos, comm);
83 for (
size_t i=0; i < vec.
_packables->size(); i++) {
84 (*vec.
_packables)[i] = T::unpack(buf, bufsize, pos, comm);
101 #endif // MUSTER_PACKABLE_VECTOR_H
This class allows a vector of packable objects to be packed as though it were a packable object itsel...
Pass this to a shared pointer if you do NOT want it to own its object.
packable_vector(const packable_vector &other)
void operator()(void const *) const
Overloaded utility functions to convert between arbitrary C/C++ types and MPI types, custom typedefs for cstdlib types like size_t, and a wrapper for MPI_Pack_Size.
void pack(void *buf, int bufsize, int *pos, MPI_Comm comm) const
Pack onto an MPI buffer.
packable_vector & operator=(const packable_vector &other)
Assignment.
int packed_size(MPI_Comm comm) const
get the number of bytes required to pack this buffer.
packable_vector< T > make_packable_vector(std::vector< T > *vec, bool owned=true)
Tempate function adaptor so we can have type inference when making packable vectors.
static packable_vector unpack(void *buf, int bufsize, int *pos, MPI_Comm comm)
Unpack from an input buffer.
#defines for switching between MPI and PMPI bindings.
packable_vector(std::vector< T > *packables, bool owned=true)
boost::shared_ptr< std::vector< T > > _packables