8#ifndef SRC_UNPACKER_HPP_
9#define SRC_UNPACKER_HPP_
11#include "util/object_util.hpp"
14#include "memory/ExtPreAlloc.hpp"
15#include "util/util_debug.hpp"
16#include "Pack_selector.hpp"
17#include "util/Pack_stat.hpp"
18#include "memory/PtrMemory.hpp"
19#include "Packer_util.hpp"
20#include "util/multi_array_openfpm/multi_array_ref_openfpm.hpp"
21#include "has_pack_encap.hpp"
22#include "util/object_creator.hpp"
23#include "Grid/grid_common.hpp"
32template<
typename T,
typename Mem,
int pack_type >
42#ifndef DISABLE_ALL_RTTI
43 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" packing for the type " << demangle(
typeid(T).name()) <<
" is not implemented\n";
54template<
typename T,
typename Mem>
75template<
typename T,
typename Mem>
101 ps.
addOffset(
sizeof(
typename T::value_type)*obj.size());
105template <
typename T,
bool is_array>
108 static void * getpointer(T & obj)
117 static void * getpointer(T & obj)
123template<
typename T,
typename Mem>
127 typedef typename std::remove_all_extents<T>::type
base_type;
130 typedef typename boost::mpl::int_<std::rank<T>::value>
n_ext;
145 typedef typename std::remove_extent<T>::type prim_type;
159 typename openfpm::multi_array_ref_openfpm<base_type,n_ext::value+1,vmpl>::reference obj,
175template<
typename T,
typename Mem>
176class Unpacker<T,Mem,PACKER_OBJECTS_WITH_WARNING_POINTERS>
203template<
typename T,
typename Mem>
204class Unpacker<T,Mem,PACKER_OBJECTS_WITH_POINTER_CHECK>
228template<
typename T,
typename Mem>
235 obj.template
unpack<prp...>(mem, ps);
243 obj.template
unpack<prp...>(mem, ps);
253template<
typename T,
typename Mem>
260 obj.template
unpack<prp...>(mem, ps);
263 template<
typename grid_sub_it_type,
264 typename context_type,
267 obj.template
unpack<prp...>(mem, sub_it, ps, context, opt);
270 template<
typename grid_sub_it_type,
271 typename header_type,
272 typename context_type,
273 unsigned int ... prp>
static void unpack_with_header(
ExtPreAlloc<Mem> & mem,
274 grid_sub_it_type & sub_it,
276 header_type & header,
279 context_type & context,
282 obj.template unpack_with_headers<prp...>(mem, sub_it, header, ih, ps, context, opt);
287template<
unsigned int prop,
typename T>
290 template<
typename Tsrc,
typename Tdst>
291 static void copy(Tsrc & src, Tdst & dst,
size_t pos)
293 typedef typename std::remove_reference<
decltype(dst.template get<prop>()[0])>::type copy_rtype;
298 template<
typename Tsrc,
typename Tdst>
299 static void copy_unpack(Tsrc & src, Tdst & dst,
size_t pos)
302 typedef typename boost::remove_reference<
decltype(src.template get< prop >())>::type copy_rtype;
308template<
unsigned int prop,
typename T,
unsigned int N1>
311 template<
typename Tsrc,
typename Tdst>
312 static void copy(Tsrc & src, Tdst & dst,
size_t pos)
314 typedef typename std::remove_reference<
decltype(dst.template get<prop>()[0][pos])>::type copy_rtype;
316 for (
int i = 0 ; i < N1 ; i++)
322 template<
typename Tsrc,
typename Tdst>
323 static void copy_unpack(Tsrc & src, Tdst & dst,
size_t pos)
326 typedef typename boost::remove_reference<
decltype(src.template get< prop >()[0])>::type copy_rtype;
328 for (
int i = 0 ; i < N1 ; i++)
336template<
typename e_src,
typename e_dst>
365 typedef typename std::remove_reference<
decltype(
src.template get<T::value>())>::type copy_rtype;
377template<
typename T,
typename Mem>
387 template<
typename T_nc,
unsigned int ... prp>
398 typedef typename boost::mpl::at<typename T::T_type::type,boost::mpl::int_<0>>::type cnk_size;
400 if (
sizeof...(prp) == 0)
404 decltype(obj)> cp(enc,obj,sub_id);
406 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::T_type::max_prop>>(cp);
413 object_s_di<
decltype(enc),T,OBJ_ENCAP_CHUNKING,prp ... >(enc,obj,sub_id);
426 template<
template<
typename,
typename>
class op,
unsigned int ... prp>
436 if (
sizeof...(prp) == 0)
440 decltype(obj)>(enc,obj,sub_id);
441 ps.
addOffset(
sizeof(
typename T::T_type));
447 object_s_di_op<op,
decltype(enc),T,OBJ_ENCAP_CHUNKING,prp ... >(enc,obj,sub_id);
void * getPointerOffset(size_t offset)
Get the base memory pointer increased with an offset.
virtual void * getPointer()
Return the pointer of the last allocation.
void * getPointerBase()
The the base pointer of the preallocate memory.
virtual size_t size() const
Get the size of the LAST allocated memory.
size_t getOffset()
Return the actual counter.
void addOffset(size_t off)
Increment the offset pointer by off.
boost::mpl::int_< std::rank< T >::value > n_ext
numver of extents in the primitive array
std::remove_all_extents< T >::type base_type
base type of the primitive arrat
static void unpack(ExtPreAlloc< Mem > &ext, typename openfpm::multi_array_ref_openfpm< base_type, n_ext::value+1, vmpl >::reference obj, Unpack_stat &ps)
It unpack C++ primitives.
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
It packs arrays of C++ primitives.
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
It unpack C++ primitives.
static void unpack_op(ExtPreAlloc< Mem > &mem, T &obj, size_t sub_id, Unpack_stat &ps)
is this needed
static void unpack(ExtPreAlloc< Mem > &mem, T &obj, size_t sub_id, Unpack_stat &ps)
is this needed
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
It unpack any object checking that the object does not have pointers inside.
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
unpack object
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
It unpack C++ primitives.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
It copy one element of the chunk for each property.
size_t sub_id
element to copy
copy_unpacker_chunk(const e_src &src, e_dst &dst, size_t sub_id)
constructor
e_dst & dst
encapsulated object destination
const e_src & src
encapsulated object source
void operator()(T &t) const
It call the copy function for each property.
It copy the properties from one object to another applying an operation.
It copy the properties from one object to another.
boost::mpl::push_front< typenameboost::mpl::pop_front< prim_vmpl >::type, boost::mpl::int_<-1 > >::type vmpl
Remove the first element (this is the Tv parameter of )