ivl 679
|
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>. 00002 A C++ template library extending syntax towards mathematical notation. 00003 00004 Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr> 00005 Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr> 00006 00007 ivl is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License 00009 version 3 as published by the Free Software Foundation. 00010 00011 Alternatively, you can redistribute it and/or modify it under the terms 00012 of the GNU General Public License version 2 as published by the Free 00013 Software Foundation. 00014 00015 ivl is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 and a copy of the GNU Lesser General Public License along 00022 with ivl. If not, see <http://www.gnu.org/licenses/>. */ 00023 00024 #ifndef IVL_CORE_DETAILS_DATA_BASE_HPP 00025 #define IVL_CORE_DETAILS_DATA_BASE_HPP 00026 00027 #include <iostream> 00028 00029 namespace ivl { 00030 00031 namespace data { 00032 00033 template <class DATA_CLASS> 00034 struct get_image_channels 00035 { 00036 typedef types::number<0> type; 00037 }; 00038 00039 } /* namespace data */ 00040 00041 /* 00042 use<array> 00043 use_1t<arrayx> 00044 00045 use<CC> 00046 CC<a,use<array> 00047 */ 00048 namespace data { 00049 /* 00050 template <class DATA_ID, class PARAMS> 00051 struct array_traits { }; 00052 00053 template < 00054 class X1 = types::term, 00055 class X2 = types::term, 00056 class X3 = types::term, 00057 class X4 = types::term, 00058 class X5 = types::term, 00059 class X6 = types::term, 00060 class X7 = types::term, 00061 class X8 = types::term, 00062 class X9 = types::term> 00063 class params { }; 00064 00065 template < 00066 class DATA_IDENTIFIER, 00067 class OPTIMAL_ACCESS, 00068 class RANDOM_ACCESS, 00069 class WRITEABLE, 00070 class CREATEABLE, 00071 class RESIZEABLE, 00072 class HAS_C_PTR, 00073 class HAS_SPECIALIZED_ITER 00074 > 00075 struct array_traits<DATA_IDENTIFIER, 00076 params< 00077 OPTIMAL_ACCESS, 00078 RANDOM_ACCESS, 00079 WRITEABLE, 00080 CREATEABLE, 00081 RESIZEABLE, 00082 HAS_C_PTR, 00083 HAS_SPECIALIZED_ITER 00084 > 00085 > 00086 : public DATA_IDENTIFIER 00087 { 00088 typedef DATA_IDENTIFIER data_identifier; 00089 typedef OPTIMAL_ACCESS optimal_access_tag; 00090 typedef RANDOM_ACCESS has_random_access; 00091 typedef WRITEABLE is_writeable; 00092 typedef CREATEABLE is_createable; 00093 typedef RESIZEABLE is_resizeable; 00094 typedef HAS_C_PTR has_c_ptr; 00095 typedef HAS_SPECIALIZED_ITER has_specialized_iter; 00096 }; 00097 */ 00098 00099 // optimal_access_tags: 00100 struct seq_optimal_tag { enum { evaluate = 1 } eval; }; 00101 struct random_optimal_tag { enum { evaluate = 2 } eval; }; 00102 struct nd_seq_optimal_tag { enum { evaluate = 0 } eval; }; 00103 00104 template <class X> 00105 class referer : public types::array_is_referer_identifier 00106 { 00107 public: 00108 typedef X derived_type; 00109 X& derived() { return static_cast<X&>(*this); } 00110 const X& derived() const { return static_cast<const X&>(*this); } 00111 }; 00112 00113 template <class X, class Y> 00114 struct minimum_access_tag 00115 { 00116 //typedef typename 00117 // types::t_if<typename types:: 00118 // t_expr<(true)>::type, X, Y>::type type; 00119 00120 enum { x_eval = X::evaluate }; 00121 enum { y_eval = Y::evaluate }; 00122 00123 typedef typename 00124 types::t_if<typename types::t_expr<(int(x_eval) < int(y_eval))>:: 00125 type, X, Y>::type type; 00126 }; 00127 00128 template <template <typename, typename> class CC> 00129 struct use 00130 { 00131 template <class T, class CHILD_CLASS> 00132 struct instance 00133 { 00134 typedef CC <T, CHILD_CLASS> type; 00135 }; 00136 }; 00137 00138 template <template <typename, int, typename> class CC, int N1> 00139 struct use_1n 00140 { 00141 template <class T, class CHILD_CLASS> 00142 struct instance 00143 { 00144 typedef CC <T, N1, CHILD_CLASS> type; 00145 }; 00146 }; 00147 00148 template <template <typename, typename, typename> class CC, class P1> 00149 struct use_1t 00150 { 00151 template <class T, class CHILD_CLASS> 00152 struct instance 00153 { 00154 typedef CC <T, P1, CHILD_CLASS> type; 00155 }; 00156 }; 00157 00158 template <template <typename, typename, typename, typename> class CC, 00159 class P1, class P2> 00160 struct use_2t 00161 { 00162 template <class T, class CHILD_CLASS> 00163 struct instance 00164 { 00165 typedef CC <T, P1, P2, CHILD_CLASS> type; 00166 }; 00167 }; 00168 00169 template <template <typename, typename, typename, typename, typename> class CC, 00170 class P1, class P2, class P3> 00171 struct use_3t 00172 { 00173 template <class T, class CHILD_CLASS> 00174 struct instance 00175 { 00176 typedef CC <T, P1, P2, P3, CHILD_CLASS> type; 00177 }; 00178 }; 00179 00180 template <template <typename, typename, typename, typename, typename, typename> class CC, 00181 class P1, class P2, class P3, class P4> 00182 struct use_4t 00183 { 00184 template <class T, class CHILD_CLASS> 00185 struct instance 00186 { 00187 typedef CC <T, P1, P2, P3, P4, CHILD_CLASS> type; 00188 }; 00189 }; 00190 00191 00192 00193 00194 } //namespace data 00195 00196 } //namespace ivl 00197 00198 00199 00200 #endif // IVL_CORE_DETAILS_DATA_BASE_HPP