OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 
16 template<typename bfv>
18 {
20  const bfv & src;
21 
23  bfv & dst;
24 
33  inline copy_fusion_vector(const bfv & src, bfv & dst)
34  :src(src),dst(dst){};
35 
36 #ifdef SE_CLASS1
37 
43  inline copy_fusion_vector(const bfv && src, bfv && dst)
44  :src(src),dst(dst)
45  {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
46 #endif
47 
49  template<typename T>
50  inline void operator()(T& t)
51  {
52  // This is the type of the object we have to copy
53  typedef typename boost::fusion::result_of::at_c<bfv,T::value>::type copy_type;
54 
55  // Remove the reference from the type to copy
56  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
57 
58  meta_copy<copy_rtype>::meta_copy_(boost::fusion::at_c<T::value>(src),boost::fusion::at_c<T::value>(dst));
59  }
60 };
61 
62 
68 template<typename bfv, typename enc>
70 {
72  const bfv & src;
73 
75  enc & dst;
76 
85  inline copy_fusion_vector_encap(const bfv & src, enc & dst)
86  :src(src),dst(dst){};
87 
88 #ifdef SE_CLASS1
89 
95  inline copy_fusion_vector_encap(const bfv && src, enc && dst)
96  :src(src),dst(dst)
97  {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
98 #endif
99 
101  template<typename T>
102  inline void operator()(T& t)
103  {
104  typedef typename boost::mpl::at<bfv,boost::mpl::int_<T::value> >::type copy_src;
105  typedef typename std::remove_reference<decltype(dst.template get<T::value>())>::type copy_dst;
106 
107  meta_copy_d<copy_src,copy_dst>::meta_copy_d_(boost::fusion::at_c<T::value>(src),dst.template get<T::value>());
108  }
109 };
110 
111 
112 #endif /* OPENFPM_DATA_SRC_GRID_COPY_FUSION_VECTOR_HPP_ */
const bfv & src
source fusion vector
static void meta_copy_(const T &src, T &dst)
copy and object from src to dst
Definition: meta_copy.hpp:37
bfv & dst
destination fusion vector
const bfv & src
source fusion vector
void operator()(T &t)
It call the copy function for each property.
copy_fusion_vector_encap(const bfv &src, enc &dst)
constructor
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
copy_fusion_vector(const bfv &src, bfv &dst)
constructor
this class is a functor for "for_each" algorithm
static void meta_copy_d_(const Tsrc &src, Tdst &dst)
copy and object from src to dst
Definition: meta_copy.hpp:69