ivl 679
ivl/details/array/impl/catarray.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_DETAILS_ARRAY_CATARRAY_HPP
00025 #define IVL_DETAILS_ARRAY_CATARRAY_HPP
00026 
00027 namespace ivl {
00028 
00029 namespace array_details {
00030 
00031 template <class A1, class A2, int CATDIM>
00032 struct catarray_result
00033 {
00034         //need both be non-const
00035         /*
00036         typedef typename types::t_if<types::is_const<A>,
00037                 const typename A::derived_type, typename A::derived_type>::type a;
00038 
00039         typedef typename types::change_data_class_set<
00040                 data::catarray<a, I>, typename A::derived_type>::type type;
00041                 */
00042 };
00043 
00044 } /* namespace array_details */
00045 /*
00046 template <class A1, class A2, int CD>
00047 class catarray : public array_details::catarray_result<A1, A2, CD>::type
00048 {
00049 public:
00050         //operator catarray&() const { } //TODO: lets see..
00051         //catarray& operator*() { return const_cast<catarray&>(*this); }
00052         catarray& ref() { return *this; }
00053 
00054         typedef typename array_details::catarray_result<A1, A2, CD>
00055                 ::type base_class;
00056 
00057         typedef typename base_class::elem_type elem_type;
00058 
00059         base_class& base()
00060                 { return static_cast<base_class&>(*this); }
00061         const base_class& base() const
00062                 { return static_cast<const base_class&>(*this); }
00063 
00064         catarray(A1& a1, A2& a2, int dim = CD) { this->setref(a.derived(), i); }
00065 
00066         catarray(const catarray& a) : base_class(a.derived()) { }
00067 
00068         using base_class::operator();
00069 
00070         //using base_class::operator=;
00071         template<class K>
00072         catarray& operator=(const K& k)
00073         { base_class::operator=(k); return *this; }
00074 
00075         catarray& operator=(const catarray& o)
00076         { base_class::operator=(o); return *this; }
00077 
00078 
00079 
00080 };
00081 */
00082 
00083 
00084 
00085 template <class A1, class A2, int CD>
00086 class concat : public array_nd<typename A1::elem_type,
00087         data::catarray<A1, A2, CD> >
00088 {
00089 public:
00090         concat& ref() { return *this; }
00091 
00092         typedef array_nd<typename A1::elem_type,
00093         data::catarray<A1, A2, CD> > base_class;
00094 
00095         typedef typename base_class::elem_type elem_type;
00096 
00097         base_class& base()
00098                 { return static_cast<base_class&>(*this); }
00099         const base_class& base() const
00100                 { return static_cast<const base_class&>(*this); }
00101 
00102         concat(A1& a1, A2& a2, int dim = CD) :
00103         base_class(a1.size() + a2.size(dim) * cast<int>(rng(0, a2.ndims()-1) == dim))
00104                 { this->setref(a1, a2, dim); }
00105 
00106 /*
00107         template<class TP>
00108         concat(const internal::tuple_base<2, TP>& tp) :
00109         base_class(tp.derived().v1.size() + tp.derived().v2.size(CD) *
00110                                 cast<int>(rng(0, tp.derived().v2.ndims()-1) == CD))
00111                 { this->setref(tp.derived().v1, tp.derived().v2, CD); }
00112 */
00113         template<class T1, class T2>
00114         concat(const internal::tuple<T1, T2>& tp) :
00115         base_class(tp.v1.size() + tp.v2->size(CD) *
00116                                 cast<int>(rng(0, tp.v2->ndims()-1) == CD))
00117                 { this->setref(tp.v1, *tp.v2, CD); }
00118 
00119 
00120         concat(const concat& a) : base_class(a.derived()) { }
00121 
00122         using base_class::operator();
00123 
00124         //using base_class::operator=;
00125         template<class K>
00126         concat& operator=(const K& k)
00127         { base_class::operator=(k); return *this; }
00128 
00129         concat& operator=(const concat& o)
00130         { base_class::operator=(o); return *this; }
00131 
00132 
00133 
00134 };
00135 
00136 } /* namespace ivl */
00137 
00138 #endif // IVL_DETAILS_ARRAY_CATARRAY_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations