19 #ifndef LIBMESH_PACKING_H 20 #define LIBMESH_PACKING_H 52 template <
typename OutputIter,
typename Context>
53 static void pack(
const T &
object,
55 const Context * context);
59 template <
typename Context>
61 const Context * context);
66 template <
typename BufferIter>
71 template <
typename BufferIter,
typename Context>
72 static T
unpack(BufferIter in, Context * ctx);
80 template <
typename Context,
typename buffertype,
81 typename OutputIter,
typename T>
82 inline void unpack_range (
const typename std::vector<buffertype> & buffer,
85 const T * output_type );
95 template <
typename Context,
typename buffertype,
typename Iter>
96 inline Iter
pack_range (
const Context * context,
99 typename std::vector<buffertype> & buffer,
100 std::size_t approx_buffer_size = 1000000);
106 template <
typename Context,
typename Iter>
109 const Iter range_end);
117 template <
typename Context,
typename Iter>
120 const Iter range_end)
122 typedef typename std::iterator_traits<Iter>::value_type T;
124 std::size_t buffer_size = 0;
125 for (Iter range_count = range_begin;
126 range_count != range_end;
138 template <
typename Context,
typename buffertype,
typename Iter>
141 const Iter range_end,
142 std::vector<buffertype> & buffer,
147 std::size_t approx_buffer_size)
149 typedef typename std::iterator_traits<Iter>::value_type T;
153 std::size_t buffer_size = 0;
154 Iter range_stop = range_begin;
155 for (; range_stop != range_end && buffer_size < approx_buffer_size;
158 std::size_t next_buffer_size =
160 buffer_size += next_buffer_size;
162 buffer.reserve(buffer.size() + buffer_size);
165 for (; range_begin != range_stop; ++range_begin)
168 std::size_t old_size = buffer.size();
172 (*range_begin, back_inserter(buffer), context);
175 unsigned int my_packable_size =
177 unsigned int my_packed_size =
179 libmesh_assert_equal_to (my_packable_size, my_packed_size);
180 libmesh_assert_equal_to (buffer.size(), old_size + my_packable_size);
192 template <
typename Context,
typename buffertype,
193 typename OutputIter,
typename T>
201 typename std::vector<buffertype>::const_iterator
202 next_object_start = buffer.begin();
204 while (next_object_start < buffer.end())
212 libmesh_assert (next_object_start == buffer.end());
220 #endif // LIBMESH_PACKING_H Iter pack_range(const Context *context, Iter range_begin, const Iter range_end, typename std::vector< buffertype > &buffer, std::size_t approx_buffer_size=1000000)
std::size_t packed_range_size(const Context *context, Iter range_begin, const Iter range_end)
static unsigned int packable_size(const T &object, const Context *context)
static unsigned int packed_size(BufferIter iter)
static void pack(const T &object, OutputIter data_out, const Context *context)
OStreamProxy out(std::cout)
void unpack_range(const typename std::vector< buffertype > &buffer, Context *context, OutputIter out, const T *output_type)
static T unpack(BufferIter in, Context *ctx)