OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
object_si_di.hpp
1/*
2 * object_si_di.hpp
3 *
4 * Created on: Jun 11, 2015
5 * Author: i-bird
6 */
7
8#ifndef OBJECT_SI_DI_HPP_
9#define OBJECT_SI_DI_HPP_
10
11
12#include "for_each_ref.hpp"
13#include "util/variadic_to_vmpl.hpp"
14#include "util/copy_compare/meta_copy.hpp"
15#include <boost/mpl/range_c.hpp>
16#include <boost/fusion/include/size.hpp>
17
18
19
33template<template<typename,typename> class op, typename v_src,typename v_dst, int... prp>
35{
37 typedef typename to_boost_vmpl<prp...>::type v_prp;
38
40 const v_src & src;
41
43 v_dst & dst;
44
51 __device__ __host__ object_si_di_e_op(const v_src & src, v_dst & dst)
52 :src(src),dst(dst)
53 {
54 };
55
56#ifdef SE_CLASS1
63 object_si_di_e_op(v_src && src, v_dst & dst)
64 :src(src),dst(dst)
65 {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
66#endif
67
69 template<typename T>
70 __device__ __host__ void operator()(T& t)
71 {
72 // Remove the reference from the type to copy
73 typedef typename boost::remove_reference<decltype(dst.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>())>::type copy_dtype;
74 typedef typename std::remove_reference<decltype(src.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>())>::type copy_stype;
75
76 meta_copy_op_d<op,copy_stype,copy_dtype>::meta_copy_op_d_(src.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(),dst.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>());
77 }
78};
79
80
81template<typename v_src,typename v_dst, int... prp>
83{
85 typedef typename to_boost_vmpl<prp...>::type v_prp;
86
88 const v_src & src;
89
91 v_dst & dst;
92
99 __device__ __host__ object_si_di_e(const v_src & src, v_dst & dst)
100 :src(src),dst(dst)
101 {
102 };
103
104#ifdef SE_CLASS1
111 object_si_di_e(v_src && src, v_dst & dst)
112 :src(src),dst(dst)
113 {std::cerr << "Error: " <<__FILE__ << ":" << __LINE__ << " Passing a temporal object\n";};
114#endif
115
117 template<typename T>
118 __device__ __host__ void operator()(T& t)
119 {
120 // Remove the reference from the type to copy
121 typedef typename boost::remove_reference<decltype(dst.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>())>::type copy_dtype;
122 typedef typename std::remove_reference<decltype(src.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>())>::type copy_stype;
123
124 meta_copy_d<copy_stype,copy_dtype>::meta_copy_d_(src.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(),dst.template get<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>());
125 }
126};
127
128
129#define OBJ_ENCAP 1
130
132
141template<template<typename,typename> class op, typename v_src, typename v_dst,int type_copy, int... prp>
143{
150 inline object_si_di_op(const v_src & vs, v_dst & vd)
151 {
152 std::cerr << "Error object_copy: " << __FILE__ << " " << __LINE__ << "\n";
153 };
154};
155
164template<typename v_src, typename v_dst,int type_copy, int... prp>
166{
173 inline object_si_di(const v_src & vs, v_dst & vd)
174 {
175 std::cerr << "Error object_copy: " << __FILE__ << " " << __LINE__ << "\n";
176 };
177};
178
179
194template<template<typename,typename> class op, typename v_src, typename v_dst, int... prp>
195struct object_si_di_op<op, v_src,v_dst,OBJ_ENCAP,prp...>
196{
203 __device__ __host__ inline object_si_di_op(const v_src & vs, v_dst && vd)
204 {
205 object_si_di_e_op<op,v_src,v_dst,prp...> obj(vs,vd);
206 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,sizeof...(prp)> >(obj);
207 }
208
215 __device__ __host__ inline object_si_di_op(const v_src & vs, v_dst & vd)
216 {
217 object_si_di_e_op<op,v_src,v_dst,prp...> obj(vs,vd);
218 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,sizeof...(prp)> >(obj);
219 }
220};
221
236template<typename v_src, typename v_dst, int... prp>
237struct object_si_di<v_src,v_dst,OBJ_ENCAP,prp...>
238{
245 __device__ __host__ inline object_si_di(const v_src & vs, v_dst && vd)
246 {
247 object_si_di_e<v_src,v_dst,prp...> obj(vs,vd);
248 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,sizeof...(prp)> >(obj);
249 }
250
257 __device__ __host__ inline object_si_di(const v_src & vs, v_dst & vd)
258 {
259 object_si_di_e<v_src,v_dst,prp...> obj(vs,vd);
260 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,sizeof...(prp)> >(obj);
261 }
262};
263
264#endif /* OBJECT_WRITE_HPP_ */
__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__ static __host__ void meta_copy_op_d_(const Tsrc &src, Tdst &dst)
Meta-copy applying an operation.
__device__ __host__ object_si_di(const v_src &vs, v_dst &&vd)
Implementation of the copy with operation.
__device__ __host__ object_si_di(const v_src &vs, v_dst &vd)
Implementation of the copy with operation.
this class is a functor for "for_each" algorithm
const v_src & src
Source object.
v_dst & dst
Destination object.
__device__ __host__ void operator()(T &t)
It call the functor for each member.
to_boost_vmpl< prp... >::type v_prp
Convert the packed properties into an MPL vector.
__device__ __host__ object_si_di_e_op(const v_src &src, v_dst &dst)
Constructor.
__device__ __host__ object_si_di_e(const v_src &src, v_dst &dst)
Constructor.
to_boost_vmpl< prp... >::type v_prp
Convert the packed properties into an MPL vector.
v_dst & dst
Destination object.
const v_src & src
Source object.
__device__ __host__ void operator()(T &t)
It call the functor for each member.
__device__ __host__ object_si_di_op(const v_src &vs, v_dst &&vd)
Implementation of the copy with operation.
__device__ __host__ object_si_di_op(const v_src &vs, v_dst &vd)
Implementation of the copy with operation.
It copy the properties from one object to another applying an operation.
object_si_di_op(const v_src &vs, v_dst &vd)
Stub method.
It copy the properties from one object to another applying an operation.
object_si_di(const v_src &vs, v_dst &vd)
Stub method.