OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
object_si_d.hpp
1 /*
2  * vector_prop_copy.hpp
3  *
4  * Created on: May 31, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef VECTOR_PROP_COPY_HPP_
9 #define VECTOR_PROP_COPY_HPP_
10 
11 #include "for_each_ref.hpp"
12 #include <boost/mpl/range_c.hpp>
13 #include <boost/fusion/include/size.hpp>
14 
26 template<typename v_src,typename v_dst, int... prp>
28 {
29  // Convert the packed properties into an MPL vector
30  typedef typename to_boost_vmpl<prp...>::type v_prp;
31 
32  // Source object
33  const v_src & src;
34 
35  // Destination object
36  v_dst & dst;
37 
44  object_si_d_e(const v_src & src, v_dst & dst)
45  :src(src),dst(dst)
46  {
47  };
48 
50  template<typename T>
51  void operator()(T& t)
52  {
53  typedef typename boost::mpl::at<typename v_dst::type,typename boost::mpl::int_<T::value>>::type ctype;
54 
55  meta_copy<ctype>(src.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(),dst.template get<T::value>());
56  }
57 };
58 
59 
71 template<typename v_src,typename v_dst, int... prp>
73 {
74  // Convert the packed properties into an MPL vector
75  typedef typename to_boost_vmpl<prp...>::type v_prp;
76 
77  // Source object
78  const v_src & src;
79 
80  // Destination object
81  v_dst & dst;
82 
89  object_si_d_f(const v_src & src, v_dst & dst)
90  :src(src),dst(dst)
91  {
92  };
93 
95  template<typename T>
96  void operator()(T& t)
97  {
98  typedef typename boost::mpl::at<typename v_dst::type,typename boost::mpl::int_<T::value>>::type ctype;
99 
100  meta_copy<ctype>(boost::fusion::at_c<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(src.data),boost::fusion::at_c<T::value>(dst.data));
101  }
102 };
103 
104 #define OBJ_ENCAP 1
105 #define OBJ_NORMAL 2
106 
115 template<typename v_src, typename v_dst,int type_copy, int... prp>
117 {
118  inline object_si_d(const v_src & vs, v_dst & vd)
119  {
120  std::cerr << "Error object_copy: " << __FILE__ << " " << __LINE__ << "\n";
121  };
122 };
123 
133 template<typename v_src, typename v_dst, int... prp>
134 struct object_si_d<v_src,v_dst,OBJ_NORMAL,prp...>
135 {
136  inline object_si_d(const v_src && vs, v_dst && vd)
137  {
138  object_si_d_f<v_src,v_dst,prp...> obj(vs,vd);
139  boost::mpl::for_each_ref< boost::mpl::range_c<int,0,v_dst::max_prop> >(obj);
140  }
141 
142  inline object_si_d(const v_src & vs, v_dst & vd)
143  {
144  object_si_d_f<v_src,v_dst,prp...> obj(vs,vd);
145  boost::mpl::for_each_ref< boost::mpl::range_c<int,0,v_dst::max_prop> >(obj);
146  }
147 };
148 
163 template<typename v_src, typename v_dst, int... prp>
164 struct object_si_d<v_src,v_dst,OBJ_ENCAP,prp...>
165 {
166  inline object_si_d(const v_src && vs, v_dst && vd)
167  {
168  object_si_d_e<v_src,v_dst,prp...> obj(vs,vd);
169  boost::mpl::for_each_ref< boost::mpl::range_c<int,0,v_dst::max_prop> >(obj);
170  }
171 
172  inline object_si_d(const v_src & vs, v_dst & vd)
173  {
174  object_si_d_e<v_src,v_dst,prp...> obj(vs,vd);
175  boost::mpl::for_each_ref< boost::mpl::range_c<int,0,v_dst::max_prop> >(obj);
176  }
177 };
178 
179 
180 #endif /* VECTOR_PROP_COPY_HPP_ */
object_si_d_f(const v_src &src, v_dst &dst)
Constructor.
Definition: object_si_d.hpp:89
void operator()(T &t)
It call the functor for each member.
Definition: object_si_d.hpp:51
This class copy general objects.
void operator()(T &t)
It call the functor for each member.
Definition: object_si_d.hpp:96
this class is a functor for "for_each" algorithm
Definition: object_si_d.hpp:27
this class is a functor for "for_each" algorithm
Definition: object_si_d.hpp:72
It copy the properties from one object to another.
object_si_d_e(const v_src &src, v_dst &dst)
Constructor.
Definition: object_si_d.hpp:44