OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 
14 template<typename T> struct meta_copy;
15 template<template<typename,typename> class op, typename T> struct meta_copy_op;
16 template<typename T> struct meta_compare;
17 
23 template<typename S>
25 {
27  const S & src;
28 
30  S & dst;
31 
33  inline copy_aggregate(const S & src, S & dst)
34  :src(src),dst(dst){};
35 
37  template<typename T>
38  inline void operator()(T& t) const
39  {
40  // This is the type of the object we have to copy
41  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
42 
43  // Remove the reference from the type to copy
44  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
45 
46  meta_copy<copy_rtype>::meta_copy_(src.template get<T::value>(),dst.template get<T::value>());
47  }
48 };
49 
56 template<template<typename,typename> class op, typename S>
58 {
60  const S & src;
61 
63  S & dst;
64 
66  inline copy_aggregate_op(const S & src, S & dst)
67  :src(src),dst(dst){};
68 
70  template<typename T>
71  inline void operator()(T& t) const
72  {
73  // This is the type of the object we have to copy
74  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
75 
76  // Remove the reference from the type to copy
77  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
78 
79  meta_copy_op<op,copy_rtype>::meta_copy_op_(src.template get<T::value>(),dst.template get<T::value>());
80  }
81 };
82 
91 /*template<template<typename,typename> class op, typename S, unsigned int ... prp >
92 struct copy_aggregate_op_prp
93 {
95  const S & src;
96 
98  S & dst;
99 
101  inline copy_aggregate_op_prp(const S & src, S & dst)
102  :src(src),dst(dst){};
103 
105  template<typename T>
106  inline void operator()(T& t) const
107  {
108  // This is the type of the object we have to copy
109  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
110 
111  // Remove the reference from the type to copy
112  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
113 
114  // Convert variadic to boost::vector
115  typedef typename boost::mpl::vector_c<unsigned int,prp...> prpv;
116 
117  // element id to copy applying an operation
118  typedef typename boost::mpl::at<prpv,T>::type ele_cop;
119 
120  meta_copy_op<op,copy_rtype>::meta_copy_op_(src.template get< ele_cop::value >(),dst.template get< ele_cop::value >());
121  }
122 };*/
123 
129 template<typename S>
131 {
133  bool eq;
134 
136  const S & src;
137 
139  const S & dst;
140 
142  inline compare_aggregate(const S & src, const S & dst)
143  :eq(true),src(src),dst(dst){};
144 
146  template<typename T>
147  inline void operator()(T& t)
148  {
149  // This is the type of the object we have to copy
150  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type compare_type;
151 
152  // Remove the reference from the type to copy
153  typedef typename boost::remove_reference<compare_type>::type compare_rtype;
154 
155  if (eq == false)
156  return;
157 
158  eq = meta_compare<compare_rtype>::meta_compare_f(boost::fusion::at_c<T::value>(src.data),boost::fusion::at_c<T::value>(dst.data));
159  }
160 
166  inline bool result()
167  {
168  return eq;
169  }
170 };
171 
172 #endif /* OPENFPM_DATA_SRC_UTIL_COPY_COMPARE_AGGREGATES_HPP_ */
copy_aggregate(const S &src, S &dst)
copy_aggregate
void operator()(T &t) const
It call the copy function for each member.
Structure to copy aggregates.
Structure to copy aggregates applying an operation limited to some properties.
bool result()
Returh the result of the comparison.
bool eq
result of the comparation
static void meta_copy_(const T &src, T &dst)
copy and object from src to dst
Definition: meta_copy.hpp:37
static void meta_copy_op_(const T &src, T &dst)
Meta-copy applying an operation.
Definition: meta_copy.hpp:569
This class copy general objects applying an operation.
Structure to copy aggregates applying an operation.
void operator()(T &t) const
It call the copy function for each member.
void operator()(T &t)
It call the copy function for each member.
This class copy general objects.
compare_aggregate(const S &src, const S &dst)
copy_aggregate
S & dst
Destination grid.
This class compare general objects.
copy_aggregate_op(const S &src, S &dst)
copy_aggregate
S & dst
Destination grid.
const S & dst
Destination grid.