Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* oln/core/tags.hh: The abstract entry point is a big switch which
must now inherits an image dimension.
* oln/fancy/print.hh: Use abstraction for image with dimension
(image_with_dim in Olena).
* oln/fancy/iota.hh: Likewise.
* oln/makefile.src: Add image_dimension.hh.
* oln/core/abstract/image_dimension.hh: New.
* oln/core/1d/image1d.hh: Add a property for dimension.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
core/1d/image1d.hh | 1
core/2d/image2d.hh | 1
core/3d/image3d.hh | 1
core/abstract/image_dimension.hh | 58 +++++++++++++++++++++++++++++++++++++++
core/tags.hh | 22 ++++++++++++--
fancy/iota.hh | 12 ++++----
fancy/print.hh | 32 ++++++++++-----------
makefile.src | 1
8 files changed, 103 insertions(+), 25 deletions(-)
Index: oln/fancy/print.hh
--- oln/fancy/print.hh (revision 15)
+++ oln/fancy/print.hh (working copy)
@@ -22,13 +22,12 @@
namespace impl {
- template <typename T>
- void print(const image1d<T>& input, std::ostream& ostr);
- template <typename T>
- void print(const image2d<T>& input, std::ostream& ostr);
- template <typename T>
- void print(const image3d<T>& input, std::ostream& ostr);
- // FIXME: it should be abstract::image2d<I>...
+ template <typename E>
+ void print(const abstract::image1d<E>& input, std::ostream& ostr);
+ template <typename E>
+ void print(const abstract::image2d<E>& input, std::ostream& ostr);
+ template <typename E>
+ void print(const abstract::image3d<E>& input, std::ostream& ostr);
} // end of namespace impl
@@ -73,31 +72,31 @@
}
- template <typename T>
- void print(const image1d<T>& input, std::ostream& ostr)
+ template <typename E>
+ void print(const abstract::image1d<E>& input, std::ostream& ostr)
{
// FIXME: lacks cleaning
for (coord_t index = 0; index < input.size().nindices(); ++index)
{
- ostr << internal::pp<T>(input[point1d(index)]) << ' ';
+ ostr << internal::pp<oln_value_type(E)>(input[point1d(index)]) <<
' ';
}
ostr << std::endl;
}
- template <typename T>
- void print(const image2d<T>& input, std::ostream& ostr)
+ template <typename E>
+ void print(const abstract::image2d<E>& input, std::ostream& ostr)
{
// FIXME: lacks cleaning
for (coord_t row = 0; row < input.size().nrows(); ++row)
{
for (coord_t col = 0; col < input.size().ncols(); ++col)
- ostr << internal::pp<T>(input[point2d(row,col)]) << '
';
+ ostr << internal::pp<oln_value_type(E)>(input[point2d(row,col)])
<< ' ';
ostr << std::endl;
}
}
- template <typename T>
- void print(const image3d<T>& input, std::ostream& ostr)
+ template <typename E>
+ void print(const abstract::image3d<E>& input, std::ostream& ostr)
{
// FIXME: lacks cleaning
for (coord_t slice = 0; slice < input.size().nslices(); ++slice)
@@ -105,7 +104,8 @@
for (coord_t row = 0; row < input.size().nrows(); ++row)
{
for (coord_t col = 0; col < input.size().ncols(); ++col)
- ostr << internal::pp<T>(input[point3d(slice,row,col)]) << '
';
+ ostr << internal::pp<oln_value_type(E)>(input[point3d(slice,row,col)])
+ << ' ';
ostr << ", ";
}
ostr << std::endl;
Index: oln/fancy/iota.hh
--- oln/fancy/iota.hh (revision 15)
+++ oln/fancy/iota.hh (working copy)
@@ -12,11 +12,11 @@
namespace impl {
template <typename T>
- void iota(image1d<T>& inout); // FIXME: abstract::image1d<I>...
+ void iota(abstract::image1d<T>& inout);
template <typename T>
- void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>...
+ void iota(abstract::image2d<T>& inout);
template <typename T>
- void iota(image3d<T>& inout); // FIXME: abstract::image2d<I>...
+ void iota(abstract::image3d<T>& inout);
} // end of namespace impl
@@ -39,7 +39,7 @@
// iterators and we just want to test.
template <typename T>
- void iota(image2d<T>& inout)
+ void iota(abstract::image2d<T>& inout)
{
unsigned counter = 0;
// FIXME: lacks cleaning
@@ -49,7 +49,7 @@
}
template <typename T>
- void iota(image1d<T>& inout)
+ void iota(abstract::image1d<T>& inout)
{
unsigned counter = 0;
// FIXME: lacks cleaning
@@ -58,7 +58,7 @@
}
template <typename T>
- void iota(image3d<T>& inout)
+ void iota(abstract::image3d<T>& inout)
{
unsigned counter = 0;
// FIXME: lacks cleaning
Index: oln/makefile.src
--- oln/makefile.src (revision 15)
+++ oln/makefile.src (working copy)
@@ -26,6 +26,7 @@
core/abstract/data_storage.hh \
core/abstract/image.hh \
core/abstract/image_constness.hh \
+ core/abstract/image_dimension.hh \
core/abstract/image_with_data.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
Index: oln/core/abstract/image_dimension.hh
--- oln/core/abstract/image_dimension.hh (revision 0)
+++ oln/core/abstract/image_dimension.hh (revision 0)
@@ -0,0 +1,58 @@
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
+
+# include <oln/core/abstract/image.hh>
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+ /*! \namespace oln::abstract
+ ** \brief oln::abstract namespace.
+ */
+ namespace abstract {
+
+ /*! \class abstract::image2d<E>
+ **
+ ** Class of 1d images.
+ */
+
+
+ template <typename E>
+ struct image1d : public virtual image<E>
+ {
+ protected:
+
+ /*! \brief Constructor (protected, empty).
+ */
+ image1d() {}
+ };
+
+ template <typename E>
+ struct image2d : public virtual image<E>
+ {
+ protected:
+
+ /*! \brief Constructor (protected, empty).
+ */
+ image2d() {}
+ };
+
+ template <typename E>
+ struct image3d : public virtual image<E>
+ {
+ protected:
+
+ /*! \brief Constructor (protected, empty).
+ */
+ image3d() {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 15)
+++ oln/core/1d/image1d.hh (working copy)
@@ -47,6 +47,7 @@
// tags
typedef tag::readwrite constness_tag;
+ typedef tag::dimension1 dimension_tag;
// functions
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 15)
+++ oln/core/2d/image2d.hh (working copy)
@@ -48,6 +48,7 @@
// tags
typedef tag::readwrite constness_tag;
+ typedef tag::dimension2 dimension_tag;
// functions
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 15)
+++ oln/core/3d/image3d.hh (working copy)
@@ -48,6 +48,7 @@
// tags
typedef tag::readwrite constness_tag;
+ typedef tag::dimension3 dimension_tag;
// functions
Index: oln/core/tags.hh
--- oln/core/tags.hh (revision 15)
+++ oln/core/tags.hh (working copy)
@@ -2,6 +2,7 @@
# define OLENA_CORE_TAGS_HH
# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
#define oln_tag_decl(TAG) \
\
@@ -60,6 +61,10 @@
oln_tag_decl_case( constness, readonly, abstract::readonly_image )
oln_tag_decl_case( constness, readwrite, abstract::readwrite_image )
+ oln_tag_decl ( dimension );
+ oln_tag_decl_case( dimension, dimension1, abstract::image1d)
+ oln_tag_decl_case( dimension, dimension2, abstract::image2d)
+ oln_tag_decl_case( dimension, dimension3, abstract::image3d)
namespace internal {
@@ -70,8 +75,17 @@
// test if ret derives from constness_tag
};
+ template <typename E>
+ struct retrieve < tag::dimension, E >
+ {
+ typedef typename props<cat::image,E>::dimension_tag ret; // FIXME: ok?
+ // test if ret derives from constness_tag
+ };
+
+
template <typename TAG, typename E>
- struct image_switch : public image_case< typename retrieve<TAG,E>::ret,
E>
+ struct image_switch :
+ public image_case< typename retrieve<TAG,E>::ret, E>
{
protected:
image_switch() {}
@@ -86,8 +100,10 @@
namespace abstract {
template <typename E>
- struct image_entry : public tag::internal::image_switch < tag::constness, E >
- // ...
+ struct image_entry :
+ public tag::internal::image_switch < tag::constness, E >,
+ public tag::internal::image_switch < tag::dimension, E >
+ // ...
{
protected:
image_entry() {}