https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update image concepts and add single_value_image.
* core/abstract/image.hh: Rename as...
* core/concept/image.hh: ...this.
Update.
Add some code from files in core/abstract/image/.
* core/image_entry.hh: Rename as...
* core/internal/image_base.hh: ...this.
Update.
Add some code from files in core/internal/.
* core/gen/image_pset_piter.hh,
* core/gen/single_value_image.hh,
* core/internal/utils.hh,
* core/internal/image_selectors.hh: New.
* core/topology_entry.hh: Remove this residue.
* core/concept/point_set.hh (has): Fix typo.
* core/concept/point.hh (oln/core/concept/operators):
Include.
* core/equipment.hh: Update.
* stc/scoop.hxx (internal::top): Rename as...
(internal::top__): ...this to disambiguate.
core/concept/image.hh | 498 +++++++++++++++++++++++++++++----------
core/concept/point.hh | 1
core/concept/point_set.hh | 3
core/equipment.hh | 23 +
core/gen/image_pset_piter.hh | 252 +++++++++++++++++++
core/gen/single_value_image.hh | 162 ++++++++++++
core/internal/image_base.hh | 297 +++++++++++++++++++----
core/internal/image_selectors.hh | 70 +++++
core/internal/utils.hh | 74 +++++
stc/scoop.hxx | 14 -
10 files changed, 1222 insertions(+), 172 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 845)
+++ oln/core/concept/image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,197 +26,461 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_IMAGE_HH
-# define OLN_CORE_ABSTRACT_IMAGE_HH
+#ifndef OLN_CORE_CONCEPT_IMAGE_HH
+# define OLN_CORE_CONCEPT_IMAGE_HH
-# include <cstddef>
-
-# include <oln/core/typedefs.hh>
-# include <oln/core/abstract/fwd_decls.hh>
-# include <oln/core/automatic/image/image.hh>
-# include <oln/debug/track.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- // Fwd decl.
- static unsigned& current_image_id();
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ struct Image : public virtual Any<Exact>,
+ public automatic::get_impl<Image, Exact>
+ {
+ stc_typename(grid);
+
+ stc_typename(point);
+ stc_typename(psite);
+
+ stc_typename(value);
+ stc_typename(rvalue);
+
+ stc_typename(piter);
+ stc_typename(fwd_piter);
+ stc_typename(bkd_piter);
+
+ stc_typename(box);
+ stc_typename(pset);
+
+ bool owns_(const psite& p) const;
+ rvalue operator()(const psite& p) const;
+
+ box bbox() const;
+ pset points() const;
+
+ protected:
+ Image();
+ };
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ struct Image_with_Nbh : public virtual Image<Exact>,
+ public automatic::get_impl<Image_with_Nbh, Exact>
+ {
+ stc_typename(nbh);
+ nbh nbhood() const;
+
+ protected:
+ Image_with_Nbh();
+ };
+
+ /// Concept-class "Mutable_Image".
+ template <typename Exact>
+ struct Mutable_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Mutable_Image, Exact>
+ {
+ stc_using_from(Image, psite);
+ using Image<Exact>::operator();
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
+ stc_typename(lvalue);
+ lvalue operator()(const psite& p);
+
+ protected:
+ Mutable_Image();
+ };
- /*! \class abstract::image<E>
- **
- ** The abstract::image class is the base class from whom derives
- ** every concrete image class. Basically, an image is a set of
- ** points and a set of values associated with those points.
- **
- ** Parameter E is the exact type of image.
- */
+ /// Concept-class "Point_Wise_Accessible_Image".
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
+ {
+ stc_using_from(Image, point);
+
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
+ bool has(const point& p) const;
- template <typename E>
- struct image : public virtual stc::any__simple<E>,
- public virtual oln::type,
- public automatic::get_impl<image, E>
+ protected:
+ Point_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Random_Accessible_Image".
+
+ template <typename Exact>
+ struct Random_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Random_Accessible_Image, Exact>
{
+ stc_using_from(Image, rvalue);
+
+ stc_typename(index);
+ rvalue operator[](index i) const;
+
+ protected:
+ Random_Accessible_Image();
+ };
+
- public:
+ /// Concept-class "Random_Mutable_Image".
- struct decl
+ template <typename Exact>
+ struct Random_Mutable_Image : public virtual Random_Accessible_Image<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Random_Mutable_Image, Exact>
+ {
+ stc_using_from(Random_Accessible_Image, index);
+ stc_using_from(Mutable_Image, lvalue);
+ using Random_Accessible_Image<Exact>::operator[];
+
+ lvalue operator[](index i);
+
+ protected:
+ Random_Mutable_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Value_Wise_Accessible_Image, Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(rvaluep);
+ rvaluep value(const vsite& v) const;
+
+ protected:
+ Value_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Mutable_Image : public virtual
Value_Wise_Accessible_Image<Exact>,
+ public automatic::get_impl<Value_Wise_Mutable_Image, Exact>
{
- oln_virtual_typedef(topo);
- oln_virtual_typedef(grid);
- oln_virtual_typedef(coord);
- oln_virtual_typedef(psite);
- oln_virtual_typedef(point);
+ stc_using_from(Value_Wise_Accessible_Image, vsite);
+ using Value_Wise_Accessible_Image<Exact>::value;
+
+ stc_typename(lvaluep);
+ lvaluep value(const vsite& v);
+
+ protected:
+ Value_Wise_Mutable_Image();
+ };
- // FIXME: Rec?
- oln_virtual_typedef(fwd_piter);
- oln_virtual_typedef(bkd_piter);
- oln_virtual_typedef(is_computed);
- oln_virtual_typedef(value);
- oln_virtual_typedef(rvalue);
+ /// Concept-class "Image_1D".
- oln_virtual_typedef(morpher);
+ template <typename Exact>
+ struct Image_1D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_1D, Exact>
+ {
+ stc_typename(coord);
- decl();
+ protected:
+ Image_1D();
};
- public:
- /*------------------*
- ! abstract methods !
- *------------------*/
+ /// Concept-class "Image_2D".
- /*! \brief Return the topological information about the current
- ** image. Nota bene: this method is abstract-like.it is a
- ** pseudo-abstract method.
- **
- ** \return An object deriving from abstract::topo. Ex: if the
- ** image is an image2d<something>, the returned object is a
- ** topo2d.
- */
+ template <typename Exact>
+ struct Image_2D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_2D, Exact>
+ {
+ stc_typename(coord);
- const oln_topo(E)& topo() const;
+ protected:
+ Image_2D();
+ };
- /*! \brief Gives access to the value stored at \a p in the
- ** current image.
- */
+ /// Concept-class "Image_3D".
- oln_rvalue(E) operator()(const oln_psite(E)& p) const;
+ template <typename Exact>
+ struct Image_3D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_3D, Exact>
+ {
+ stc_typename(coord);
+
+ protected:
+ Image_3D();
+ };
- unsigned id() const;
+
+ /// Concept-class "Point_Wise_Accessible_Image_2D".
+
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image_2D : public virtual
Point_Wise_Accessible_Image<Exact>,
+ public virtual Image_2D<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image, point);
+ stc_using_from(Point_Wise_Accessible_Image, rvalue);
+ stc_using_from(Image_2D, coord);
+
+ bool has_at(coord row, coord col) const;
+ rvalue at(coord row, coord col) const;
+
+ // default
+ bool impl_has_at(coord row, coord col) const;
+ rvalue impl_at(coord row, coord col) const;
protected:
+ Point_Wise_Accessible_Image_2D();
+ };
+
- /*! \brief Constructors (protected).
- */
- image();
- image(const image& rhs);
+ /// Concept-class "Point_Wise_Mutable_Image_2D".
- /*! \brief Assignment (protected).
- */
- E& operator=(const image& rhs);
+ template <typename Exact>
+ struct Point_Wise_Mutable_Image_2D : public virtual
Point_Wise_Accessible_Image_2D<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Point_Wise_Mutable_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image_2D, point);
+ stc_using_from(Point_Wise_Accessible_Image_2D, coord);
+ stc_using_from(Mutable_Image, lvalue);
+ using Point_Wise_Accessible_Image_2D<Exact>::at;
- /*! \brief Destructor.
- */
- virtual ~image();
+ lvalue at(coord row, coord col);
- private:
+ // default
+ lvalue impl_at(coord row, coord col);
- unsigned id_;
+ protected:
+ Point_Wise_Mutable_Image_2D();
};
+
+
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image<E>::decl::decl()
+ // ----------------------------------- Image<Exact>
+
+ template <typename Exact>
+ bool
+ Image<Exact>::owns_(const typename Image<Exact>::psite& p) const
{
- // FIXME: Rec?
- mlc::assert_< mlc_is_a(topo, abstract::topology) >::check();
- mlc::assert_< mlc_is_a(grid, abstract::grid) >::check();
- mlc::assert_< mlc_is_a(point, abstract::point) >::check();
- mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check();
- mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check();
+ return exact(this)->impl_owns_(p);
+ }
- // FIXME: Rec?
- // mlc::assert_< mlc_is_a(plain, abstract::image) >::check();
+ template <typename Exact>
+ typename Image<Exact>::rvalue
+ Image<Exact>::operator()(const typename Image<Exact>::psite& p) const
+ {
+ precondition(this->owns_(p));
+ return exact(this)->impl_read(p);
}
- template <typename E>
- image<E>::image()
- : id_(++current_image_id())
+ template <typename Exact>
+ typename Image<Exact>::box
+ Image<Exact>::bbox() const
{
- ++debug::n_images;
+ return exact(this)->impl_bbox();
}
- template <typename E>
- image<E>::image(const image& rhs)
- : id_(rhs.id_)
+ template <typename Exact>
+ typename Image<Exact>::pset
+ Image<Exact>::points() const
{
- ++debug::n_images;
+ return exact(this)->impl_points();
}
- template <typename E>
- E& image<E>::operator=(const image<E>& rhs)
+ template <typename Exact>
+ Image<Exact>::Image()
{
- this->id_ = rhs.id_;
- return this->exact();
}
- template <typename E>
- image<E>::~image()
+ // ----------------------------------- Image_with_Nbh<Exact>
+
+ template <typename Exact>
+ typename Image_with_Nbh<Exact>::nbh
+ Image_with_Nbh<Exact>::nbhood() const
{
- decl();
- --debug::n_images;
+ return exact(this)->impl_nbhood();
}
- template <typename E>
- unsigned
- image<E>::id() const
+ template <typename Exact>
+ Image_with_Nbh<Exact>::Image_with_Nbh()
{
- return id_;
}
- template <typename E>
- const oln_topo(E)&
- image<E>::topo() const
+ // ----------------------------------- Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Mutable_Image<Exact>::lvalue
+ Mutable_Image<Exact>::operator()(const typename
Mutable_Image<Exact>::psite& p)
{
- return this->exact().impl_topo();
+ precondition(this->owns_(p));
+ return exact(this)->impl_read_write(p);
}
- template <typename E>
- oln_rvalue(E)
- image<E>::operator()(const oln_psite(E)& p) const
+ template <typename Exact>
+ Mutable_Image<Exact>::Mutable_Image()
{
- return this->exact().impl_op_read(p);
}
-# endif
+ // ----------------------------------- Point_Wise_Accessible_Image<Exact>
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image<Exact>::has(const typename
Point_Wise_Accessible_Image<Exact>::point& p) const
+ {
+ return exact(this)->impl_has(p);
+ }
+ template <typename Exact>
+ Point_Wise_Accessible_Image<Exact>::Point_Wise_Accessible_Image()
+ {
+ }
- } // end of namespace oln::abstract
+ // ----------------------------------- Random_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Random_Accessible_Image<Exact>::rvalue
+ Random_Accessible_Image<Exact>::operator[](typename
Random_Accessible_Image<Exact>::index i) const
+ {
+ return exact(this)->impl_index_read(p);
+ }
+ template <typename Exact>
+ Random_Accessible_Image<Exact>::Random_Accessible_Image()
+ {
+ }
+ // ----------------------------------- Random_Mutable_Image<Exact>
-# ifndef OLN_INCLUDE_ONLY
+ template <typename Exact>
+ typename Random_Mutable_Image<Exact>::lvalue
+ Random_Mutable_Image<Exact>::operator[](typename
Random_Accessible_Image<Exact>::index i)
+ {
+ return exact(this)->impl_index_read_write(p);
+ }
+
+ template <typename Exact>
+ Random_Mutable_Image<Exact>::Random_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Accessible_Image<Exact>::rvaluep
+ Value_Wise_Accessible_Image<Exact>::value(const typename
Value_Wise_Accessible_Image<Exact>::vsite& v) const
+ {
+ return exact(this)->impl_value_read(v);
+ }
+
+ template <typename Exact>
+ Value_Wise_Accessible_Image<Exact>::Value_Wise_Accessible_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Mutable_Image<Exact>::lvaluep
+ Value_Wise_Mutable_Image<Exact>::value(const typename
Value_Wise_Accessible_Image<Exact>::vsite& v)
+ {
+ return exact(this)->impl_value_read_write(p);
+ }
+
+ template <typename Exact>
+ Value_Wise_Mutable_Image<Exact>::Value_Wise_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Image_1D<Exact>
+
+ template <typename Exact>
+ Image_1D<Exact>::Image_1D()
+ {
+ }
+
+ // ----------------------------------- Image_2D<Exact>
+
+ template <typename Exact>
+ Image_2D<Exact>::Image_2D()
+ {
+ }
+
+ // ----------------------------------- Image_3D<Exact>
+
+ template <typename Exact>
+ Image_3D<Exact>::Image_3D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Accessible_Image_2D<Exact>
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::has_at(coord row, coord col) const
+ {
+ return exact(this)->impl_has_at(row, col);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::at(coord row, coord col) const
+ {
+ return exact(this)->impl_at(row, col);
+ }
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::impl_has_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->has(p);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
+ }
+
+ template <typename Exact>
+ Point_Wise_Accessible_Image_2D<Exact>::Point_Wise_Accessible_Image_2D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Mutable_Image_2D<Exact>
+
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::at(coord row, coord col)
+ {
+ return exact(this)->impl_at(row, col);
+ }
- static unsigned& current_image_id()
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
- static unsigned id_ = 0;
- return id_;
+ Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
}
# endif
@@ -225,4 +489,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_IMAGE_HH
+#endif // ! OLN_CORE_CONCEPT_IMAGE_HH
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 849)
+++ oln/core/concept/point_set.hh (working copy)
@@ -30,6 +30,7 @@
# include <ostream>
# include <oln/core/equipment.hh>
+# include <oln/core/point.hh>
namespace oln
@@ -77,7 +78,7 @@
bool
Point_Set<Exact>::has(const typename Point_Set<Exact>::point& p) const
{
- return exact(this)->impl_has();
+ return exact(this)->impl_has(p);
}
template <typename Exact>
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 849)
+++ oln/core/concept/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/value.hh>
# include <oln/core/equipment.hh>
+# include <oln/core/concept/operators.hh>
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 849)
+++ oln/core/equipment.hh (working copy)
@@ -40,35 +40,58 @@
# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
// b
+ stc_decl_associated_type( bkd_niter );
stc_decl_associated_type( bkd_piter );
+ stc_decl_associated_type( bkd_qiter );
stc_decl_associated_type( box );
+
// c
stc_decl_associated_type( coord );
+
// d
stc_decl_associated_type( data );
stc_decl_associated_type( dim );
stc_decl_associated_type( dpoint );
+
// f
+ stc_decl_associated_type( fwd_niter );
stc_decl_associated_type( fwd_piter );
+ stc_decl_associated_type( fwd_qiter );
+
// g
stc_decl_associated_type( grid );
+
// i
stc_decl_associated_type( index );
+
// l
stc_decl_associated_type( lvalue );
+ stc_decl_associated_type( lvaluep );
+
// n
stc_decl_associated_type( n );
+ stc_decl_associated_type( nbh );
+ stc_decl_associated_type( niter );
+
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
+
+ // q
+ stc_decl_associated_type( qiter );
+
// r
stc_decl_associated_type( rvalue );
+ stc_decl_associated_type( rvaluep );
+
// s
stc_decl_associated_type( std_container );
+
// v
stc_decl_associated_type( value );
+ stc_decl_associated_type( vsite );
} // end of namespace oln
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 0)
+++ oln/core/gen/single_value_image.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
+# define OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ template <typename Ps, typename T> class single_value_image;
+
+
+ /// Virtual types.
+ template <typename Ps, typename T>
+ struct vtypes< single_value_image<Ps, T> >
+ {
+ typedef typename Ps::point point;
+ typedef point psite;
+ typedef Ps pset;
+
+ typedef T value;
+ typedef const T& rvalue;
+
+ typedef internal::pair<Ps, T> data;
+
+ // FIXME: To be defined...
+ typedef mlc::none qiter;
+ typedef mlc::none fwd_qiter;
+ typedef mlc::none bkd_qiter;
+ };
+
+
+ /// Super type.
+ template <typename Ps, typename T>
+ struct super_trait_< single_value_image<Ps, T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+
+ /// Class for images defined by a point set and a single value.
+
+ template <typename Ps, typename T>
+ class single_value_image : public internal::image_base_< single_value_image<Ps,
T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::image_base_<current> super;
+ public:
+
+
+ stc_using(point);
+ stc_using(rvalue);
+ stc_using(data);
+
+ single_value_image();
+
+ single_value_image(const Ps& ps, const T& val);
+
+ bool impl_owns_(const point& p) const;
+ bool impl_has (const point& p) const;
+
+ rvalue impl_read(const point&) const;
+
+ const Ps& impl_points() const;
+
+ void change_value(const T& new_value);
+
+ }; // end of single_value_image<Ps, T>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image()
+ {
+ }
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image(const Ps& pts,
+ const T& val)
+ {
+ this->data_ = new data(pts, val);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_owns_(const typename single_value_image<Ps,
T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_has(const typename single_value_image<Ps,
T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ typename single_value_image<Ps, T>::rvalue
+ single_value_image<Ps, T>::impl_read(const typename single_value_image<Ps,
T>::point&) const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+ template <typename Ps, typename T>
+ const Ps&
+ single_value_image<Ps, T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename Ps, typename T>
+ void
+ single_value_image<Ps, T>::change_value(const T& new_value)
+ {
+ assert(this->has_data());
+ this->data_->value2 = new_value;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
Index: oln/core/gen/image_pset_piter.hh
--- oln/core/gen/image_pset_piter.hh (revision 0)
+++ oln/core/gen/image_pset_piter.hh (revision 0)
@@ -0,0 +1,252 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_IMAGE_PSET_PITER_HH
+# define OLN_CORE_GEN_IMAGE_PSET_PITER_HH
+
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ /// Fwd decls.
+
+ template <typename Ps> struct image_pset_fwd_piter_;
+ template <typename Ps> struct image_pset_bkd_piter_;
+
+
+ /// Super types.
+
+ template <typename Ps>
+ struct super_trait_< image_pset_fwd_piter_<Ps> >
+ {
+ typedef image_pset_fwd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename Ps>
+ struct super_trait_< image_pset_bkd_piter_<Ps> >
+ {
+ typedef image_pset_bkd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+ /// Virtual types.
+
+ template <typename Ps>
+ struct vtypes< image_pset_fwd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+ template <typename Ps>
+ struct vtypes< image_pset_bkd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+
+ /// Class image_pset_fwd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_fwd_piter_ : public Iterator_on_Points<
image_pset_fwd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_fwd_piter_();
+
+ template <typename I>
+ image_pset_fwd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::fwd_piter i_;
+ };
+
+
+ /// Class image_pset_bkd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_bkd_piter_ : public Iterator_on_Points<
image_pset_bkd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_bkd_piter_();
+
+ template <typename I>
+ image_pset_bkd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::bkd_piter i_;
+ };
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // -------------------- image_pset_fwd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_invalidate()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ bool image_pset_fwd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_fwd_piter_<Ps>::point
+ image_pset_fwd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_fwd_piter_<Ps>::point*
+ image_pset_fwd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+
+ // -------------------- image_pset_bkd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_invalidate()
+ {
+ i_.invalidate();
+ }
+
+ template <typename Ps>
+ bool image_pset_bkd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_bkd_piter_<Ps>::point
+ image_pset_bkd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_bkd_piter_<Ps>::point*
+ image_pset_bkd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_IMAGE_PSET_PITER_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 0)
+++ oln/core/internal/image_selectors.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+
+ // 1. mutability
+
+ typedef selector<Image, 1> Image_mutability;
+
+ template <typename Exact>
+ struct case_< Image_mutability, Exact, 1 > : where_<
stc_type_is_found(lvalue) >
+ {
+ typedef Mutable_Image<Exact> ret;
+ };
+
+
+ // 2. point-wise accessibility
+
+ typedef selector<Image, 2> Image_pw_accessibility;
+
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 1 > : where_< mlc::eq_<
stc_type(Exact, psite),
+ stc_type(Exact, point) > >
+ {
+ typedef Point_Wise_Accessible_Image<Exact> ret;
+ };
+
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 845)
+++ oln/core/internal/image_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,95 +25,298 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_IMAGE_ENTRY_HH
-# define OLN_CORE_IMAGE_ENTRY_HH
+#ifndef OLN_CORE_INTERNAL_IMAGE_BASE_HH
+# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
-# include <oln/core/abstract/entry.hh>
-# include <oln/core/abstract/image/all.hh>
-
-# include <oln/core/type_fun/plain.hh>
+# include <oln/core/internal/image_selectors.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/gen/box.hh>
+# include <oln/core/gen/image_pset_piter.hh>
namespace oln
{
- /// Fwd decl.
- template <typename E> struct image_entry;
+ /// Fwd decls.
+
+ namespace internal
+ {
+ template <typename Exact> struct image_base_;
+ template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct image_morpher_;
+ template <typename Exact> struct single_image_morpher_;
+ template <typename Exact> struct multiple_image_morpher_;
+ }
+
+
+ /// Super types.
+
+ template <typename Exact>
+ struct super_trait_< internal::image_base_<Exact> >
+ {
+ typedef top<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::primitive_image_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::image_morpher_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+ template <typename Exact>
+ struct super_trait_< internal::single_image_morpher_<Exact> >
+ {
+ typedef internal::image_morpher_<Exact> ret;
+ };
- template <typename E>
- struct set_super_type< image_entry<E> >
+ template <typename Exact>
+ struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
- typedef mlc::none ret;
+ typedef internal::image_morpher_<Exact> ret;
};
- /// Virtual types associated to image_entry<E>.
+ /// Virtual types.
- template <typename E>
- struct vtypes< image_entry<E> >
+ template <typename Exact>
+ struct vtypes< internal::image_base_<Exact> >
{
- typedef stc::abstract topo_type;
+ // Abstract.
+
+ typedef stc::abstract point;
+ typedef stc::abstract psite;
+ typedef stc::abstract pset;
+
+ typedef stc::abstract value;
+ typedef stc::abstract rvalue;
+
+ typedef stc::abstract data;
+
+ // Deferred.
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(pset) pset__;
+
+ // Final.
+
+ typedef stc::final< stc::is<Image> > category;
+ typedef stc::final< box_<point__> > box;
+ typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< typename pset__::fwd_piter > fwd_piter;
+ typedef stc::final< typename pset__::bkd_piter > bkd_piter;
+ typedef stc::final< fwd_piter > piter;
+
+ };
+
+
+ template <typename Exact>
+ struct vtypes< internal::primitive_image_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::image_morpher_<Exact> >
+ {
+ typedef stc::abstract delegatee;
+ typedef stc::not_delegated data;
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::single_image_morpher_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::multiple_image_morpher_<Exact> >
+ {
+ typedef stc::abstract n;
+ };
+
+
+
+ /// Implementation base classes.
+
+
+ namespace internal
+ {
+
+
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ class image_base_ : public top<Exact>
+ {
+ typedef top<Exact> super;
+ public:
+
+ stc_typename(data);
+
+ bool has_data() const;
+
+ protected:
+ image_base_();
+
+ tracked_ptr<data> data_;
+ };
- typedef stc::abstract point_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, grid)> grid_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, coord)> coord_type;
- typedef stc::abstract is_computed_type;
- typedef stc::abstract value_type;
+ /// primitive_image_<Exact>
- typedef stc::abstract fwd_piter_type;
- typedef stc::abstract bkd_piter_type;
+ template <typename Exact>
+ class primitive_image_ : public image_base_<Exact>
+ {
+ protected:
+ primitive_image_();
+ };
- // FIXME: final definitions:
- typedef oln_fwd_piter(E) piter_type;
- // FIXME: default definitions:
- typedef oln_point(E) psite_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_value(E) rvalue_type;
-# endif // !OLENA_USE_SCOOP_ALT
+ /// image_morpher_<Exact>
- /// \brief Morpher type.
- ///
- /// Optionally contains a tag indicating a kind of morpher.
- typedef mlc::none morpher_type;
+ template <typename Exact>
+ class image_morpher_ : public image_base_<Exact>
+ {
+ public:
+
+ stc_typename(delegatee);
+
+ protected:
+ image_morpher_();
};
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< image_entry<E>, typedef_::rvalue_type >
+
+ /// single_image_morpher_<Exact>
+
+ template <typename Exact>
+ class single_image_morpher_ : public image_morpher_<Exact>
{
- typedef oln_value(E) ret;
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+
+ // Abstract.
+ delegatee& image();
+ const delegatee& image() const;
+
+ protected:
+ single_image_morpher_();
};
-# endif // OLENA_USE_SCOOP_ALT
- /// Entry class for point sets: image_entry<E> is an alias for
- /// entry< abstract::image, E>.
+ /// multiple_image_morpher_<Exact>
- template <typename E>
- struct image_entry : public entry<abstract::image, E>
+ template <typename Exact>
+ class multiple_image_morpher_ : public image_morpher_<Exact>
{
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+ stc_typename(n);
+ enum { n_ = mlc_value(n) };
+
+ // Abstract.
+ delegatee& image(unsigned i = 0);
+ const delegatee& image(unsigned i = 0) const;
+
protected:
- image_entry();
+ multiple_image_morpher_();
};
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image_entry<E>::image_entry()
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ bool image_base_<Exact>::has_data() const
+ {
+ return this->data_ != 0;
+ }
+
+ template <typename Exact>
+ image_base_<Exact>::image_base_()
+ {
+ }
+
+ /// primitive_image_<Exact>
+
+ template <typename Exact>
+ primitive_image_<Exact>::primitive_image_()
{
}
+ // image_morpher_<Exact>
+
+ template <typename Exact>
+ image_morpher_<Exact>::image_morpher_()
+ {
+ }
+
+ // single_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image()
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ const typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image() const
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ single_image_morpher_<Exact>::single_image_morpher_()
+ {
+ }
+
+ // multiple_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i)
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ const typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i) const
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ multiple_image_morpher_<Exact>::multiple_image_morpher_()
+ {
+ }
+
+
# endif
+ } // end of namespace oln::internal
} // end of namespace oln
-#endif // ! OLN_CORE_IMAGE_ENTRY_HH
+#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 0)
+++ oln/core/internal/utils.hh (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_UTILS_HH
+# define OLN_CORE_INTERNAL_UTILS_HH
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ /// Simple singleton class.
+
+ template <typename T>
+ struct singleton
+ {
+ singleton()
+ {}
+ singleton(T val)
+ : value(val)
+ {}
+ T value;
+ };
+
+
+ /// Simple pair class.
+
+ template <typename T1, typename T2>
+ struct pair
+ {
+ pair()
+ {}
+ pair(T1 val1, T2 val2)
+ : value1(val1),
+ value2(val2)
+ {}
+ T1 value1;
+ T2 value2;
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_UTILS_HH
+
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 849)
+++ oln/stc/scoop.hxx (working copy)
@@ -867,22 +867,22 @@
};
template <typename abstraction, typename E>
- struct top;
+ struct top__;
template <template<class> class abstraction, typename E>
- struct top < stc::is<abstraction>, E > : public plug< abstraction, E
>
+ struct top__ < stc::is<abstraction>, E > : public plug< abstraction, E
>
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::none, E > : public Any<E>
+ struct top__ < mlc::none, E > : public Any<E>
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::not_found, E >; /* FIXME: Error msg here */
+ struct top__ < mlc::not_found, E >; /* FIXME: Error msg here */
} /* end of namespace internal */
@@ -900,7 +900,7 @@
};
template <typename E>
-struct top : public internal::top< stc_find_type(E, category), E >
+struct top : public internal::top__< stc_find_type(E, category), E >
{
protected:
top() {}