https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Polish the accesses to bbox_<point> as a virtual type.
* oln/core/gen/bbox.hh (oln::bbox_::self_t): Rename as...
(oln::bbox_::self_type): ...this.
Make it public.
(oln::bbox_::super_t): Adjust.
* oln/core/gen/topo_lbbox.hh
(vtypes< topo_lbbox_<point> >::bbox_type): Adjust.
* oln/core/gen/topo_bbox.hh (oln::vtypes< topo_lbbox_<point> >):
Define this virtul type using `bbox_<point>::self_t' instead of
just `bbox_<point>' to force the instiantiation of
oln::bbox_<point> at this point.
(oln::topo_bbox_<point>::bbox_t): Use oln_type_of to define it.
bbox.hh | 9 +++++++--
topo_bbox.hh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
topo_lbbox.hh | 2 +-
3 files changed, 62 insertions(+), 5 deletions(-)
Index: oln/core/gen/bbox.hh
--- oln/core/gen/bbox.hh (revision 647)
+++ oln/core/gen/bbox.hh (working copy)
@@ -72,8 +72,13 @@
class bbox_ : public point_set_entry< bbox_<point_t> >,
private mlc::assert_< mlc_is_a(point_t, abstract::point) >
{
- typedef bbox_<point_t> self_t;
- typedef point_set_entry<self_t> super_t;
+ // Make self_type public so that is can be used to define a
+ // virtual type of oln::topo_bbox_ and oln::topo_lbbox_.
+ public:
+ typedef bbox_<point_t> self_type;
+
+ private:
+ typedef point_set_entry<self_type> super_t;
typedef oln_type_of(point_t, coord) coord_t;
Index: oln/core/gen/topo_bbox.hh
--- oln/core/gen/topo_bbox.hh (revision 647)
+++ oln/core/gen/topo_bbox.hh (working copy)
@@ -52,7 +52,59 @@
template <typename point>
struct vtypes< topo_bbox_<point> >
{
- typedef bbox_<point> bbox_type;
+ /* Trick to force the instantiation of bbox_<point>.
+
+ As bbox_<point> is a template type used to define the `bbox'
+ virtual type of topo_bbox_<point>, it requires some attention
+ regarding its instantiation.
+
+
+ Metalic's mlc_is_a is used by the static hierarchy mechanism of
+ Static. mlc_is_a performs a static typedef introspection,
+ taking advantage of the SFINAE rule. However, there two
+ phenomena seem to happen here (probably due to the very nature
+ of SFINAE):
+
+ 1. the statement `mlc_is_a(B, A)' requires the knowledge of the
+ entire declaration of the inspected class to answer
+ positively if a `B' actually *is a* `A'. If B is a template
+ class, this implies that B must have been instantiated for
+ mlc_is_a to be able to inspect it;
+
+ 2. mlc_is_a does *not* trigger the instantiation of the
+ inspected type (probably to prevent any error, in accordance
+ to the SFINAE rule).
+
+ When a template type is used to define a virtual type, it
+ *must* have been instantiated, because it might be used during
+ the construction of the base classes of the class it belongs
+ to. That is the case of bbox_<point> here.
+
+ So, how one can trigger such an instantiation? We used to
+ address this problem by using explicit template instantiations
+ placed before the definition of the class holding the template
+ type used a virtual type :
+
+ template class bbox_<point1d>;
+ template class bbox_<point2d>;
+ template class bbox_<point3d>;
+
+ And so on. But this is not good w.r.t. software engineering:
+ one must take care of the correct explicit instantiations at
+ the right place, which is error-prone --and the C++ compiler
+ won't produces easily understandable messages!-- and requires a
+ manual addition for each instantiation of the template type
+ potentially used as a definition of a virtual type.
+
+ A better solution is to force the compiler to instantiate the
+ type at the definition site of the virtual type (here, as for
+ bbox_<point>). Such an instantiation can be triggered by
+ requesting the use of a typedef contained within this type. As
+ many template types define a typedef `self_t' to refer to
+ themselves, we use this typename to both trigger the
+ instantiation of bbox_<point>, and to define
+ `vtypes< topo_bbox_<point> >::bbox_type'. */
+ typedef typename bbox_<point>::self_t bbox_type;
typedef point point_type;
typedef mlc::true_ is_random_accessible_type;
};
@@ -66,7 +118,7 @@
{
typedef topo_bbox_<point> self_t;
typedef topology_entry<self_t> super_t;
- typedef bbox_<point> bbox_t;
+ typedef oln_type_of(self_t, bbox) bbox_t;
public:
Index: oln/core/gen/topo_lbbox.hh
--- oln/core/gen/topo_lbbox.hh (revision 647)
+++ oln/core/gen/topo_lbbox.hh (working copy)
@@ -106,7 +106,7 @@
themselves, we use this typename to both trigger the
instantiation of bbox_<point>, and to define
`vtypes< topo_lbbox_<point> >::bbox_type'. */
- typedef typename bbox_<point>::self_t bbox_type;
+ typedef typename bbox_<point>::self_type bbox_type;
typedef point point_type;
typedef mlc::true_ is_random_accessible_type;
};
2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add value cast image morpher.
* tests/value_cast.cc: New.
* tests/Makefile.am: Update.
* oln/morpher/value_cast.hh: New.
* oln/Makefile.am: Update.
* oln/morpher/internal/image_value_morpher.hh (lvalue): Change
definition mode from single_vtype to vtypes.
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am (revision 646)
+++ tests/Makefile.am (working copy)
@@ -40,6 +40,7 @@
\
identity_morpher \
add_neighborhood_morpher \
+ value_cast \
morphers \
\
fill
@@ -67,6 +68,7 @@
# Morphers.
identity_morpher_SOURCES = identity_morpher.cc
add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc
+value_cast_SOURCES = value_cast.cc
morphers_SOURCES = morphers.cc
# Algorithms.
Index: tests/value_cast.cc
===================================================================
--- tests/value_cast.cc (revision 0)
+++ tests/value_cast.cc (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2006 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.
+
+/// Test oln::value_cast.cc.
+
+#include <iostream>
+
+#include <oln/basics2d.hh>
+#include <oln/value/all.hh>
+#include <oln/morpher/value_cast.hh>
+
+
+template <typename T>
+void print(T)
+{
+ std::cout << "?" << std::endl;
+}
+
+
+void print(int)
+{
+ std::cout << "int" << std::endl;
+}
+
+void print(float)
+{
+ std::cout << "float" << std::endl;
+}
+
+void print(unsigned char)
+{
+ std::cout << "unsigned char" << std::endl;
+}
+
+
+
+
+int main()
+{
+ using namespace oln;
+
+ using oln::value::gl8;
+
+ point2d p(0,0);
+
+ {
+ image2d<int> ima(1,1);
+ print( value_cast<float>(ima)(p) );
+ }
+
+ {
+ image2d<bool> ima(1,1);
+ print( value_cast<int>(ima)(p) );
+ }
+
+ {
+ image2d<gl8> ima(1,1);
+ print( value_cast<unsigned char>(ima)(p) );
+ }
+
+}
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 646)
+++ oln/Makefile.am (working copy)
@@ -151,6 +151,7 @@
morpher/identity.hh \
morpher/tags.hh \
morpher/thru_fun.hh \
+ morpher/value_cast.hh \
\
value/all.hh \
value/default.hh \
Index: oln/morpher/value_cast.hh
===================================================================
--- oln/morpher/value_cast.hh (revision 0)
+++ oln/morpher/value_cast.hh (revision 0)
@@ -0,0 +1,129 @@
+// Copyright (C) 2006 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_MORPHER_VALUE_CAST
+# define OLN_MORPHER_VALUE_CAST
+
+# include <xtd/abstract/open_nary_fun.hh>
+# include <xtd/res.hh>
+# include <oln/morpher/internal/image_value_morpher.hh>
+
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <typename Image, typename Value> struct value_cast;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <typename Image, typename Value>
+ struct set_super_type< morpher::value_cast<Image, Value> >
+ {
+ typedef morpher::value_cast<Image, Value> self_t;
+ typedef morpher::internal::image_value_morpher<Image, self_t> ret;
+ };
+
+
+ template <typename Image, typename Value>
+ struct vtypes< morpher::value_cast<Image, Value> >
+ {
+ typedef Value value_type;
+ typedef mlc::false_ is_mutable_type;
+ };
+
+ template <typename Image, typename Value>
+ struct single_vtype< morpher::value_cast<Image, Value>, typedef_::rvalue_type >
+ {
+ typedef Value ret;
+ };
+
+
+
+ namespace morpher
+ {
+
+ /// 'Image thru Valuection' morpher.
+ template <typename Image, typename Value>
+ class value_cast : public internal::image_value_morpher< Image,
+ value_cast<Image, Value> >
+ {
+ private:
+
+ typedef value_cast<Image, Value> self_t;
+ typedef internal::image_value_morpher<Image, self_t> super_t;
+
+ typedef oln_type_of(self_t, psite) psite_t;
+ typedef oln_type_of(self_t, rvalue) rvalue_t;
+
+ public:
+
+ value_cast(const Image& image);
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Image, typename Value>
+ value_cast<Image, Value>::value_cast(const Image& image) :
+ super_t(image)
+ {
+ }
+
+# endif
+
+ } // end of namespace oln::morpher
+
+
+ template <typename Value, typename I>
+ morpher::value_cast<I, Value>
+ value_cast(const abstract::image<I>& ima);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Value, typename I>
+ morpher::value_cast<I, Value>
+ value_cast(const abstract::image<I>& ima)
+ {
+ morpher::value_cast<I, Value> tmp(ima.exact());
+ return tmp;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_MORPHER_VALUE_CAST
Index: oln/morpher/internal/image_value_morpher.hh
===================================================================
--- oln/morpher/internal/image_value_morpher.hh (revision 646)
+++ oln/morpher/internal/image_value_morpher.hh (working copy)
@@ -64,7 +64,7 @@
{
// Morpher type.
typedef oln::morpher::tag::identity morpher_type; // FIXME: Wrong!
-
+ typedef mlc::undefined lvalue_type;
typedef mlc::undefined value_type;
};
@@ -75,14 +75,7 @@
typedef mlc::undefined ret;
};
- template <typename Image, typename Exact>
- struct single_vtype< morpher::internal::image_value_morpher<Image, Exact>,
- typedef_::lvalue_type >
- {
- typedef mlc::undefined ret;
- };
-
namespace morpher
{
namespace internal
Index: ChangeLog
===================================================================
--- ChangeLog (revision 644)
+++ ChangeLog (working copy)
@@ -1,5 +1,20 @@
2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
+ Add binary value type plus update image hierarchy plugs.
+
+ * oln/value/tags.hh: New.
+ * oln/value/bin.hh: New.
+ * oln/value/all.hh: New.
+ * oln/core/abstract/image/type/hierarchy.hh (case_): Rely on value
+ tags.
+ (case_): Overload to handle other value types.
+ (include): Update.
+ * oln/value/greylevel.hh (greylevel_): New conversion operator.
+ (gl1): Remove; now replaced by value::bin.
+ * oln/Makefile.am: Update.
+
+2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
+
Add grey-level types.
* tests/grey.cc: New.
Index: oln/core/abstract/image/type/hierarchy.hh
===================================================================
--- oln/core/abstract/image/type/hierarchy.hh (revision 644)
+++ oln/core/abstract/image/type/hierarchy.hh (working copy)
@@ -30,7 +30,7 @@
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image/hierarchies.hh>
-# include <xtd/valtraits.hh>
+# include <oln/value/tags.hh>
/* Image ``type'' hierarchy (summary).
@@ -93,34 +93,50 @@
namespace oln
{
- /// Switch on on the grid dimension.
+ /// Switch on the value type.
/// \{
- // ----------------------------------------------- //
- // Cases where the value type is an builtin type. //
- // ----------------------------------------------- //
+ // ------------------------------------- //
+ // Cases where the value type is known. //
+ // ------------------------------------- //
/// Binary case.
template <typename E>
struct case_< image_hierarchy_wrt_type, E, 1 > :
- where_< xtd_is_binary(oln_type_of(E, value)) >
+ where_< value::is_binary<oln_type_of(E, value)> >
{
// Definition of the super class corresponding to this case.
typedef abstract::binary_image<E> ret;
};
- /// Grey-level case.
+ /// Color case.
template <typename E>
struct case_< image_hierarchy_wrt_type, E, 2 > :
- where_< mlc::or_list_< mlc::eq_<oln_type_of(E, value), char>,
- mlc::eq_<oln_type_of(E, value), signed char>,
- mlc::eq_<oln_type_of(E, value), unsigned char> > >
+ where_< value::is_color<oln_type_of(E, value)> >
{
// Definition of the super class corresponding to this case.
+ typedef abstract::color_image<E> ret;
+ };
+
+ /// Grey-level case.
+ template <typename E>
+ struct case_< image_hierarchy_wrt_type, E, 3 > :
+ where_< value::is_grey_level<oln_type_of(E, value)> >
+ {
+ // Definition of the super class corresponding to this case.
typedef abstract::grey_level_image<E> ret;
};
+ /// Label case.
+ template <typename E>
+ struct case_< image_hierarchy_wrt_type, E, 4 > :
+ where_< value::is_label<oln_type_of(E, value)> >
+ {
+ // Definition of the super class corresponding to this case.
+ typedef abstract::label_image<E> ret;
+ };
+
// -------------- //
// Default case. //
// -------------- //
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 644)
+++ oln/Makefile.am (working copy)
@@ -152,8 +152,10 @@
morpher/tags.hh \
morpher/thru_fun.hh \
\
+ value/all.hh \
value/default.hh \
value/greylevel.hh \
+ value/tags.hh \
\
basics1d.hh \
basics2d.hh \
Index: oln/value/bin.hh
===================================================================
--- oln/value/bin.hh (revision 0)
+++ oln/value/bin.hh (revision 0)
@@ -0,0 +1,110 @@
+// Copyright (C) 2006 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_VALUE_BIN_HH
+# define OLN_CORE_VALUE_BIN_HH
+
+# include <mlc/bexpr.hh>
+# include <xtd/optraits.hh>
+# include <xtd/valtraits.hh>
+# include <oln/value/greylevel.hh>
+
+
+namespace oln
+{
+
+ namespace value
+ {
+
+ typedef greylevel_<1> bin;
+
+
+ // Binary ops.
+ bin operator and(bin lhs, bin rhs);
+ bin operator or(bin lhs, bin rhs);
+ bin operator xor(bin lhs, bin rhs);
+
+ // Unary ops.
+ bin operator not(bin val);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ bin operator and(bin lhs, bin rhs)
+ {
+ return bin(bool(lhs) and bool(rhs));
+ }
+
+ bin operator or(bin lhs, bin rhs)
+ {
+ return bin(bool(lhs) or bool(rhs));
+ }
+
+ bin operator xor(bin lhs, bin rhs)
+ {
+ return bin(bool(lhs) xor bool(rhs));
+ }
+
+ bin operator not(bin val)
+ {
+ return bin(not bool(val));
+ }
+
+# endif
+
+ } // end of namespace oln::value
+
+} // end of namespace oln
+
+
+
+namespace xtd
+{
+
+ using oln::value::bin;
+
+
+ // Logical traits.
+
+ template <> struct set_trait_< op_land, bin, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_land, bool, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_land, bin, bool > { typedef bin ret; };
+
+ template <> struct set_trait_< op_lor, bin, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_lor, bool, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_lor, bin, bool > { typedef bin ret; };
+
+ template <> struct set_trait_< op_lxor, bin, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_lxor, bool, bin > { typedef bin ret; };
+ template <> struct set_trait_< op_lxor, bin, bool > { typedef bin ret; };
+
+ template <> struct set_trait_< op_lnot, bin > { typedef bin ret; };
+
+} // end of namespace xtd
+
+
+#endif // ! OLN_CORE_VALUE_BIN_HH
Index: oln/value/all.hh
===================================================================
--- oln/value/all.hh (revision 0)
+++ oln/value/all.hh (revision 0)
@@ -0,0 +1,41 @@
+// Copyright (C) 2006 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_VALUE_ALL_HH
+# define OLN_VALUE_ALL_HH
+
+
+# include <oln/value/tags.hh>
+
+# include <oln/value/greylevel.hh>
+# include <oln/value/bin.hh>
+# include <oln/value/default.hh>
+
+# include <oln/color/rgb.hh>
+
+
+#endif // ! OLN_VALUE_ALL_HH
Index: oln/value/greylevel.hh
===================================================================
--- oln/value/greylevel.hh (revision 644)
+++ oln/value/greylevel.hh (working copy)
@@ -30,10 +30,12 @@
# include <iostream>
# include <mlc/contract.hh>
+# include <mlc/bexpr.hh>
# include <xtd/optraits.hh>
# include <oln/core/abstract/value.hh>
+
namespace oln
{
@@ -71,11 +73,14 @@
greylevel_();
/// Ctor.
- explicit greylevel_(typename internal::encoding<nbits>::ret val);
+ explicit greylevel_(const typename internal::encoding<nbits>::ret& val);
/// Access to std type.
typename internal::encoding<nbits>::ret value() const;
+ /// Op encoding_t.
+ operator typename internal::encoding<nbits>::ret() const;
+
/// Op greylevel.
operator greylevel() const;
@@ -96,7 +101,6 @@
/// Aliases.
- typedef greylevel_<1> gl1;
typedef greylevel_<8> gl8;
typedef greylevel_<16> gl16;
typedef greylevel_<32> gl32;
@@ -183,7 +187,7 @@
}
template <unsigned nbits>
- greylevel_<nbits>::greylevel_(typename internal::encoding<nbits>::ret val)
+ greylevel_<nbits>::greylevel_(const typename internal::encoding<nbits>::ret& val)
: val_(val)
{
}
@@ -203,6 +207,12 @@
}
template <unsigned nbits>
+ greylevel_<nbits>::operator typename internal::encoding<nbits>::ret() const
+ {
+ return val_;
+ }
+
+ template <unsigned nbits>
bool greylevel_<nbits>::operator<(const greylevel_<nbits>& rhs) const
{
return val_ < rhs.val_;
Index: oln/value/tags.hh
===================================================================
--- oln/value/tags.hh (revision 0)
+++ oln/value/tags.hh (revision 0)
@@ -0,0 +1,105 @@
+// Copyright (C) 2006 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_VALUE_TAGS_HH
+# define OLN_VALUE_TAGS_HH
+
+# include <mlc/bexpr.hh>
+
+
+namespace oln
+{
+
+
+ namespace color
+ {
+ template <typename T> class rgb_;
+ } // end of namespace oln::color
+
+
+ namespace value
+ {
+
+ // Color trait.
+
+ template <typename T>
+ struct is_color : public mlc::bexpr_<false>
+ {
+ };
+
+ template <typename T>
+ struct is_color < color::rgb_<T> > : public mlc::bexpr_<true> {};
+
+
+ // Grey-level trait.
+
+ template <typename T>
+ struct is_grey_level : public mlc::bexpr_<false>
+ {};
+
+ template <unsigned nbits>
+ class greylevel_;
+
+ template <unsigned nbits>
+ struct is_grey_level < greylevel_<nbits> > : public mlc::bexpr_<true> {};
+
+ class greylevel;
+
+ template <>
+ struct is_grey_level < greylevel > : public mlc::bexpr_<true> {};
+
+
+ // Binary trait.
+
+ template <typename T>
+ struct is_binary : public mlc::bexpr_<false>
+ {
+ };
+
+ template <>
+ struct is_binary < bool > : public mlc::bexpr_<true> {};
+
+ typedef greylevel_<1> bin;
+
+ template <>
+ struct is_binary < bin > : public mlc::bexpr_<true> {};
+
+
+ // Label trait.
+
+ template <typename T>
+ struct is_label : public mlc::bexpr_<false>
+ {
+ };
+
+
+ } // end of namespace oln::value
+
+} // end of namespace oln
+
+
+#endif // ! OLN_VALUE_TAGS_HH