OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
15template<typename T> struct meta_copy;
16template<template<typename,typename> class op, typename T> struct meta_copy_op;
17template<typename T> struct meta_compare;
18template<typename Tsrc,typename Tdst> struct meta_copy_d;
19
25template<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
52template<typename T> struct meta_copy;
53template<template<typename,typename> class op, typename T> struct meta_copy_op;
54template<typename T> struct meta_compare;
55
61template<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
94template<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
127template<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_ */
Structure to compare aggregates.
bool result()
Returh the result of the comparison.
compare_aggregate(const S &src, const S &dst)
copy_aggregate
const S & dst
Destination grid.
void operator()(T &t)
It call the copy function for each member.
bool eq
result of the comparation
Structure to copy aggregates.
void operator()(T &t) const
It call the copy function for each member.
S2 & dst
Destination grid.
copy_aggregate_dual(S src, S2 &dst)
copy_aggregate
Structure to copy aggregates applying an operation.
void operator()(T &t) const
It call the copy function for each member.
copy_aggregate_op(const S &src, S &dst)
copy_aggregate
Structure to copy aggregates.
copy_aggregate(const S &src, S &dst)
copy_aggregate
void operator()(T &t) const
It call the copy function for each member.
S & dst
Destination grid.
This class compare general objects.
copy for a source object to a destination
Definition meta_copy.hpp:85
This class copy general objects applying an operation.
static void meta_copy_op_(const T &src, T &dst)
Meta-copy applying an operation.
This class copy general objects.
Definition meta_copy.hpp:53
__device__ static __host__ void meta_copy_(const T &src, T &dst)
copy and object from src to dst
Definition meta_copy.hpp:60