OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
copy_fusion_vector.hpp
1 /*
2  * copy_fusion_vector.hpp
3  *
4  * Created on: Nov 1, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_GRID_COPY_FUSION_VECTOR_HPP_
9 #define OPENFPM_DATA_SRC_GRID_COPY_FUSION_VECTOR_HPP_
10 
11 
17 template<typename bfv, typename enc>
19 {
21  const bfv & src;
22 
24  enc & dst;
25 
34  __device__ __host__ inline copy_fusion_vector_encap(const bfv & src, enc & dst)
35  :src(src),dst(dst){};
36 
37 #ifdef SE_CLASS1
38 
44  inline copy_fusion_vector_encap(const bfv && src, enc && dst)
45  :src(src),dst(dst)
46  {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
47 #endif
48 
50  template<typename T>
51  __device__ __host__ inline void operator()(T& t)
52  {
53  typedef typename boost::mpl::at<bfv,boost::mpl::int_<T::value> >::type copy_src;
54  typedef typename std::remove_reference<decltype(dst.template get<T::value>())>::type copy_dst;
55 
56  meta_copy_d<copy_src,copy_dst>::meta_copy_d_(boost::fusion::at_c<T::value>(src),dst.template get<T::value>());
57  }
58 };
59 
60 
66 template<typename enc, typename bfv>
68 {
70  const enc & src;
71 
73  bfv & dst;
74 
83  __device__ __host__ inline copy_encap_vector_fusion(const enc & src, bfv & dst)
84  :src(src),dst(dst){};
85 
86 #ifdef SE_CLASS1
87 
93  __device__ __host__ inline copy_encap_vector_fusion(const enc && src, bfv && dst)
94  :src(src),dst(dst)
95  {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
96 #endif
97 
99  template<typename T>
100  __device__ __host__ inline void operator()(T& t)
101  {
102  typedef typename boost::mpl::at<bfv,boost::mpl::int_<T::value> >::type copy_dst;
103  typedef typename std::remove_reference<decltype(src.template get<T::value>())>::type copy_src;
104 
105  meta_copy_d<copy_src,copy_dst>::meta_copy_d_(src.template get<T::value>(),boost::fusion::at_c<T::value>(dst));
106  }
107 };
108 
109 #endif /* OPENFPM_DATA_SRC_GRID_COPY_FUSION_VECTOR_HPP_ */
const enc & src
source fusion vector
const bfv & src
source fusion vector
this class is a functor for "for_each" algorithm
__device__ static __host__ void meta_copy_d_(const Tsrc &src, Tdst &dst)
copy and object from src to dst
Definition: meta_copy.hpp:92
__device__ __host__ void operator()(T &t)
It call the copy function for each property.
enc & dst
destination fusion vector
this class is a functor for "for_each" algorithm
__device__ __host__ void operator()(T &t)
It call the copy function for each property.
__device__ __host__ copy_encap_vector_fusion(const enc &src, bfv &dst)
constructor
__device__ __host__ copy_fusion_vector_encap(const bfv &src, enc &dst)
constructor
bfv & dst
destination fusion vector