481: Fix a duplicate where-clause and perform some aesthetic changes in image abstractions.

https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix a duplicate where-clause and perform some aesthetic changes in image abstractions. * oln/core/abstract/image_dimension.hh: Move the static switch statement before the cases. Aesthetic changes. * olena/oln/core/abstract/image_typeness.hh: Likewise. (case_<value_type_tag, value_type, 2>): Fix a copy-and-paste bug: remove a duplicate `unsigned char' type in the where-clause and replace it with `signed char'. * oln/core/abstract/image_typeness_integre.hh, * tests/image_entry.cc: Aesthetic changes. oln/core/abstract/image_dimension.hh | 58 +++++++++++++++++++--------- oln/core/abstract/image_typeness.hh | 58 ++++++++++++++++++---------- oln/core/abstract/image_typeness_integre.hh | 7 +-- tests/image_entry.cc | 4 - 4 files changed, 84 insertions(+), 43 deletions(-) Index: tests/image_entry.cc --- tests/image_entry.cc (revision 480) +++ tests/image_entry.cc (working copy) @@ -28,7 +28,7 @@ /// Test oln::abstract::image_entry. // FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to -// stress image_typeness.hh. This should be done in another test, of +// stress image_typeness.hh. This might be done in another test, of // course. #include <oln/core/1d/grid1d.hh> @@ -64,7 +64,7 @@ namespace my { - // A very simple 1D image. + // A very simple 1-D image. class image : public oln::set_super_type<my::image>::ret { typedef image self_type; Index: oln/core/abstract/image_dimension.hh --- oln/core/abstract/image_dimension.hh (revision 480) +++ oln/core/abstract/image_dimension.hh (working copy) @@ -65,13 +65,17 @@ */ +/*-------------------------. +| Dimension abstractions. | +`-------------------------*/ + namespace oln { namespace abstract { - /// Class of 1D images. + /// Class of 1-D images. template <typename E> struct image1d : public virtual image<E> { @@ -80,7 +84,7 @@ image1d() {} }; - /// Class of 2D images. + /// Class of 2-D images. template <typename E> struct image2d : public virtual image<E> { @@ -89,7 +93,7 @@ image2d() {} }; - /// Class of 3d images. + /// Class of 3-D images. template <typename E> struct image3d : public virtual image<E> { @@ -100,21 +104,45 @@ } // end of namespace oln::abstract +} // end of namespace oln + /*-------------------. | Dimension switch. | `-------------------*/ +namespace oln +{ + /// Case tag for the dimension. + struct grid_dim_tag; +} + + +// Register the dimension switch for oln::abstract::image_entry. +namespace stc +{ + template <typename I> + struct set_entry_node<I, oln::abstract::dimension_tag> : + public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret + ::template instantiated_with<I>::ret + { + }; +} // end of namespace stc + + +namespace oln +{ + // Forward declarations. class grid1d; class grid2d; class grid3d; - /// Case tag for the dimension. - struct grid_dim_tag; /// Switch on on the grid dimension. /// \{ + + /// 1-D case. template <typename grid_type> struct case_<grid_dim_tag, grid_type, 1> : // Test. @@ -124,6 +152,7 @@ typedef stc::abstraction_as_type<abstract::image1d> ret; }; + /// 2-D case. template <typename grid_type> struct case_<grid_dim_tag, grid_type, 2> : // Test. @@ -133,6 +162,7 @@ typedef stc::abstraction_as_type<abstract::image2d> ret; }; + /// 3-D case. template <typename grid_type> struct case_<grid_dim_tag, grid_type, 3> : // Test. @@ -142,7 +172,7 @@ typedef stc::abstraction_as_type<abstract::image3d> ret; }; - /// Abort when grid_type is not handled by the previous cases. + /// Default case: abort when grid_type is not handled by the previous cases. template <typename grid_type> struct default_case_<grid_dim_tag, grid_type> { @@ -153,19 +183,11 @@ } // end of namespace oln -// Register the dimension switch for oln::abstract::image_entry. -namespace stc -{ - template <typename I> - struct set_entry_node<I, oln::abstract::dimension_tag> : - public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret - ::template instantiated_with<I>::ret - { - }; -} // end of namespace stc - +/*----------------------------------. +| Dimension external virtual type. | +`----------------------------------*/ -// FIXME: Is this external property really useful? +// FIXME: Is this external vtype really useful? namespace oln { /// Image dimension type as an external vtype of abstract::image. Index: oln/core/abstract/image_typeness_integre.hh --- oln/core/abstract/image_typeness_integre.hh (revision 480) +++ oln/core/abstract/image_typeness_integre.hh (working copy) @@ -77,11 +77,12 @@ } // end of namespace ntg +/*--------------------------. +| Typeness switch (cont.). | +`--------------------------*/ + namespace oln { - /*--------------------. - | Value type switch. | - `--------------------*/ /// Switch on on the value type. /// \{ Index: oln/core/abstract/image_typeness.hh --- oln/core/abstract/image_typeness.hh (revision 480) +++ oln/core/abstract/image_typeness.hh (working copy) @@ -68,7 +68,12 @@ */ -namespace oln { +/*------------------------. +| Typeness abstractions. | +`------------------------*/ + +namespace oln +{ namespace abstract { @@ -142,9 +147,9 @@ }; - /*---------------------. - | Conjunctions types. | - `---------------------*/ + // -------------------- // + // Conjunctions types. // + // -------------------- // namespace internal { @@ -204,13 +209,34 @@ } // end of namespace oln::abstract +} // end of namespace oln + - /*--------------------. - | Value type switch. | - `--------------------*/ +/*------------------. +| Typeness switch. | +`------------------*/ +namespace oln +{ /// Case tag for the dimension. struct value_type_tag; +} + + +// Register the dimension switch/case for oln::abstract::image_entry. +namespace stc +{ + template <typename I> + struct set_entry_node<I, oln::abstract::typeness_tag> : + public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret + ::super_type::template instantiated_with<I>::ret + { + }; +} // end of namespace stc + + +namespace oln +{ /// Switch on on the grid dimension. /// \{ @@ -236,7 +262,7 @@ struct case_<value_type_tag, value_type, 2> : public mlc::where_< mlc::or_list_< mlc_eq(value_type, char), - mlc_eq(value_type, unsigned char), + mlc_eq(value_type, signed char), mlc_eq(value_type, unsigned char) > > { // Definition of the super class corresponding to this case @@ -273,19 +299,11 @@ } // end of namespace oln -// Register the dimension switch/case for oln::abstract::image_entry. -namespace stc -{ - template <typename I> - struct set_entry_node<I, oln::abstract::typeness_tag> : - public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret - ::super_type::template instantiated_with<I>::ret - { - }; -} // end of namespace stc - +/*---------------------------------. +| Typeness external virtual type. | +`---------------------------------*/ -// FIXME: Is this external property really useful? +// FIXME: Is this external vtype really useful? namespace oln { /// Image ``typeness'' as an external vtype of abstract::image.
participants (1)
-
Roland Levillain