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_IMAGE_DETAILS_IMAGE_COMMON_BASE_HPP 00025 #define IVL_IMAGE_DETAILS_IMAGE_COMMON_BASE_HPP 00026 00027 namespace ivl { 00028 00029 template <class T, class OPTS> 00030 class array_common_base<image<T, OPTS> > 00031 : 00032 public types::t_if< 00033 00034 // image of 1 channel is array_2d ! 00035 types::t_eq<typename data::get_image_channels< 00036 OPTS>::type, types::number<1> >, 00037 00038 //types::t_expr<( 00039 // OPTS::image_channels == 1)>, 00040 00041 array_2d<T, typename types::derive_opts<image<T, OPTS> >::type>, 00042 00043 array_nd<T, typename types::derive_opts<image<T, OPTS> >::type> 00044 00045 >::type, 00046 00047 public array_common_base<common_container_base<T, image<T, OPTS> > > 00048 { 00049 private: 00050 //typedef typename data::get_image_channels< 00051 // typename OPTS::data_type>::type prv_im_channels; 00052 00053 //enum { N = prv_im_channels::value }; 00054 00055 // the type of the image 00056 typedef image<T, OPTS> t; 00057 00058 typedef array_common_base< 00059 common_container_base<T, image<T, OPTS> > > prv_common; 00060 00061 typedef array_common_base prv_this_type; 00062 00063 typedef typename prv_this_type::array_nd_or_2d_type prv_base_class; 00064 /* 00065 typedef typename types::t_if<types::t_expr<(N == 1)>, // image of 1 channel is array_2d ! 00066 array_2d<T, DATA_CLASS_SET, typename types::derive <t> ::type>, 00067 array_nd<T, DATA_CLASS_SET, typename types::derive <t> ::type> 00068 >::type prv_base_class;*/ 00069 00070 public: 00071 using prv_base_class::Ch; 00072 00073 typedef prv_base_class base_class; 00074 00075 typedef t image_type; 00076 typedef t current_type; 00077 typedef t container_type; 00078 00079 typedef typename prv_base_class::all_init_arg all_init_arg; 00080 typedef typename prv_base_class::data_init_arg data_init_arg; 00081 00082 t& to_current() { return static_cast<t&>(*this); } 00083 const t& to_current() const { return static_cast<const t&>(*this); } 00084 t& to_image() { return static_cast<t&>(*this); } 00085 const t& to_image() const { return static_cast<const t&>(*this); } 00086 00087 typedef typename types::derive<t>::type derived_type; 00088 00089 t& derived() { return static_cast<derived_type&>(to_image()); } 00090 const t& derived() const 00091 { return static_cast<const derived_type&>(to_image()); } 00092 00094 array_common_base() { } 00095 00097 array_common_base(array_common_base& o) : base_class(o) { } 00098 00100 array_common_base(all_init_arg y) : base_class(y) { } 00101 00103 template <class S> 00104 array_common_base(const array<size_t, S>& sz) : base_class(sz) { } 00105 00107 template <class S> 00108 array_common_base(const array<size_t, S>& sz, const T* x) 00109 : base_class(sz, x) { } 00110 00112 template <class S> 00113 array_common_base(const array<size_t, S>& sz, const T& x) 00114 : base_class(sz, x) { } 00115 00117 template <class S> 00118 array_common_base(const array<size_t, S>& sz, const data_init_arg &y) 00119 : base_class(sz, y) { } 00120 00122 template <class S, class J, class D> 00123 array_common_base(const array<size_t, S>& sz, const array<J, D>& a) 00124 : base_class(sz, a) { } 00125 00127 template <class J, class D> 00128 array_common_base(const array_nd<J, D>& x) : base_class(x) { } 00129 00131 template <class J, class D> 00132 array_common_base(array_nd<J, D>& x) : base_class(x) { } 00133 00134 //propagation of operator = 00135 using base_class::operator=; 00136 array_common_base& operator=(const array_common_base& a) 00137 { 00138 base_class::operator=(a); 00139 return *this; 00140 } 00141 00142 using prv_common::operator-; 00143 using prv_common::operator+; 00144 using prv_common::operator|; 00145 using prv_common::operator~; 00146 using prv_common::operator!; 00147 using prv_common::operator*; 00148 using prv_common::operator->*; 00149 00150 }; 00151 00152 } /* namespace ivl */ 00153 00154 #endif // IVL_IMAGE_DETAILS_IMAGE_COMMON_BASE_HPP