8 #ifndef SRC_PACKER_HPP_
9 #define SRC_PACKER_HPP_
11 #include "util/object_util.hpp"
13 #include "Vector/util.hpp"
14 #include "memory/ExtPreAlloc.hpp"
15 #include "util/util_debug.hpp"
18 #include "Grid/grid_sm.hpp"
19 #include "util/Pack_stat.hpp"
20 #include "Pack_selector.hpp"
21 #include "has_pack_encap.hpp"
22 #include "Packer_util.hpp"
43 template<
typename T,
typename Mem,
int pack_type >
53 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" packing for the type " << demangle(
typeid(T).name()) <<
" is not implemented\n";
61 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" packing for the type " << demangle(
typeid(T).name()) <<
" is not implemented\n";
72 template<
typename T,
typename Mem>
122 template<
typename T,
typename Mem>
123 class Packer<T,Mem,PACKER_ARRAY_PRIMITIVE>
140 ext.
allocate(
sizeof(
typename T::value_type)*n);
141 memcpy(ext.
getPointer(),obj.getPointer(),
sizeof(
typename T::value_type)*n);
154 req +=
sizeof(
typename T::value_type)*obj.size();
165 template<
typename T,
typename Mem>
166 class Packer<T,Mem,PACKER_OBJECTS_WITH_WARNING_POINTERS>
181 std::cerr <<
"Error : " << __FILE__ <<
":" << __LINE__ <<
" the reference counter of mem should never be zero when packing \n";
183 if (!(std::is_array<T>::value ==
true && std::is_fundamental<
typename std::remove_all_extents<T>::type>::value ==
true))
184 std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" impossible to check the type " << demangle(
typeid(T).name()) <<
" please consider to add a static method like \"static bool noPointers() {return true;}\" \n" ;
220 template<
typename T,
typename Mem>
221 class Packer<T,Mem,PACKER_OBJECTS_WITH_POINTER_CHECK>
236 std::cerr <<
"Error : " << __FILE__ <<
":" << __LINE__ <<
" the reference counter of mem should never be zero when packing \n";
238 if (obj.noPointers() ==
false)
239 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" the type " << demangle(
typeid(T).name()) <<
" has pointers inside, sending pointers values has no sense\n";
275 template<
typename T,
typename Mem>
280 template<
int ... prp>
static void packRequest(
const T & obj,
size_t & req)
287 obj.template
pack<prp...>(mem, sts);
297 template<
typename T,
typename Mem>
302 template<
int ... prp>
static void packRequest(
const T & obj,
size_t & req)
314 obj.template
pack<prp...>(mem, sts);
319 obj.template
pack<prp...>(mem, sub_it, sts);
323 template<
typename T,
typename Mem>
336 std::cerr <<
"Error : " << __FILE__ <<
":" << __LINE__ <<
" the reference counter of mem should never be zero when packing \n";
343 if (
sizeof...(prp) == 0)
345 mem.
allocate(
sizeof(
typename T::T_type));
351 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
354 object_si_d<T,decltype(enc),OBJ_ENCAP,prp ... >(eobj,enc);
366 template<
int ... prp>
void packRequest(T & eobj,
size_t & req)
372 if (
sizeof...(prp) == 0)
375 typedef object<
typename object_creator<
typename T::type,prp...>::type> prp_object;
377 req +=
sizeof(prp_object);
static void packRequest(const T &obj, size_t &req)
it add a request to pack an object
static void packRequest(size_t &req)
It add a request to pack a C++ primitive.
static void pack(ExtPreAlloc< Mem > &ext, const T &obj, Pack_stat &sts)
It pack any C++ primitives.
static void packRequest(const T &obj, size_t &req)
It add a request to pack a C++ primitive.
virtual void * getPointer()
Return the pointer of the last allocation.
static void packRequest(T &obj, size_t &req)
It add a request to pack a C++ primitive.
static void packRequest(size_t &req)
it add a request to pack an object
virtual bool allocate(size_t sz)
Allocate a chunk of memory.
virtual long int ref()
Return the reference counter.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
void incReq()
Increment the request pointer.
static void packRequest(const T &obj, size_t &req)
it add a request to pack an object
static void pack(ExtPreAlloc< Mem > &ext, const T &obj, Pack_stat &sts)
It pack any object checking that the object does not have pointers inside.
Declaration grid_key_dx_iterator_sub.
It create a boost::fusion vector with the selected properties.
static void pack(ExtPreAlloc< Mem > &ext, const T &obj, Pack_stat &sts, size_t n)
It packs arrays of C++ primitives.
static void packRequest(size_t &req)
it add a request to pack an object
virtual size_t size() const
Get the size of the LAST allocated memory.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
static void pack(ExtPreAlloc< Mem > &ext, const T &obj, Pack_stat &sts)
It pack an object.
It copy the properties from one object to another.
static void call_packRequest(encap &obj, size_t &req)
pack/serialize