1/*
2 * util.hpp
3 *
4 * Created on: Jul 16, 2015
5 * Author: i-bird
6 */
7
8#ifndef SRC_VECTOR_UTIL_HPP_
9#define SRC_VECTOR_UTIL_HPP_
10
11#include "util/common.hpp"
12
13
14template<typename T, typename Sfinae = void>
15struct is_vector: std::false_type {};
16
17/*! \brief is_grid check if the type is a vector
18 *
19 * ### Example
20 *
21 * \snippet util.hpp Check is_vector
22 *
23 * return true if T is a vector
24 *
25 */
26template<typename T>
27struct is_vector<T, typename Void< typename T::yes_i_am_vector>::type > : std::true_type
28{};
29
30///////////////////////////////////////////////////////////////////////////////////////////////////////////
31
32template<typename T, typename Sfinae = void>
33struct is_vector_native: std::false_type {};
34
35
36/*! \brief is_grid check if the type is a vector
37 *
38 * ### Example
39 *
40 * \snippet util.hpp Check is_vector
41 *
42 * return true if T is a vector
43 *
44 */
45template<typename T>
46struct is_vector_native<T, typename Void< typename T::yes_i_am_vector_native>::type > : std::true_type
47{};
48
49///////////////////////////////////////////////////////////////////////////////////////////////////////////
50
51template<typename T, typename Sfinae = void>
52struct is_vector_dist: std::false_type {};
53
54
55/*! \brief is_grid check if the type is a vector
56 *
57 * ### Example
58 *
59 * \snippet util.hpp Check is_vector
60 *
61 * return true if T is a vector
62 *
63 */
64template<typename T>
65struct is_vector_dist<T, typename Void< typename T::yes_i_am_vector_dist>::type > : std::true_type
66{};
67
68///////////////////////////////////////////////////////////////////////////////////////////////////////////
69
70/*! \brief Check this is a gpu or cpu type cell-list
71 *
72 */
73template<typename T, typename Sfinae = void>
74struct is_gpu_celllist: std::false_type {};
75
76
77template<typename T>
78struct is_gpu_celllist<T, typename Void<typename T::yes_is_gpu_celllist>::type> : std::true_type
79{};
80
81///////////////////////////////////////////////////////////////////////////////////////////////////////////
82
83/*! \brief Check this is a gpu or cpu type cell-list
84 *
85 */
86template<typename T, typename Sfinae = void>
87struct is_gpu_ker_celllist: std::false_type {};
88
89
90template<typename T>
91struct is_gpu_ker_celllist<T, typename Void<typename T::yes_is_gpu_ker_celllist>::type> : std::true_type
92{};
93
94// structure to check the device pointer
95
96/*! \brief this class is a functor for "for_each" algorithm
97 *
98 * This class is a functor for "for_each" algorithm. It check if the
99 * pointer ptr match one of the pointer properties
100 *
101 */
102template<typename data_type>
103struct check_device_ptr
104{
105 //! pointer to check
106 void * ptr;
107
108 //! Data to check
109 data_type & data;
110
111 mutable int prp;
112
113 mutable bool result;
114
115 /*! \brief constructor
116 *
117 * \param ptr pointer to check
118 * \param data data structure
119 *
120 */
121 inline check_device_ptr(void * ptr, data_type & data)
122 :ptr(ptr),data(data),result(false)
123 {};
124
125 //! It call the copy function for each property
126 template<typename T>
127 inline void operator()(T& t)
128 {
129 if (data.template getPointer<T::value>() == ptr)
130 {
131 prp = T::value;
132 result = true;
133 }
134 }
135};
136
137#endif /* SRC_VECTOR_UTIL_HPP_ */
138