OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
copy_compare_aggregates.hpp
1 /*
2  * copy_aggregates.hpp
3  *
4  * Created on: Oct 31, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_UTIL_COPY_COMPARE_AGGREGATES_HPP_
9 #define OPENFPM_DATA_SRC_UTIL_COPY_COMPARE_AGGREGATES_HPP_
10 
11 #include <boost/type_traits.hpp>
12 #include <boost/mpl/vector_c.hpp>
13 #include <iostream>
14 
15 template<typename T> struct meta_copy;
16 template<template<typename,typename> class op, typename T> struct meta_copy_op;
17 template<typename T> struct meta_compare;
18 template<typename Tsrc,typename Tdst> struct meta_copy_d;
19 
25 template<typename S, typename S2>
27 {
29  const S src;
30 
32  S2 & dst;
33 
35  inline copy_aggregate_dual(S src, S2 & dst)
36  :src(src),dst(dst){};
37 
39  template<typename T>
40  inline void operator()(T& t) const
41  {
42  // This is the type of the object we have to copy
43  typedef typename boost::fusion::result_of::at_c<typename S2::type,T::value>::type copy_type;
44 
45  // Remove the reference from the type to copy
46  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
47 
48  meta_copy_d<decltype(src.template get<T::value>()), copy_rtype>::meta_copy_d_(src.template get<T::value>(),dst.template get<T::value>());
49  }
50 };
51 
52 template<typename T> struct meta_copy;
53 template<template<typename,typename> class op, typename T> struct meta_copy_op;
54 template<typename T> struct meta_compare;
55 
61 template<typename S>
63 {
65  const S & src;
66 
68  S & dst;
69 
71  inline copy_aggregate(const S & src, S & dst)
72  :src(src),dst(dst){};
73 
75  template<typename T>
76  inline void operator()(T& t) const
77  {
78  // This is the type of the object we have to copy
79  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
80 
81  // Remove the reference from the type to copy
82  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
83 
84  meta_copy<copy_rtype>::meta_copy_(src.template get<T::value>(),dst.template get<T::value>());
85  }
86 };
87 
94 template<template<typename,typename> class op, typename S>
96 {
98  const S & src;
99 
101  S & dst;
102 
104  inline copy_aggregate_op(const S & src, S & dst)
105  :src(src),dst(dst){};
106 
108  template<typename T>
109  inline void operator()(T& t) const
110  {
111  // This is the type of the object we have to copy
112  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
113 
114  // Remove the reference from the type to copy
115  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
116 
117  meta_copy_op<op,copy_rtype>::meta_copy_op_(src.template get<T::value>(),dst.template get<T::value>());
118  }
119 };
120 
121 
127 template<typename S>
129 {
131  bool eq;
132 
134  const S & src;
135 
137  const S & dst;
138 
140  inline compare_aggregate(const S & src, const S & dst)
141  :eq(true),src(src),dst(dst){};
142 
144  template<typename T>
145  inline void operator()(T& t)
146  {
147  // This is the type of the object we have to copy
148  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type compare_type;
149 
150  // Remove the reference from the type to copy
151  typedef typename boost::remove_reference<compare_type>::type compare_rtype;
152 
153  if (eq == false)
154  return;
155 
156  eq = meta_compare<compare_rtype>::meta_compare_f(boost::fusion::at_c<T::value>(src.data),boost::fusion::at_c<T::value>(dst.data));
157  }
158 
164  inline bool result()
165  {
166  return eq;
167  }
168 };
169 
170 #endif /* OPENFPM_DATA_SRC_UTIL_COPY_COMPARE_AGGREGATES_HPP_ */
copy_aggregate(const S &src, S &dst)
copy_aggregate
Structure to copy aggregates.
__device__ static __host__ void meta_copy_(const T &src, T &dst)
copy and object from src to dst
Definition: meta_copy.hpp:60
Structure to compare aggregates.
bool result()
Returh the result of the comparison.
bool eq
result of the comparation
static void meta_copy_op_(const T &src, T &dst)
Meta-copy applying an operation.
Definition: meta_copy.hpp:710
This class copy general objects applying an operation.
void operator()(T &t) const
It call the copy function for each member.
void operator()(T &t) const
It call the copy function for each member.
Structure to copy aggregates applying an operation.
void operator()(T &t)
It call the copy function for each member.
This class copy general objects.
S2 & dst
Destination grid.
compare_aggregate(const S &src, const S &dst)
copy_aggregate
S & dst
Destination grid.
void operator()(T &t) const
It call the copy function for each member.
This class compare general objects.
copy for a source object to a destination
copy_aggregate_dual(S src, S2 &dst)
copy_aggregate
copy_aggregate_op(const S &src, S &dst)
copy_aggregate
Structure to copy aggregates.
S & dst
Destination grid.
const S & dst
Destination grid.