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"
27 template<typename T, typename Mem, int pack_type=Pack_selector<T>::value >
35 static void unpack(ExtPreAlloc<Mem> , T & obj)
37 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" packing for the type " << demangle(
typeid(T).name()) <<
" is not implemented\n";
47 template<
typename T,
typename Mem>
61 T * ptr =
static_cast<T *
>(ext.getPointerOffset(ps.
getOffset()));
68 template<
typename T,
typename Mem>
90 memcpy(obj.getPointer(),ext.getPointerOffset(ps.
getOffset()),
sizeof(
typename T::value_type)*obj.size());
92 ps.
addOffset(
sizeof(
typename T::value_type)*obj.size());
103 template<
typename T,
typename Mem>
104 class Unpacker<T,Mem,PACKER_OBJECTS_WITH_WARNING_POINTERS>
117 std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" impossible to check the type " << demangle(
typeid(T).name()) <<
" please consider to add a static method \"void noPointers()\" \n" ;
119 memcpy(&obj,(T *)ext.getPointerOffset(ps.
getOffset()),
sizeof(T));
131 template<
typename T,
typename Mem>
132 class Unpacker<T,Mem,PACKER_OBJECTS_WITH_POINTER_CHECK>
145 if (obj.noPointers() ==
false)
146 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" the type " << demangle(
typeid(T).name()) <<
" has pointers inside, sending pointers values has no sense\n";
148 memcpy(&obj,(T *)ext.getPointerOffset(ps.
getOffset()),
sizeof(T));
160 template<
typename T,
typename Mem>
165 template<
unsigned int ... prp>
void static unpack(ExtPreAlloc<Mem> & mem, T & obj,
Unpack_stat & ps)
167 obj.template
unpack<prp...>(mem, ps);
177 template<
typename T,
typename Mem>
182 template<
unsigned int ... prp>
static void unpack(ExtPreAlloc<Mem> & mem, T & obj,
Unpack_stat & ps)
184 obj.template
unpack<prp...>(mem, ps);
189 obj.template
unpack<prp...>(mem, sub_it, ps);
199 template<
typename T,
typename Mem>
size_t getOffset()
Return the actual counter.
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.
void addOffset(size_t off)
Increment the request pointer.
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.
static void unpack(ExtPreAlloc< Mem > &ext, T &obj, Unpack_stat &ps)
It unpack any object checking that the object does not have pointers inside.