1 /*M/////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 // 5 // By downloading, copying, installing or using the software you agree to this license. 6 // If you do not agree to this license, do not download, install, 7 // copy or use the software. 8 // 9 // 10 // License Agreement 11 // For Open Source Computer Vision Library 12 // 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved. 16 // Third party copyrights are property of their respective owners. 17 // 18 // Redistribution and use in source and binary forms, with or without modification, 19 // are permitted provided that the following conditions are met: 20 // 21 // * Redistribution's of source code must retain the above copyright notice, 22 // this list of conditions and the following disclaimer. 23 // 24 // * Redistribution's in binary form must reproduce the above copyright notice, 25 // this list of conditions and the following disclaimer in the documentation 26 // and/or other materials provided with the distribution. 27 // 28 // * The name of the copyright holders may not be used to endorse or promote products 29 // derived from this software without specific prior written permission. 30 // 31 // This software is provided by the copyright holders and contributors "as is" and 32 // any express or implied warranties, including, but not limited to, the implied 33 // warranties of merchantability and fitness for a particular purpose are disclaimed. 34 // In no event shall the Intel Corporation or contributors be liable for any direct, 35 // indirect, incidental, special, exemplary, or consequential damages 36 // (including, but not limited to, procurement of substitute goods or services; 37 // loss of use, data, or profits; or business interruption) however caused 38 // and on any theory of liability, whether in contract, strict liability, 39 // or tort (including negligence or otherwise) arising in any way out of 40 // the use of this software, even if advised of the possibility of such damage. 41 // 42 //M*/ 43 44 #pragma once 45 46 #ifndef __OPENCV_CUDEV_UTIL_TUPLE_DETAIL_HPP__ 47 #define __OPENCV_CUDEV_UTIL_TUPLE_DETAIL_HPP__ 48 49 #include <thrust/tuple.h> 50 51 namespace cv { namespace cudev { 52 53 namespace tuple_detail 54 { 55 using thrust::tuple; 56 using thrust::tuple_size; 57 using thrust::get; 58 using thrust::tuple_element; 59 using thrust::make_tuple; 60 using thrust::tie; 61 62 template <class Tuple, int SIZE, template <typename T> class CvtOp> struct ConvertTuple; 63 64 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 2, CvtOp> 65 { 66 typedef tuple< 67 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 68 typename CvtOp<typename tuple_element<1, Tuple>::type>::type 69 > type; 70 }; 71 72 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 3, CvtOp> 73 { 74 typedef tuple< 75 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 76 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 77 typename CvtOp<typename tuple_element<2, Tuple>::type>::type 78 > type; 79 }; 80 81 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 4, CvtOp> 82 { 83 typedef tuple< 84 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 85 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 86 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 87 typename CvtOp<typename tuple_element<3, Tuple>::type>::type 88 > type; 89 }; 90 91 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 5, CvtOp> 92 { 93 typedef tuple< 94 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 95 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 96 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 97 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 98 typename CvtOp<typename tuple_element<4, Tuple>::type>::type 99 > type; 100 }; 101 102 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 6, CvtOp> 103 { 104 typedef tuple< 105 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 106 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 107 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 108 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 109 typename CvtOp<typename tuple_element<4, Tuple>::type>::type, 110 typename CvtOp<typename tuple_element<5, Tuple>::type>::type 111 > type; 112 }; 113 114 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 7, CvtOp> 115 { 116 typedef tuple< 117 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 118 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 119 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 120 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 121 typename CvtOp<typename tuple_element<4, Tuple>::type>::type, 122 typename CvtOp<typename tuple_element<5, Tuple>::type>::type, 123 typename CvtOp<typename tuple_element<6, Tuple>::type>::type 124 > type; 125 }; 126 127 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 8, CvtOp> 128 { 129 typedef tuple< 130 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 131 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 132 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 133 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 134 typename CvtOp<typename tuple_element<4, Tuple>::type>::type, 135 typename CvtOp<typename tuple_element<5, Tuple>::type>::type, 136 typename CvtOp<typename tuple_element<6, Tuple>::type>::type, 137 typename CvtOp<typename tuple_element<7, Tuple>::type>::type 138 > type; 139 }; 140 141 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 9, CvtOp> 142 { 143 typedef tuple< 144 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 145 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 146 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 147 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 148 typename CvtOp<typename tuple_element<4, Tuple>::type>::type, 149 typename CvtOp<typename tuple_element<5, Tuple>::type>::type, 150 typename CvtOp<typename tuple_element<6, Tuple>::type>::type, 151 typename CvtOp<typename tuple_element<7, Tuple>::type>::type, 152 typename CvtOp<typename tuple_element<8, Tuple>::type>::type 153 > type; 154 }; 155 156 template <class Tuple, template <typename T> class CvtOp> struct ConvertTuple<Tuple, 10, CvtOp> 157 { 158 typedef tuple< 159 typename CvtOp<typename tuple_element<0, Tuple>::type>::type, 160 typename CvtOp<typename tuple_element<1, Tuple>::type>::type, 161 typename CvtOp<typename tuple_element<2, Tuple>::type>::type, 162 typename CvtOp<typename tuple_element<3, Tuple>::type>::type, 163 typename CvtOp<typename tuple_element<4, Tuple>::type>::type, 164 typename CvtOp<typename tuple_element<5, Tuple>::type>::type, 165 typename CvtOp<typename tuple_element<6, Tuple>::type>::type, 166 typename CvtOp<typename tuple_element<7, Tuple>::type>::type, 167 typename CvtOp<typename tuple_element<8, Tuple>::type>::type, 168 typename CvtOp<typename tuple_element<9, Tuple>::type>::type 169 > type; 170 }; 171 } 172 173 }} 174 175 #endif 176