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
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 
13 template<typename T> struct meta_copy;
14 template<typename T> struct meta_compare;
15 
21 template<typename S>
23 {
25  const S & src;
26 
28  S & dst;
29 
31  inline copy_aggregate(const S & src, S & dst)
32  :src(src),dst(dst){};
33 
35  template<typename T>
36  inline void operator()(T& t) const
37  {
38  // This is the type of the object we have to copy
39  typedef typename boost::fusion::result_of::at_c<typename S::type,T::value>::type copy_type;
40 
41  // Remove the reference from the type to copy
42  typedef typename boost::remove_reference<copy_type>::type copy_rtype;
43 
44  meta_copy<copy_rtype> cp(src.template get<T::value>(),dst.template get<T::value>());
45  }
46 };
47 
48 
54 template<typename S>
56 {
57  bool eq;
58 
60  const S & src;
61 
63  const S & dst;
64 
66  inline compare_aggregate(const S & src, const S & dst)
67  :eq(true),src(src),dst(dst){};
68 
70  template<typename T>
71  inline void operator()(T& t)
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 compare_type;
75 
76  // Remove the reference from the type to copy
77  typedef typename boost::remove_reference<compare_type>::type compare_rtype;
78 
79  if (eq == false)
80  return;
81 
82  eq = meta_compare<compare_rtype>::meta_compare_f(boost::fusion::at_c<T::value>(src.data),boost::fusion::at_c<T::value>(dst.data));
83  }
84 
90  inline bool result()
91  {
92  return eq;
93  }
94 };
95 
96 #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 compare aggregates.
bool result()
Returh the result of the comparison.
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
This class compare general objects.
S & dst
Destination grid.
const S & dst
Destination grid.