ivl 679
ivl/details/core/types/array_iterator.hpp
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_TYPES_ARRAY_ITERATOR_HPP
00025 #define IVL_CORE_DETAILS_TYPES_ARRAY_ITERATOR_HPP
00026 
00027 namespace ivl {
00028 namespace types {
00029 
00030 
00031 namespace types_details {
00032 
00033 template <class A, class WRITEABLE, int SPECIALIZATION>
00034 struct best_iterator { };
00035 
00036 template <class A>
00037 struct best_iterator<A, types::t_true, 0>
00038 {
00039         typedef typename A::iterator type;
00040 };
00041 
00042 template <class A>
00043 struct best_iterator<A, types::t_false, 0>
00044 {
00045         typedef typename A::const_iterator type;
00046 };
00047 
00048 template <class A, int SPC>
00049 struct best_iterator<A, types::t_true, SPC>
00050 {
00051         typedef typename A::template s_iterator<SPC>::type type;
00052 };
00053 
00054 template <class A, int SPC>
00055 struct best_iterator<A, types::t_false, SPC>
00056 {
00057         typedef typename A::template const_s_iterator<SPC>::type type;
00058 };
00059 
00060 template <class A, class WRITEABLE, int SPECIALIZATION>
00061 struct best_reverse_iterator { };
00062 
00063 template <class A>
00064 struct best_reverse_iterator<A, types::t_true, 0>
00065 {
00066         typedef typename A::reverse_iterator type;
00067 };
00068 
00069 template <class A>
00070 struct best_reverse_iterator<A, types::t_false, 0>
00071 {
00072         typedef typename A::const_reverse_iterator type;
00073 };
00074 
00075 // -------------------------------------------------
00076 
00077 template <
00078 class A,
00079 class WRITEABLE,
00080 int SPECIALIZATION = 0,
00081 bool PAST_END_CAPABLE = true
00082 >
00083 struct best_iterator_nd { };
00084 
00085 template <class A>
00086 struct best_iterator_nd<A, types::t_true, 0, true>
00087 {
00088         typedef typename A::iterator_nd type;
00089 };
00090 
00091 template <class A>
00092 struct best_iterator_nd<A, types::t_false, 0, true>
00093 {
00094         typedef typename A::const_iterator_nd type;
00095 };
00096 
00097 template <class A, int SPC>
00098 struct best_iterator_nd<A, types::t_true, SPC, true>
00099 {
00100         typedef typename A::template s_iterator_nd<SPC>::type type;
00101 };
00102 
00103 template <class A, int SPC>
00104 struct best_iterator_nd<A, types::t_false, SPC, true>
00105 {
00106         typedef typename A::template const_s_iterator_nd<SPC>::type type;
00107 };
00108 
00109 // --- not pastend capable nd
00110 template <class A>
00111 struct best_iterator_nd<A, types::t_true, 0, false>
00112 {
00113         typedef typename A::_fast_iterator_nd type;
00114 };
00115 
00116 template <class A>
00117 struct best_iterator_nd<A, types::t_false, 0, false>
00118 {
00119         typedef typename A::_fast_const_iterator_nd type;
00120 };
00121 
00122 template <class A, int SPC>
00123 struct best_iterator_nd<A, types::t_true, SPC, false>
00124 {
00125         typedef typename A::template _fast_s_iterator_nd<SPC>::type type;
00126 };
00127 
00128 template <class A, int SPC>
00129 struct best_iterator_nd<A, types::t_false, SPC, false>
00130 {
00131         typedef typename A::template _fast_const_s_iterator_nd<SPC>::type type;
00132 };
00133 
00134 // --- reverse nd
00135 
00136 template <class A, class WRITEABLE, int SPECIALIZATION = 0, int PAST_END = true>
00137 struct best_reverse_iterator_nd { };
00138 
00139 template <class A>
00140 struct best_reverse_iterator_nd<A, types::t_true, 0, true>
00141 {
00142         typedef typename A::reverse_iterator_nd type;
00143 };
00144 
00145 template <class A>
00146 struct best_reverse_iterator_nd<A, types::t_false, 0, true>
00147 {
00148         typedef typename A::const_reverse_iterator_nd type;
00149 };
00150 
00151 } /* namespace types_details */
00152 
00153 template <class A, int SPECIALIZATION = 0>
00154 struct best_iterator
00155 {
00156         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00157 
00158         typedef typename types_details::best_iterator<A,
00159                 typename is_writeable::type, SPECIALIZATION>::type type;
00160         /*
00161         typedef typename t_if<is_writeable,
00162                 typename
00163                 types_details::best_iterator<A, typename A::is_writeable,
00164                         SPECIALIZATION>::type,
00165                 typename
00166                 types_details::best_iterator<A, types::t_false, SPECIALIZATION>::type
00167                 >::type type;*/
00168 };
00169 
00170 template <int S>
00171 struct best_iterator<types::term, S> { typedef types::term type; };
00172 
00173 template <class A, int SPECIALIZATION = 0>
00174 struct best_reverse_iterator
00175 {
00176         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00177 
00178         typedef typename types_details::best_reverse_iterator<A,
00179                 typename is_writeable::type, SPECIALIZATION>::type type;
00180 
00181         /*
00182         typedef typename t_if<is_writeable,
00183                 typename
00184                 types_details::best_reverse_iterator<A, typename A::is_writeable,
00185                         SPECIALIZATION>::type,
00186                 typename
00187                 types_details::best_reverse_iterator<A, types::t_false,
00188                         SPECIALIZATION>::type
00189                 >::type type;*/
00190 };
00191 
00192 template <int S>
00193 struct best_reverse_iterator<types::term, S> { typedef types::term type; };
00194 
00195 template <class A, int SPECIALIZATION = 0, bool PAST_END_CAPABLE = true>
00196 struct best_iterator_nd
00197 {
00198         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00199 
00200         typedef typename types_details::best_iterator_nd<A,
00201                 typename is_writeable::type, SPECIALIZATION, PAST_END_CAPABLE>
00202                 ::type type;
00203                 /*
00204         typedef typename t_if<is_writeable,
00205                 typename
00206                 types_details::best_iterator_nd<A, typename A::is_writeable,
00207                         SPECIALIZATION>::type,
00208                 typename
00209                 types_details::best_iterator_nd<A, types::t_false, SPECIALIZATION>::type
00210                 >::type type;*/
00211 };
00212 
00213 template <int S, bool P>
00214 struct best_iterator_nd<types::term, S, P> { typedef types::term type; };
00215 
00216 template <class A, int SPECIALIZATION = 0>
00217 struct best_fast_iterator_nd
00218 : public best_iterator_nd<A, SPECIALIZATION, false>
00219 {
00220 };
00221 
00222 template <class A, int SPECIALIZATION = 0, bool PAST_END_CAPABLE = true>
00223 struct best_reverse_iterator_nd
00224 {
00225         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00226 
00227         typedef typename types_details::best_reverse_iterator_nd<A,
00228                 typename is_writeable::type, SPECIALIZATION, PAST_END_CAPABLE>
00229                 ::type type;
00230 /*
00231         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00232         typedef typename t_if<is_writeable,
00233                 typename
00234                 types_details::best_reverse_iterator_nd<A, typename A::is_writeable,
00235                         SPECIALIZATION>::type,
00236                 typename
00237                 types_details::best_reverse_iterator_nd<A, types::t_false,
00238                         SPECIALIZATION>::type
00239                 >::type type;*/
00240 };
00241 
00242 template <int S, bool P>
00243 struct best_reverse_iterator_nd<types::term, S, P>
00244 { typedef types::term type; };
00245 
00246 /*
00247 template <class A>
00248 struct best_iterator_nd
00249 {
00250         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00251         typedef typename t_if<t_and<t_not<is_const<A> >, typename A::is_writeable>,
00252                 typename
00253                 types_details::best_iterator_nd<A, typename A::is_writeable>::type,
00254                 typename A::const_iterator_nd>::type type;
00255 };
00256 
00257 template <class A>
00258 struct best_reverse_iterator_nd
00259 {
00260         typedef t_and<t_not<is_const<A> >, typename A::is_writeable> is_writeable;
00261         typedef typename t_if<t_and<t_not<is_const<A> >, typename A::is_writeable>,
00262                 typename types_details::
00263                         best_reverse_iterator_nd<A, typename A::is_writeable>::type,
00264                 typename A::const_reverse_iterator_nd>::type type;
00265 };
00266 */
00267 
00268 } /* namespace types */
00269 } /* namespace ivl */
00270 
00271 #endif // IVL_CORE_DETAILS_TYPES_ARRAY_ITERATOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations