image.hh

00001 // Copyright (C) 2001, 2002, 2003, 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_CORE_IMAGE_HH
00029 # define OLENA_CORE_IMAGE_HH
00030 
00031 # include <mlc/type.hh>
00032 # include <ntg/basics.hh>
00033 # include <oln/core/abstract/image_with_impl.hh>
00034 # include <oln/core/abstract/iter.hh>
00035 
00036 # include <sstream>
00037 
00038 
00039 namespace oln {
00040 
00041   template<unsigned Dim, class T, class Impl, class Exact = mlc::final>
00042   class image; //fwd_decl
00043 
00050   template<unsigned Dim, class T, class Impl, class Exact>
00051   struct image_id<image<Dim, T, Impl, Exact> >
00052   {
00053     enum{dim = Dim};
00054     typedef T value_type;
00055     typedef Impl impl_type;
00056     typedef typename mlc::exact_vt<image<Dim, T, Impl, Exact>, Exact>::ret exact_type;
00057   };
00058 
00065   template<unsigned Dim, class T, class Impl, class Exact>
00066   struct image_traits<image<Dim, T, Impl, Exact> >:
00067     public image_traits<abstract::image_with_impl<typename image_id<image<Dim, T, Impl, Exact> >::impl_type,
00068                                                   typename image_id<image<Dim, T, Impl, Exact> >::exact_type> >
00069   {
00070 
00071   };
00072   
00073   // image
00074   
00075   
00082   template<unsigned Dim, class T, class Impl, class Exact>
00083   class image:
00084     public abstract::image_with_impl<typename image_id<image<Dim, T, Impl, Exact> >::impl_type,
00085                                      typename image_id<image<Dim, T, Impl, Exact> >::exact_type>
00086   {
00087     
00088     
00089   public:
00090 
00091     typedef typename mlc::exact_vt<image<Dim, T, Impl, Exact>, Exact>::ret exact_type; 
00092     typedef typename image_traits<exact_type>::point_type point_type; 
00098     typedef typename image_traits<exact_type>::dpoint_type dpoint_type; 
00104     typedef typename image_traits<exact_type>::iter_type iter_type; 
00110     typedef typename image_traits<exact_type>::fwd_iter_type fwd_iter_type; 
00112     typedef typename image_traits<exact_type>::bkd_iter_type bkd_iter_type;
00114     typedef typename image_traits<exact_type>::value_type value_type; 
00118     typedef typename image_traits<exact_type>::size_type size_type;
00120     typedef typename image_traits<exact_type>::impl_type impl_type; 
00123     typedef image<Dim, T, Impl, Exact> self_type;
00124     typedef typename abstract::image_with_impl<Impl,
00125                                                exact_type> super_type;
00126 
00127     image() : super_type()
00128     {
00129       mlc_init_static_hierarchy(Exact);
00130     }
00131 
00139     image(self_type& rhs): super_type(rhs)
00140     {
00141       mlc_init_static_hierarchy(Exact);
00142     }
00143 
00144     static std::string
00145     name()
00146     {
00147       std::ostringstream s;
00148       s << "image<" << Dim << ", " << ntg_name(T) << ", " << Impl::name()
00149         << ", " << Exact::name() << ">";
00150       return s.str();
00151     }
00152 
00154 
00155     image(impl_type* i) : super_type(i)
00156     {
00157       mlc_init_static_hierarchy(Exact);
00158     }
00159 
00161     
00162     image(const size_type& size) :
00163       super_type(new impl_type(size))
00164     {
00165       mlc_init_static_hierarchy(Exact);
00166     }
00167 
00168   };
00169 
00176   template<class I, class T = typename mlc::exact<I>::ret::value_type>
00177   struct mute
00178   {
00179     typedef typename mlc::exact<I>::ret::template mute<T>::ret ret;
00180   };
00181 
00182   //define img_type equal to the image of dim Dim
00183 
00190   template <unsigned Dim, class T, class Exact = mlc::final>
00191   struct dim_traits
00192   {
00193   };
00194 } // end of oln
00195 
00196 #endif // ! OLENA_CORE_IMAGE_HH

Generated on Thu Apr 15 20:13:11 2004 for Olena by doxygen 1.3.6-20040222