OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Support.hpp
1//
2// Created by tommaso on 29/03/19.
3// Modified by Abhinav and Pietro
4
5#ifndef OPENFPM_PDATA_SUPPORT_HPP
6#define OPENFPM_PDATA_SUPPORT_HPP
7
8#include <Space/Shape/Point.hpp>
9#include <Vector/vector_dist.hpp>
10
12{
13 // This class is basically a wrapper around a point and a set of offsets.
14 // Offsets are stored as they are the data that is mostly required in DCPSE, so we
15 // pre-compute and store them, while the positions can be re-computed everytime is
16 // necessary (it should almost never be the case) (todo: check if this is required)
17
18private:
19
20 size_t referencePointKey;
22
23public:
24
25 Support() {};
26
27 Support(const size_t &referencePoint, const openfpm::vector_std<size_t> &keys)
28 :referencePointKey(referencePoint),
29 keys(keys)
30 {}
31
32 Support(const size_t &referencePoint, const std::vector<size_t> &keys)
33 :referencePointKey(referencePoint),
34 keys(keys.begin(), keys.end())
35 {}
36
37 Support(const Support &other)
38 : referencePointKey(other.referencePointKey),
39 keys(other.keys)
40 {}
41
42 size_t size()
43 {
44 return keys.size();
45 }
46
47 const size_t getReferencePointKey() const
48 {
49 return referencePointKey;
50 }
51
52 const openfpm::vector_std<size_t> &getKeys() const
53 {
54 return keys;
55 }
56
58 {
59 return keys;
60 }
61
62 static bool pack()
63 {
64 return true;
65 }
66
67 static bool packRequest()
68 {
69 return true;
70 }
71
72 template<int ... prp> inline void packRequest(size_t & req) const
73 {
74 req += sizeof(size_t);
75 keys.packRequest(req);
76 }
77
78 template<int ... prp> inline void pack(ExtPreAlloc<HeapMemory> & mem, Pack_stat & sts) const
79 {
80 Packer<size_t,HeapMemory>::pack(mem,referencePointKey,sts);
81 keys.template pack<prp ...>(mem,sts);
82 }
83
84 template<unsigned int ... prp, typename MemType> inline void unpack(ExtPreAlloc<MemType> & mem, Unpack_stat & ps)
85 {
86 Unpacker<size_t,MemType>::unpack(mem,referencePointKey,ps);
87 keys.template unpack<prp ...>(mem,ps);
88 }
89
90};
91
92
93#endif //OPENFPM_PDATA_SUPPORT_HPP
Packing status object.
Definition Pack_stat.hpp:61
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
Definition Packer.hpp:56
Unpacking status object.
Definition Pack_stat.hpp:16
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
Definition Unpacker.hpp:40
Implementation of 1-D std::vector like structure.