Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2005
- 10 participants
- 59 discussions
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
* oln/core/entry.hh: Move to...
* oln/core/abstract/entry.hh: ...here.
* oln/core/properties.hh: New.
* tests/core/tests/image1d: Adapt to properties management.
* tests/core/tests/image2d: Likewise.
* tests/core/tests/image3d: Likewise.
* tests/core/tests/image_identity: Likewise.
* tests/core/tests/setget: Likewise.
* oln/fancy/print.hh: Likewise.
* oln/fancy/iota.hh: Likewise.
* oln/basics.hh: Likewise.
* oln/makefile.src: Likewise.
* oln/io/write_image_2d_pnm.hh: Likewise.
* oln/io/read_image_2d_pnm.hh: Likewise.
* oln/io/write_image.hh: Likewise.
* oln/io/read_image.hh: Likewise.
* oln/core/value_box.hh: Likewise.
* oln/core/abstract/image_constness.hh: Likewise.
* oln/core/abstract/image.hh: Likewise.
* oln/core/abstract/piter.hh: Likewise.
* oln/core/abstract/images.hh: Likewise.
* oln/core/abstract/image_with_data.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
* oln/core/abstract/image_identity.hh: Likewise.
* oln/core/abstract/data_storage.hh: Likewise.
* oln/core/abstract/internal/image_impl.hh: Likewise.
* oln/core/abstract/op.hh: Likewise.
* oln/core/1d/array1d.hh: Likewise.
* oln/core/1d/image1d.hh: Likewise.
* oln/core/1d/fwd_piter1d.hh: Likewise.
* oln/core/1d/point1d.hh: Likewise.
* oln/core/coord.hh: Likewise.
* oln/core/2d/array2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/fwd_piter2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/3d/array3d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
* oln/core/3d/point3d.hh: Likewise.
* oln/core/cats.hh: Remove because obsolete.
* oln/core/props.hh: Likewise.
* oln/core/macros.hh: Likewise.
oln/basics.hh | 2
oln/core/1d/array1d.hh | 13 ++
oln/core/1d/fwd_piter1d.hh | 13 ++
oln/core/1d/image1d.hh | 47 ++++++----
oln/core/1d/point1d.hh | 16 ++-
oln/core/2d/array2d.hh | 15 ++-
oln/core/2d/fwd_piter2d.hh | 12 ++
oln/core/2d/image2d.hh | 35 ++++---
oln/core/2d/point2d.hh | 15 ++-
oln/core/3d/array3d.hh | 13 ++
oln/core/3d/image3d.hh | 42 ++++-----
oln/core/3d/point3d.hh | 13 ++
oln/core/abstract/data_storage.hh | 61 +++++++++++--
oln/core/abstract/entry.hh | 83 ++++++++++++++++++
oln/core/abstract/image.hh | 138 +++++++++++++++++++++----------
oln/core/abstract/image_constness.hh | 17 ++-
oln/core/abstract/image_identity.hh | 28 +++++-
oln/core/abstract/image_with_data.hh | 54 ++++++++++--
oln/core/abstract/images.hh | 3
oln/core/abstract/internal/image_impl.hh | 7 -
oln/core/abstract/op.hh | 22 ++++
oln/core/abstract/piter.hh | 45 +++++++---
oln/core/abstract/point.hh | 41 ++++++---
oln/core/cats.hh | 79 -----------------
oln/core/coord.hh | 8 +
oln/core/entry.hh | 66 --------------
oln/core/macros.hh | 86 -------------------
oln/core/properties.hh | 95 +++++++++++++++++++++
oln/core/props.hh | 77 -----------------
oln/core/value_box.hh | 37 ++++----
oln/fancy/iota.hh | 3
oln/fancy/print.hh | 5 -
oln/io/read_image.hh | 4
oln/io/read_image_2d_pnm.hh | 27 ++----
oln/io/write_image.hh | 6 -
oln/io/write_image_2d_pnm.hh | 3
oln/makefile.src | 6 -
tests/core/tests/image1d | 2
tests/core/tests/image2d | 2
tests/core/tests/image3d | 2
tests/core/tests/image_identity | 11 +-
tests/core/tests/setget | 6 -
42 files changed, 700 insertions(+), 560 deletions(-)
Index: tests/core/tests/image1d
--- tests/core/tests/image1d (revision 50)
+++ tests/core/tests/image1d (working copy)
@@ -13,7 +13,7 @@
template <typename I>
-void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p)
+void foo(oln::abstract::image<I>& input, const oln_type_of(I, point)& p)
{
// FIXME: dummy code below
// struct dummy {};
Index: tests/core/tests/image2d
--- tests/core/tests/image2d (revision 50)
+++ tests/core/tests/image2d (working copy)
@@ -13,7 +13,7 @@
template <typename I>
-void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p)
+void foo(oln::abstract::image<I>& input, const oln_type_of(I, point)& p)
{
// FIXME: dummy code below
// struct dummy {};
Index: tests/core/tests/image3d
--- tests/core/tests/image3d (revision 50)
+++ tests/core/tests/image3d (working copy)
@@ -13,7 +13,7 @@
template <typename I>
-void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p)
+void foo(oln::abstract::image<I>& input, const oln_type_of(I, point)& p)
{
// FIXME: dummy code below
// struct dummy {};
Index: tests/core/tests/image_identity
--- tests/core/tests/image_identity (revision 50)
+++ tests/core/tests/image_identity (working copy)
@@ -10,14 +10,14 @@
namespace oln {
template <typename I>
- struct category_type< image_identity<I> >
+ struct set_category< image_identity<I> >
{
- typedef cat::image ret;
+ typedef category::image ret;
};
template <typename I>
- struct props <cat::image, image_identity<I> >
- : public props<cat::image, I>
+ struct set_props < category::image, image_identity<I> >
+ : public get_props < category::image, I >
{
typedef I delegated_type;
};
@@ -25,8 +25,7 @@
}
template <typename I>
-struct image_identity:
- public oln::abstract::image_identity<I, image_identity<I> >
+struct image_identity : public oln::abstract::image_identity<I, image_identity<I> >
{
typedef oln::abstract::image_identity<I, image_identity<I> > super_type;
Index: tests/core/tests/setget
--- tests/core/tests/setget (revision 50)
+++ tests/core/tests/setget (working copy)
@@ -7,13 +7,13 @@
struct dummy_image;
template <>
- struct category_type< dummy_image >
+ struct set_category< dummy_image >
{
- typedef cat::image ret;
+ typedef category::image ret;
};
template <>
- struct props <cat::image, dummy_image>
+ struct set_props < category::image, dummy_image > : public props_of <category::image>
{
typedef int size_type;
typedef int point_type;
Index: oln/fancy/print.hh
--- oln/fancy/print.hh (revision 50)
+++ oln/fancy/print.hh (working copy)
@@ -40,6 +40,7 @@
# include <oln/core/2d/point2d.hh>
# include <oln/core/coord.hh>
+
namespace oln {
namespace fancy {
@@ -106,7 +107,7 @@
// FIXME: lacks cleaning
for (coord_t index = 0; index < input.size().nindices(); ++index)
{
- ostr << internal::pp<oln_value_type(E)>(input[point1d(index)]) << ' ';
+ ostr << internal::pp<oln_type_of(E, value)>(input[point1d(index)]) << ' ';
}
ostr << std::endl;
}
@@ -118,7 +119,7 @@
for (coord_t row = 0; row < input.size().nrows(); ++row)
{
for (coord_t col = 0; col < input.size().ncols(); ++col)
- ostr << internal::pp<oln_value_type(E)>(input[point2d(row,col)]) << ' ';
+ ostr << internal::pp<oln_type_of(E, value)>(input[point2d(row,col)]) << ' ';
ostr << std::endl;
}
}
Index: oln/fancy/iota.hh
--- oln/fancy/iota.hh (revision 50)
+++ oln/fancy/iota.hh (working copy)
@@ -28,7 +28,6 @@
#ifndef OLENA_FANCY_IOTA_HH
# define OLENA_FANCY_IOTA_HH
-# include <oln/core/macros.hh>
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/piter.hh>
@@ -43,7 +42,7 @@
void iota(abstract::image<I>& inout)
{
unsigned counter = 0;
- oln_piter_type(I) p(inout.size());
+ oln_type_of(I, fwd_piter) p(inout.size());
for_all(p)
inout[p] = ++counter;
}
Index: oln/basics.hh
--- oln/basics.hh (revision 50)
+++ oln/basics.hh (working copy)
@@ -54,7 +54,7 @@
// oln::
# include <oln/core/coord.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
# include <oln/core/value_box.hh>
# include <oln/core/abstract/size.hh>
Index: oln/makefile.src
--- oln/makefile.src (revision 50)
+++ oln/makefile.src (working copy)
@@ -24,6 +24,7 @@
core/3d/point3d.hh \
core/3d/size3d.hh \
core/abstract/data_storage.hh \
+ core/abstract/entry.hh \
core/abstract/image.hh \
core/abstract/image_constness.hh \
core/abstract/image_identity.hh \
@@ -34,11 +35,8 @@
core/abstract/piter.hh \
core/abstract/point.hh \
core/abstract/size.hh \
- core/cats.hh \
core/coord.hh \
- core/macros.hh \
- core/props.hh \
- core/entry.hh \
+ core/properties.hh \
core/value_box.hh \
fancy/iota.hh \
fancy/print.hh \
Index: oln/io/write_image_2d_pnm.hh
--- oln/io/write_image_2d_pnm.hh (revision 50)
+++ oln/io/write_image_2d_pnm.hh (working copy)
@@ -41,7 +41,6 @@
# include <ntg/color/color.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/macros.hh>
# include <oln/core/abstract/op.hh>
# include <oln/io/utils.hh>
@@ -56,7 +55,7 @@
struct write_image_2d_raw
: public oln::abstract::void_op<write_image_2d_raw<I> >
{
- typedef oln_value_type(I) value_type;
+ typedef oln_type_of(I, value) value_type;
typedef ntg_io_type(value_type) io_type;
const I& to_write_;
Index: oln/io/read_image_2d_pnm.hh
--- oln/io/read_image_2d_pnm.hh (revision 50)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -13,7 +13,6 @@
# include <ntg/color/color.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/macros.hh>
# include <oln/core/abstract/op.hh>
# include <oln/io/utils.hh>
@@ -24,43 +23,39 @@
template <typename I>
struct image2d;
+ // fwd decl
namespace io {
-
namespace impl {
-
- template <typename I>
- struct read_image_2d_raw;
-
+ template <typename I> struct read_image_2d_raw;
}
-
}
+ // category
template <typename I>
- struct category_type< io::impl::read_image_2d_raw<I> >
+ struct set_category < io::impl::read_image_2d_raw<I> >
{
- typedef cat::image ret;
+ typedef category::image ret;
};
+ // super_type
template <typename I>
- struct props <cat::image, io::impl::read_image_2d_raw<I> >
- : public props<cat::image, I>
+ struct set_super_type < io::impl::read_image_2d_raw<I> >
{
- typedef I delegated_type;
+ typedef abstract::op<I, io::impl::read_image_2d_raw<I> > ret;
};
-
namespace io {
namespace impl {
template <typename I>
- struct read_image_2d_raw:
- oln::abstract::op<I, read_image_2d_raw<I> >
+ struct read_image_2d_raw :
+ public oln::abstract::op<I, read_image_2d_raw<I> >
{
typedef oln::abstract::op<I, read_image_2d_raw<I> > super_type;
- typedef oln_value_type(I) value_type;
+ typedef oln_type_of(I, value) value_type;
typedef ntg_io_type(value_type) io_type;
mlc::box<I> image_;
Index: oln/io/write_image.hh
--- oln/io/write_image.hh (revision 50)
+++ oln/io/write_image.hh (working copy)
@@ -37,11 +37,11 @@
namespace io {
- template <typename E>
- void write(const abstract::image<E>& im, const std::string& name)
+ template <typename I>
+ void write(const abstract::image<I>& im, const std::string& name)
{
std::string ext;
- oln_value_type(E) t;
+ oln_type_of(I, value) t;
ext = internal::utils::extension(name);
Index: oln/io/read_image.hh
--- oln/io/read_image.hh (revision 50)
+++ oln/io/read_image.hh (working copy)
@@ -33,8 +33,6 @@
# include <mlc/box.hh>
-# include <oln/core/macros.hh>
-
# include <oln/io/read_image_2d_pnm.hh>
# include <oln/io/utils.hh>
@@ -65,7 +63,7 @@
void do_read(abstract::image<I>& ima, const filename& name)
{
std::string ext;
- const oln_value_type(I) t;
+ const oln_type_of(I, value) t;
ext = internal::utils::extension(name.get());
Index: oln/core/entry.hh
--- oln/core/entry.hh (revision 50)
+++ oln/core/entry.hh (working copy)
@@ -1,66 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ENTRY_HH
-# define OLENA_CORE_ENTRY_HH
-
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-
-
-namespace oln {
-
- template <template <typename> class Base>
- struct prop_of
- {
- template <typename E>
- struct inherits
- {
- typedef Base<E> ret;
- };
- };
-
- namespace abstract {
-
- template <typename E>
- struct image_entry :
- public props < cat::image, E >::image_constness
- ::template inherits<E>::ret,
- public props < cat::image, E >::image_dimension
- ::template inherits<E>::ret
- // ...
- {
- protected:
- image_entry() {}
- };
-
- }
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_ENTRY_HH
Index: oln/core/props.hh
--- oln/core/props.hh (revision 50)
+++ oln/core/props.hh (working copy)
@@ -1,77 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_PROPS_HH
-# define OLENA_CORE_PROPS_HH
-
-# include <mlc/types.hh>
-
-# include <oln/core/cats.hh>
-
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
-
-
- /*! \class default_props
- **
- ** \brief Class that defines properties by default, so properties are
- ** undefined. // FIXME: this doc should be modified...
- **
- ** Practically all typedefs of default_props are thus set to
- ** mlc::undefined_type.
- **
- ** When props<E> is specialized, the programmer should derive that
- ** specialization from another props<E'> or from default_props.
- ** That ensures that an undefined property is set to mlc::undefined_type.
- **
- ** \see props<E>
- */
- template < typename category >
- struct default_props;
-
-
- /*! \class props<E>
- **
- ** Declaration of the trait class for properties.
- ** Parameter E is the targeted type. FIXME: rewrite doc.
- */
- template <typename category, typename type>
- struct props : public default_props <category>
- {};
-
- template <typename category, typename type>
- struct props <category, const type> : public props <category, type>
- {};
-
-
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_PROPS_HH
Index: oln/core/value_box.hh
--- oln/core/value_box.hh (revision 50)
+++ oln/core/value_box.hh (working copy)
@@ -30,16 +30,11 @@
# include <iostream>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
-// the proper macro:
-// for use in 'abstract::image::op[](point)'
-# define oln_value_box_type(E) typename oln::value_box<E>
-
-
/*! \namespace oln
** \brief oln namespace.
*/
@@ -78,7 +73,12 @@
public:
+ /// typedefs
+ typedef oln_type_of(I, value) value_type;
+ typedef oln_type_of(I, point) point_type;
+
+
/*! \brief op=
** FIXME:...
** \return (*this)
@@ -103,7 +103,7 @@
template <typename II>
value_box& operator=(const value_box<II>& rhs)
{
- ima_.set(p_, rhs); // automatic conversion from rhs to oln_value_type(I)
+ ima_.set(p_, rhs); // automatic conversion from rhs to value_type
return *this;
}
@@ -137,7 +137,7 @@
return value;
}
- operator const oln_value_type(I)() const
+ operator const value_type() const
{
return ima_.get(p_);
}
@@ -154,7 +154,7 @@
** \return a value (const, temp)
*/
- const oln_value_type(I) value() const
+ const value_type value() const
{
return ima_.get(p_);
}
@@ -179,7 +179,7 @@
/// Ctor (restricted access).
- value_box(abstract::image<I>& ima, const oln_point_type(I)& p) :
+ value_box(abstract::image<I>& ima, const point_type& p) :
ima_(ima.exact()),
p_(p)
{
@@ -190,7 +190,7 @@
*------------*/
I& ima_;
- oln_point_type(I) p_;
+ point_type p_;
};
@@ -213,6 +213,13 @@
public:
+ /// typedefs
+
+ typedef oln_type_of(I, value) value_type;
+ typedef oln_type_of(I, point) point_type;
+
+
+
/*! \brief Assignment (op=) is declared but undefined.
*/
@@ -232,7 +239,7 @@
return value;
}
- operator const oln_value_type(I)() const
+ operator const value_type() const
{
return ima_.get(p_);
}
@@ -249,7 +256,7 @@
** \return a value (const, temp)
*/
- const oln_value_type(I) value() const
+ const value_type value() const
{
return ima_.get(p_);
}
@@ -276,7 +283,7 @@
/// Ctor (restricted access).
- value_box(const abstract::image<I>& ima, const oln_point_type(I)& p) :
+ value_box(const abstract::image<I>& ima, const point_type& p) :
ima_(ima.exact()),
p_(p)
{
@@ -287,7 +294,7 @@
*------------*/
const I& ima_;
- oln_point_type(I) p_;
+ point_type p_;
};
Index: oln/core/macros.hh
--- oln/core/macros.hh (revision 50)
+++ oln/core/macros.hh (working copy)
@@ -1,86 +0,0 @@
-// Copyright (C) 2001, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_MACROS_HH
-# define OLENA_CORE_MACROS_HH
-
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
-
-
-
-// FIXME: some crucial (meta-)work to be done here!
-//
-// first, introduce a piece of meta-code to get the proper abstraction
-// from parameter; e.g., if I is an abstract::image then abstraction
-// is abstract::image else etc.
-//
-// second, in macro below, there should be an exact_type from I somewhere
-// cause we cannot be sure that I is an exact type; just think about it...
-
-
-
-
-
-// for oln::abstract::image
-//--------------------------
-
-// unary macros
-
-# define oln_delegated_type(T) typename oln::props<oln_category_type(T),T>::delegated_type
-
-# define oln_size_type(T) typename oln::props<oln_category_type(T),T>::size_type
-# define oln_point_type(T) typename oln::props<oln_category_type(T),T>::point_type
-# define oln_dpoint_type(T) typename oln::props<oln_category_type(T),T>::dpoint_type
-# define oln_value_type(T) typename oln::props<oln_category_type(T),T>::value_type
-# define oln_iter_type(T) typename oln::props<oln_category_type(T),T>::iter_type
-
-# define oln_value_storage_type(T) typename oln::props<oln_category_type(T),T>::value_storage_type
-# define oln_value_container_type(T) typename oln::props<oln_category_type(T),T>::value_container_type
-
-# define oln_piter_type(T) typename oln::props<oln_category_type(T),T>::piter_type
-# define oln_fwd_piter_type(T) typename oln::props<oln_category_type(T),T>::fwd_piter_type
-
-// binary macros
-
-# define oln_ch_value_type(I,V) typename oln::props<oln_category_type(I),I>::ch_value_type<V>::ret
-
-
-// for oln::abstract::data_storage
-
-# define oln_data_type(T) typename oln::props<oln_category_type(T),T>::data_type
-
-
-
-// generic macros
-//----------------
-
-# define oln_typeof( FROM_TYPE, WHAT_TYPE ) typename oln::props<oln_category_type(FROM_TYPE),FROM_TYPE>::WHAT_TYPE##_type
-
-
-
-#endif // ! OLENA_CORE_MACROS_HH
Index: oln/core/abstract/image_constness.hh
--- oln/core/abstract/image_constness.hh (revision 50)
+++ oln/core/abstract/image_constness.hh (working copy)
@@ -87,6 +87,11 @@
*/
+ /// typedef
+
+ typedef oln_type_of(E, point) point_type;
+
+
/*! \brief Write the value \a v at \a p in the current image.
** This method is used in value_box<I>. Client should not use
** this method but abstract::image<I>::operator[](point)
@@ -96,7 +101,7 @@
*/
template <typename V>
- void set(const oln_point_type(E)& p, const V& v)
+ void set(const point_type& p, const V& v)
{
return this->exact().impl_set(p, v);
}
@@ -104,7 +109,7 @@
// FIXME: NEW:
// template <typename A, typename V>
-// void& set(const oln_point_type(E)& p,
+// void& set(const point_type& p,
// void (I::*method)(A),
// const V& value)
// {
@@ -126,10 +131,12 @@
template <typename E>
struct set_image_impl < readwrite_image<E>, E> : public virtual image_impl<E>
{
+ /// typedefs
typedef typename image_impl<E>::D D;
+ typedef oln_type_of(D, point) point_type;
template <typename V>
- void impl_set(const oln_point_type(D)& p, const V& v)
+ void impl_set(const point_type& p, const V& v)
{
this->exact().impl_set_ante(p, v);
this->delegate().impl_set(p, v);
@@ -139,10 +146,10 @@
// extra code; default is 'do nothing':
template <typename V>
- void impl_set_ante(const oln_point_type(D)&, const V&) {}
+ void impl_set_ante(const point_type&, const V&) {}
template <typename V>
- void impl_set_post(const oln_point_type(D)&, const V&) {}
+ void impl_set_post(const point_type&, const V&) {}
};
} // end of namespace oln::abstract::internal
Index: oln/core/abstract/entry.hh
--- oln/core/abstract/entry.hh (revision 0)
+++ oln/core/abstract/entry.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ABSTRACT_ENTRY_HH
+# define OLENA_CORE_ABSTRACT_ENTRY_HH
+
+# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+
+
+// FIXME: this file should move to oln/core/abstract/
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace abstract {
+ template <typename E> struct image_entry;
+ }
+
+ // category
+ template <typename E>
+ struct set_category < abstract::image_entry<E> >
+ {
+ typedef category::image ret;
+ };
+
+
+
+ namespace abstract {
+
+// namespace internal {
+
+// template < typename isa, typename E >
+// struct inherits
+// {
+// typedef typename isa::template instantiated_with<E>::ret ret;
+// };
+
+// }
+
+ template <typename E>
+ struct image_entry :
+ // intrusive:
+ public oln_type_of_(E, image_constness) ::template instantiated_with<E>::ret,
+ public oln_type_of_(E, image_dimension) ::template instantiated_with<E>::ret
+ // ...
+ {
+ protected:
+ image_entry() {}
+ };
+
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_ENTRY_HH
Index: oln/core/abstract/image.hh
--- oln/core/abstract/image.hh (revision 50)
+++ oln/core/abstract/image.hh (working copy)
@@ -28,10 +28,10 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_HH
# define OLENA_CORE_ABSTRACT_IMAGE_HH
+# include <mlc/types.hh>
+
# include <oln/core/abstract/internal/image_impl.hh>
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
# include <oln/core/value_box.hh>
@@ -41,37 +41,72 @@
namespace oln {
+ // fwd decl
+ namespace abstract {
+ template <typename E> struct image;
+ template <typename E> struct readonly_image;
+ }
- // FIXME: doc
- template <>
- struct default_props < cat::image >
- {
- typedef mlc::undefined_type delegated_type;
+ // category
+ template <typename E>
+ struct set_category< abstract::image<E> > { typedef category::image ret; };
- typedef mlc::undefined_type size_type;
- typedef mlc::undefined_type point_type;
- typedef mlc::undefined_type value_type;
- typedef mlc::undefined_type piter_type;
- typedef mlc::undefined_type fwd_piter_type;
- typedef mlc::undefined_type value_storage_type;
- typedef mlc::undefined_type value_container_type;
+ /// properties of any type in category::image
- // FIXME: etc.
+ template <typename type>
+ struct props_of <category::image, type>
+ {
+ typedef mlc::true_type user_defined_;
+
+ mlc_decl_prop(category::image, value_type);
+ mlc_decl_prop(category::image, point_type);
+ mlc_decl_prop(category::image, size_type);
+ mlc_decl_prop(category::image, fwd_piter_type);
+ mlc_decl_prop_with_default(category::image, value_storage_type, mlc::no_type);
+ mlc_decl_prop_with_default(category::image, storage_type, mlc::no_type);
+ mlc_decl_prop_with_default(category::image, delegated_type, mlc::no_type);
- template <typename T>
- struct ch_value_type
+ mlc_decl_prop_with_default(category::image, image_constness_type, is_a<abstract::readonly_image>);
+ mlc_decl_prop(category::image, image_dimension_type);
+
+ //...
+
+ static void echo(std::ostream& ostr)
{
- typedef mlc::undefined_type ret;
- };
+ ostr << "props_of(" // FIXME: << typeid(oln::category::image).name()
+ << ", " << typeid(type).name() << ") = {"
+ << " value_type = " << typeid(value_type).name()
+ << " point_type = " << typeid(point_type).name()
+ << " size_type = " << typeid(size_type).name()
+ << " fwd_piter_type = " << typeid(fwd_piter_type).name()
+ << " value_storage_type = " << typeid(value_storage_type).name()
+ << " storage_type = " << typeid(storage_type).name()
+ << " delegated_type = " << typeid(delegated_type).name()
- protected:
- default_props() {}
+ << " image_constness_type = " << typeid(image_constness_type).name()
+ << " image_dimension_type = " << typeid(image_dimension_type).name()
+
+ << " }" << std::endl;
+ }
+
};
+ mlc_register_prop(category::image, value_type);
+ mlc_register_prop(category::image, point_type);
+ mlc_register_prop(category::image, size_type);
+ mlc_register_prop(category::image, fwd_piter_type);
+ mlc_register_prop(category::image, value_storage_type);
+ mlc_register_prop(category::image, storage_type);
+ mlc_register_prop(category::image, delegated_type);
+ mlc_register_prop(category::image, image_constness_type);
+ mlc_register_prop(category::image, image_dimension_type);
+
+
+
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
@@ -92,20 +127,27 @@
struct image : public internal::get_image_impl < image<E>, E>
{
+ /// typedefs
+
+ typedef oln_type_of(E, size) size_type;
+ typedef oln_type_of(E, value) value_type;
+ typedef oln_type_of(E, point) point_type;
+
+
/*------------------*
! abstract methods !
*------------------*/
- /*! \brief Return the size of the current image. Nota bene: this method is abstract-like.it
- ** is a pseudo-abstract method.
+ /*! \brief Return the size of the current image. Nota bene:
+ ** this method is abstract-like.it is a pseudo-abstract method.
**
** \return An object deriving from abstract::size. Ex: if the
** image is an image2d<something>, the returned object is a
** size2d.
*/
- const oln_size_type(E)& size() const
+ const size_type& size() const
{
return this->exact().impl_size();
}
@@ -137,7 +179,7 @@
** \see hold_large
*/
- bool hold(const oln_point_type(E)& p) const
+ bool hold(const point_type& p) const
{
precondition(this->npoints() != 0);
return this->exact().impl_hold(p);
@@ -158,7 +200,7 @@
** \see hold
*/
- bool hold_large(const oln_point_type(E)& p) const
+ bool hold_large(const point_type& p) const
{
precondition(this->npoints() != 0);
return this->exact().impl_hold_large(p);
@@ -175,7 +217,7 @@
** \see hold_large
*/
- bool impl_hold_large(const oln_point_type(E)& p) const
+ bool impl_hold_large(const point_type& p) const
{
return this->hold(p);
}
@@ -196,11 +238,11 @@
** \see value_box
*/
- oln_value_box_type(const E) operator[](const oln_point_type(E)& p) const
+ value_box<const E> operator[](const point_type& p) const
{
precondition(this->npoints() != 0);
precondition(this->hold_large(p));
- oln_value_box_type(const E) tmp(this->exact(), p);
+ value_box<const E> tmp(this->exact(), p);
return tmp;
}
@@ -214,11 +256,11 @@
** \see value_box
*/
- oln_value_box_type(E) operator[](const oln_point_type(E)& p)
+ value_box<E> operator[](const point_type& p)
{
precondition(this->npoints() != 0);
precondition(this->hold_large(p));
- oln_value_box_type(E) tmp(this->exact(), p);
+ value_box<E> tmp(this->exact(), p);
return tmp;
}
@@ -251,7 +293,7 @@
** \see value_box, abstract::image<I>::operator[](point)
*/
- const oln_value_type(E) get(const oln_point_type(E)& p) const
+ const value_type get(const point_type& p) const
{
return this->exact().impl_get(p);
}
@@ -282,13 +324,21 @@
template <typename E>
struct set_image_impl < image<E>, E > : public virtual image_impl<E>
{
+
+ /// typedefs
+
typedef typename image_impl<E>::D D;
+ typedef oln_type_of(D, size) size_type;
+ typedef oln_type_of(D, point) point_type;
+ typedef oln_type_of(D, value) value_type;
+
+
// delegations are "template methods" (Cf. the GOF's book)
- const oln_size_type(D)& impl_size() const
+ const size_type& impl_size() const
{
- const oln_size_type(D)& s = this->delegate().size();
+ const size_type& s = this->delegate().size();
this->exact().impl_size_extra(s);
return s;
}
@@ -300,31 +350,31 @@
return n;
}
- bool impl_hold(const oln_point_type(D)& p) const
+ bool impl_hold(const point_type& p) const
{
this->exact().impl_hold_extra(p);
return this->delegate().hold(p);
}
- bool impl_hold_large(const oln_point_type(D)& p) const
+ bool impl_hold_large(const point_type& p) const
{
this->exact().impl_hold_large_extra(p);
return this->delegate().hold_large(p);
}
- oln_value_box_type(D) operator[](const oln_point_type(D)& p) const
+ value_box<D> operator[](const point_type& p) const
{
precondition(this->hold_large(p));
return this->delegate().operator[](p);
}
- oln_value_box_type(const D) operator[](const oln_point_type(D)& p)
+ value_box<const D> operator[](const point_type& p)
{
precondition(this->hold_large(p));
return this->delegate().operator[](p);
}
- const oln_value_type(D) impl_get(const oln_point_type(D)& p) const
+ const value_type impl_get(const point_type& p) const
{
this->exact().impl_get_extra(p);
return this->delegate().impl_get(p);
@@ -332,13 +382,13 @@
// extra code; default is "do nothing"
- void impl_size_extra(const oln_size_type(D)& s) const {}
+ void impl_size_extra(const size_type& s) const {}
void impl_npoints_extra(unsigned long n) const {}
- void impl_hold_extra(const oln_point_type(D)& p) const {}
- void impl_hold_large_extra(const oln_point_type(D)& p) const {}
+ void impl_hold_extra(const point_type& p) const {}
+ void impl_hold_large_extra(const point_type& p) const {}
- void impl_get_extra(const oln_point_type(D)&) const {}
+ void impl_get_extra(const point_type&) const {}
};
} // end of namespace oln::abstract::internal
Index: oln/core/abstract/piter.hh
--- oln/core/abstract/piter.hh (revision 50)
+++ oln/core/abstract/piter.hh (working copy)
@@ -33,9 +33,7 @@
# include <mlc/contract.hh>
# include <oln/core/abstract/point.hh>
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
@@ -44,34 +42,55 @@
namespace oln {
+ // fwd decl
namespace abstract {
-
template <typename E> struct piter;
-
}
-
+ // category
template <typename E>
- struct category_type<abstract::piter<E> > { typedef cat::piter ret; };
+ struct set_category< abstract::piter<E> > { typedef category::piter ret; };
- template <>
- struct default_props < cat::piter >
+ /// properties of any type in category::piter
+
+ template <typename type>
+ struct props_of < category::piter, type >
{
- typedef mlc::undefined_type point_type;
- typedef mlc::undefined_type size_type;
+ typedef mlc::true_type user_defined_;
+
+ mlc_decl_prop(category::piter, size_type);
+ mlc_decl_prop(category::piter, point_type);
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( category::piter, "
+ << typeid(type).name() << ") = {"
+ << " size_type = " << typeid(size_type).name()
+ << " point_type = " << typeid(point_type).name() << " }" << std::endl;
+ }
+
};
+ mlc_register_prop(category::piter, size_type);
+ mlc_register_prop(category::piter, point_type);
+
+
namespace abstract {
template <typename E>
struct piter : public mlc::any__best_speed<E>
{
+
+ /// typedefs
+
typedef piter<E> self_type;
- typedef oln_point_type(E) point_type;
- typedef oln_size_type(E) size_type;
+ typedef oln_type_of(E, size) size_type;
+ typedef oln_type_of(E, point) point_type;
+
+
void start()
{
this->exact().impl_start();
Index: oln/core/abstract/images.hh
--- oln/core/abstract/images.hh (revision 50)
+++ oln/core/abstract/images.hh (working copy)
@@ -36,7 +36,4 @@
# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/entry.hh>
-
-
#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
--- oln/core/abstract/image_with_data.hh (revision 50)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -31,15 +31,44 @@
# include <mlc/tracked_ptr.hh>
-# include <oln/core/entry.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/abstract/entry.hh>
+
/*! \namespace oln
** \brief oln namespace.
*/
namespace oln {
+ // fwd decl
+ namespace abstract {
+ template <typename E> class image_with_data;
+ }
+
+ // category
+ template <typename E>
+ struct set_category < abstract::image_with_data<E> >
+ {
+ typedef category::image ret;
+ };
+
+ // super_type
+ template <typename E>
+ struct set_super_type < abstract::image_with_data<E> >
+ {
+ typedef abstract::image_entry<E> ret;
+ };
+
+ // props
+ template <typename E>
+ struct set_props < category::image, abstract::image_with_data<E> > : public props_of<category::image>
+ {
+ // intrusive property:
+ typedef is_a<abstract::readwrite_image> image_constness_type;
+ };
+
+
+
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
@@ -59,7 +88,14 @@
public:
+ /// typedefs
+ typedef oln_type_of(E, size) size_type;
+ typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, value) value_type;
+ typedef oln_type_of(E, storage) storage_type;
+
+
/*! \brief Implement abstract::image<E>::size() so return the
** size of the current image.
**
@@ -68,7 +104,7 @@
** size2d.
*/
- const oln_size_type(E)& impl_size() const
+ const size_type& impl_size() const
{
precondition(this->has_data());
return this->data_->size();
@@ -97,7 +133,7 @@
** \return True if p belongs to the current image, false otherwise.
*/
- bool impl_hold(const oln_point_type(E)& p) const
+ bool impl_hold(const point_type& p) const
{
precondition(this->has_data());
return this->data_->hold(p);
@@ -111,7 +147,7 @@
** \return True if p belongs to the current image, false otherwise.
*/
- const oln_value_type(E) impl_get(const oln_point_type(E)& p) const
+ const value_type impl_get(const point_type& p) const
{
precondition(this->has_data());
return this->data_->get(p);
@@ -123,7 +159,7 @@
*/
template <typename V>
- void impl_set(const oln_point_type(E)& p, const V& v)
+ void impl_set(const point_type& p, const V& v)
{
precondition(this->has_data());
this->data_->set(p, v);
@@ -151,8 +187,8 @@
/*! \brief Constructor (protected) with memory allocation for
** data.
*/
- image_with_data(const oln_size_type(E)& size) :
- data_(new oln_value_container_type(E)(size))
+ image_with_data(const size_type& size) :
+ data_(new storage_type(size))
{
}
@@ -166,7 +202,7 @@
/*! \brief Data storage.
*/
- mlc::tracked_ptr<oln_value_container_type(E)> data_;
+ mlc::tracked_ptr<storage_type> data_;
};
Index: oln/core/abstract/point.hh
--- oln/core/abstract/point.hh (revision 50)
+++ oln/core/abstract/point.hh (working copy)
@@ -29,10 +29,9 @@
# define OLENA_CORE_ABSTRACT_POINT_HH
# include <mlc/any.hh>
+# include <mlc/bool.hh>
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
/*! \namespace oln
@@ -41,24 +40,37 @@
namespace oln {
- /// fwd decl
+ // fwd decl
namespace abstract {
template <typename E> struct point;
}
+ // category
+ template <typename E>
+ struct set_category< abstract::point<E> > { typedef category::point ret; };
- /*! \class default_props< cat::point >
- **
- ** Default properties for points. Specialization of
- ** default_props<category>.
- */
- template <>
- struct default_props < cat::point >
+
+ /// properties of any type in category::point
+
+ template <typename type>
+ struct props_of < category::point, type >
{
- typedef mlc::undefined_type dpoint_type;
+ typedef mlc::true_type user_defined_;
+
+ mlc_decl_prop(category::point, dpoint_type);
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( category::point, "
+ << typeid(type).name() << ") = {"
+ << " dpoint_type = " << typeid(dpoint_type).name() << " }" << std::endl;
+ }
+
};
+ mlc_register_prop(category::point, dpoint_type);
+
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
@@ -95,9 +107,10 @@
return ! this->operator==(rhs);
}
- typedef oln_dpoint_type(E) dpoint_type;
+ // FIXME: doc...
- // FIXME: doc
+ typedef oln_type_of(E, dpoint) dpoint_type;
+
const point operator+(const dpoint_type& dp) const
{
return this->exact().impl_plus(dp);
Index: oln/core/abstract/image_identity.hh
--- oln/core/abstract/image_identity.hh (revision 50)
+++ oln/core/abstract/image_identity.hh (working copy)
@@ -30,14 +30,38 @@
# include <mlc/box.hh>
-# include <oln/core/entry.hh>
+# include <oln/core/properties.hh>
+# include <oln/core/abstract/entry.hh>
+
namespace oln {
+
+ // fwd decl
namespace abstract {
+ template <typename I, typename E> struct image_identity;
+ }
+ // category
+ template <typename I, typename E>
+ struct set_category< abstract::image_identity<I,E> > {
+ typedef category::image ret;
+ };
+
+ // props
+ template <typename I, typename E>
+ struct set_props < category::image, abstract::image_identity<I,E> >
+ : public get_props< category::image, I >
+ {
+ typedef I delegated_type;
+ };
+
+
+
+ namespace abstract {
+
template <typename I, typename E>
- struct image_identity: public abstract::image_entry<E>
+ struct image_identity : public abstract::image_entry<E>
{
protected:
Index: oln/core/abstract/data_storage.hh
--- oln/core/abstract/data_storage.hh (revision 50)
+++ oln/core/abstract/data_storage.hh (working copy)
@@ -30,15 +30,57 @@
# include <mlc/any.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
+
namespace oln {
+ // fwd decl
namespace abstract {
+ template <typename E> struct data_storage;
+ }
+ // category
+ template <typename E>
+ struct set_category< abstract::data_storage<E> > { typedef category::data_storage ret; };
+
+
+ template <typename type>
+ struct props_of < category::data_storage, type >
+ {
+ typedef mlc::true_type user_defined_;
+
+ mlc_decl_prop(category::data_storage, size_type);
+ mlc_decl_prop(category::data_storage, point_type);
+ mlc_decl_prop(category::data_storage, data_type);
+
+ static void echo(std::ostream& ostr)
+ {
+ ostr << "props_of( category::data_storage, "
+ << typeid(type).name() << " ) = {"
+ << " size_type = " << typeid(size_type).name()
+ << " point_type = " << typeid(point_type).name()
+ << " data_type = " << typeid(data_type).name() << " }" << std::endl;
+ }
+
+ };
+
+ mlc_register_prop(category::data_storage, size_type);
+ mlc_register_prop(category::data_storage, point_type);
+ mlc_register_prop(category::data_storage, data_type);
+
+
+ namespace abstract {
+
template <typename E>
struct data_storage : public mlc::any__best_speed<E>
{
+ // typedefs
+
+ typedef oln_type_of(E, size) size_type;
+ typedef oln_type_of(E, point) point_type;
+ typedef oln_type_of(E, data) data_type;
+
// abstract methods
bool has_data() const
@@ -54,12 +96,12 @@
postcondition(! this->has_data());
}
- const oln_size_type(E)& size() const
+ const size_type& size() const
{
return this->exact().impl_size();
}
- void resize(const oln_size_type(E)& s)
+ void resize(const size_type& s)
{
this->exact().impl_resize(s);
}
@@ -71,29 +113,28 @@
return this->exact().impl_npoints();
}
- bool hold(const oln_point_type(E)& p) const
+ bool hold(const point_type& p) const
{
if (! this->has_data())
return false;
return this->exact().impl_hold(p);
}
- const oln_data_type(E) get(const oln_point_type(E)& p) const
+ const data_type get(const point_type& p) const
{
precondition(this->has_data());
precondition(this->hold_large(p));
return this->exact().impl_get(p);
}
- void set(const oln_point_type(E)& p,
- const oln_data_type(E)& v)
+ void set(const point_type& p, const data_type& v)
{
precondition(this->has_data());
precondition(this->hold_large(p));
this->exact().impl_set(p, v);
}
- void set_data(const oln_data_type(E)& v)
+ void set_data(const data_type& v)
{
precondition(this->has_data());
this->exact().impl_set_data(v);
@@ -101,14 +142,14 @@
// polymorphic method with default
- bool hold_large(const oln_point_type(E)& p) const
+ bool hold_large(const point_type& p) const
{
if (! this->has_data())
return false;
return this->exact().impl_hold_large(p);
}
- bool impl_hold_large(const oln_point_type(E)& p) const
+ bool impl_hold_large(const point_type& p) const
{
return this->exact().impl_hold(p);
}
Index: oln/core/abstract/internal/image_impl.hh
--- oln/core/abstract/internal/image_impl.hh (revision 50)
+++ oln/core/abstract/internal/image_impl.hh (working copy)
@@ -30,8 +30,9 @@
# include <mlc/any.hh>
-# include <oln/core/macros.hh>
+# include <oln/core/properties.hh>
+
namespace oln {
namespace abstract {
@@ -45,7 +46,7 @@
// entry point:
template <typename A, typename E>
- struct get_image_impl : public get_image_impl_helper <A, oln_delegated_type(E), E>
+ struct get_image_impl : public get_image_impl_helper <A, oln_type_of(E, delegated), E>
{
};
@@ -67,7 +68,7 @@
template <typename E>
struct image_impl : public mlc::any__best_speed<E>
{
- typedef oln_delegated_type(E) D;
+ typedef oln_type_of(E, delegated) D;
D& delegate() { return this->exact().impl_delegate(); }
const D& delegate() const { return this->exact().impl_delegate(); }
};
Index: oln/core/abstract/op.hh
--- oln/core/abstract/op.hh (revision 50)
+++ oln/core/abstract/op.hh (working copy)
@@ -32,14 +32,28 @@
namespace oln {
+ // fwd decl
namespace abstract {
+ template <typename O, typename E> struct op;
+ }
- template <typename I, typename E>
- struct op : public oln::abstract::image_identity<I, E>
+ // category
+ template <typename O, typename E>
+ struct set_category< abstract::op<O,E> > { typedef category::image ret; };
+
+ // super_type
+ template <typename O, typename E>
+ struct set_super_type< abstract::op<O,E> > { typedef abstract::image_identity<O, E> ret; };
+
+
+ namespace abstract {
+
+ template <typename O, typename E>
+ struct op : public image_identity<O, E>
{
- typedef oln::abstract::image_identity<I, E> super_type;
+ typedef image_identity<O, E> super_type;
- op(I& ref): super_type(ref)
+ op(O& ref) : super_type(ref)
{
this->exact_ptr = (E*)(void*)(this);
}
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 50)
+++ oln/core/1d/array1d.hh (working copy)
@@ -36,13 +36,20 @@
namespace oln {
+ // fwd decl
template <typename T> struct array1d;
- template <typename T>
- struct category_type< array1d<T> > { typedef cat::data_storage ret; };
+ // category
+ template <typename T>
+ struct set_category< array1d<T> > { typedef category::data_storage ret; };
+ // super_type
+ template <typename T>
+ struct set_super_type< array1d<T> > { typedef abstract::data_storage< array1d<T> > ret; };
+
+ // props
template <typename T>
- struct props < cat::data_storage, array1d<T> > // FIXME: add inheritance
+ struct set_props < category::data_storage, array1d<T> > : public props_of<category::data_storage>
{
typedef size1d size_type;
typedef point1d point_type;
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 50)
+++ oln/core/1d/image1d.hh (working copy)
@@ -25,41 +25,44 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_IMAGE1D_HH
-# define OLENA_CORE_IMAGE1D_HH
+#ifndef OLENA_CORE_1D_IMAGE1D_HH
+# define OLENA_CORE_1D_IMAGE1D_HH
# include <mlc/traits.hh>
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/1d/array1d.hh>
+# include <oln/core/1d/fwd_piter1d.hh>
+
+
/*! \namespace oln
** \brief oln namespace.
*/
namespace oln {
+
// fwd decl
template <typename T> class image1d;
- // category decl
- template <typename T> struct category_type< image1d<T> > { typedef cat::image ret; };
+ // category
+ template <typename T>
+ struct set_category< image1d<T> > { typedef category::image ret; };
+ // super
+ template <typename T>
+ struct set_super_type < image1d<T> >
+ {
+ typedef abstract::image_with_data< image1d<T> > ret;
+ };
- /*! \class props< abstract::image, image1d<T> >
- **
- ** Properties of common 1D images. Specialization of props<abstraction,type>.
- ** Parameter T is the type of pixel values.
- **
- ** \see image1d<T>, props<category,type>
- */
template <typename T>
- struct props < cat::image, image1d<T> > : public default_props < cat::image >
+ struct set_props < category::image, image1d<T> > : public props_of<category::image>
{
- // intrusive properties
- typedef prop_of<abstract::readwrite_image> image_constness;
- typedef prop_of<abstract::image1d> image_dimension;
+ // intrusive property:
+ typedef is_a<abstract::image1d> image_dimension_type;
typedef mlc::no_type delegated_type;
@@ -67,14 +70,18 @@
typedef point1d point_type;
typedef T value_type;
+ typedef fwd_piter1d piter_type;
+ typedef fwd_piter1d fwd_piter_type;
+
// please note that value_storage_type means data_type
// since image1d is an image_with_data
- typedef mlc_encoding_type(T) value_storage_type;
+ typedef T value_storage_type;
+// typedef mlc_encoding_type(T) value_storage_type;
// please note that value_container_type means
// data_container_type (or value_storage_container_type)
// FIXME: find a better name...
- typedef array1d<value_storage_type> value_container_type;
+ typedef array1d<value_storage_type> storage_type;
// functions
@@ -83,11 +90,13 @@
{
typedef image1d<U> ret;
};
-
};
+
+
+
/*! \class image1d<T>
**
** Common class for 1D images. Pixels values are stored in memory.
@@ -126,4 +135,4 @@
} // end of namespace oln
-#endif // ! OLENA_CORE_IMAGE1D_HH
+#endif // ! OLENA_CORE_1D_IMAGE1D_HH
Index: oln/core/1d/fwd_piter1d.hh
--- oln/core/1d/fwd_piter1d.hh (revision 50)
+++ oln/core/1d/fwd_piter1d.hh (working copy)
@@ -33,22 +33,29 @@
# include <oln/core/abstract/piter.hh>
# include <oln/core/1d/point1d.hh>
# include <oln/core/1d/size1d.hh>
-# include <oln/core/props.hh>
namespace oln {
+
+ // fwd decl
struct fwd_piter1d;
- template <> struct category_type< fwd_piter1d > { typedef cat::piter ret; };
+ // category
+ template <>
+ struct set_category<fwd_piter1d> { typedef category::piter ret; };
+
+ // props
template <>
- struct props < cat::piter, fwd_piter1d > : public default_props< cat::piter >
+ struct set_props < category::piter, fwd_piter1d > : public props_of<category::piter>
{
typedef point1d point_type;
typedef size1d size_type;
};
+
+
struct fwd_piter1d : public abstract::piter< fwd_piter1d >
{
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 50)
+++ oln/core/1d/point1d.hh (working copy)
@@ -32,8 +32,7 @@
# include <oln/core/abstract/point.hh>
# include <oln/core/coord.hh>
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
+# include <oln/core/properties.hh>
// FIXME: doc
@@ -41,18 +40,27 @@
namespace oln {
+
struct point1d;
struct dpoint1d;
+ // category
template <>
- struct category_type< point1d > { typedef cat::point ret; };
+ struct set_category< point1d > { typedef category::point ret; };
+ // super_type
template <>
- struct props < cat::point, point1d > : default_props< cat::point >
+ struct set_super_type< point1d > { typedef abstract::point< point1d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::point, point1d > : public props_of<category::point>
{
typedef dpoint1d dpoint_type;
};
+
+
struct point1d : public abstract::point< point1d >
{
point1d()
Index: oln/core/coord.hh
--- oln/core/coord.hh (revision 50)
+++ oln/core/coord.hh (working copy)
@@ -44,6 +44,8 @@
public:
typedef int value_type;
+ static const value_type min_value = INT_MIN;
+ static const value_type max_value = INT_MAX;
coord_t() :
value_(undef_())
@@ -140,13 +142,13 @@
static const coord_t& infty()
{
- static coord_t infty_ = INT_MAX;
+ static coord_t infty_ = max_value;
return infty_;
}
static const coord_t& _infty()
{
- static coord_t _infty_ = INT_MIN + 1;
+ static coord_t _infty_ = min_value + 1;
return _infty_;
}
@@ -158,7 +160,7 @@
static const value_type undef_()
{
- return INT_MIN;
+ return min_value;
}
};
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 50)
+++ oln/core/2d/array2d.hh (working copy)
@@ -35,14 +35,20 @@
namespace oln {
+ // fwd decl
+ template <typename T> struct array2d;
- template <typename T> struct array2d;
+ // category
template <typename T>
- struct category_type< array2d<T> > { typedef cat::data_storage ret; };
+ struct set_category< array2d<T> > { typedef category::data_storage ret; };
-
+ // super_type
+ template <typename T>
+ struct set_super_type< array2d<T> > { typedef abstract::data_storage< array2d<T> > ret; };
+
+ // props
template <typename T>
- struct props < cat::data_storage, array2d<T> > // FIXME: add inheritance
+ struct set_props < category::data_storage, array2d<T> > : public props_of<category::data_storage>
{
typedef size2d size_type;
typedef point2d point_type;
@@ -50,6 +56,7 @@
};
+
template <typename T>
class array2d : public abstract::data_storage< array2d<T> >
{
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 50)
+++ oln/core/2d/image2d.hh (working copy)
@@ -35,6 +35,7 @@
# include <oln/core/2d/array2d.hh>
# include <oln/core/2d/fwd_piter2d.hh>
+
/*! \namespace oln
** \brief oln namespace.
*/
@@ -48,28 +49,28 @@
void do_read(abstract::image<I>&, const filename&);
}
+
+
// fwd decl
template <typename T> class image2d;
- // category decl
+ // category
template <typename T>
- struct category_type< image2d<T> > { typedef cat::image ret; };
+ struct set_category< image2d<T> > { typedef category::image ret; };
+ // super
+ template <typename T>
+ struct set_super_type < image2d<T> >
+ {
+ typedef abstract::image_with_data< image2d<T> > ret;
+ };
- /*! \class props< abstract::image, image2d<T> >
- **
- ** Properties of common 2D images. Specialization of props<abstraction,type>.
- ** Parameter T is the type of pixel values.
- **
- ** \see image2d<T>, props<category,type>
- */
template <typename T>
- struct props < cat::image, image2d<T> > : public default_props < cat::image >
+ struct set_props < category::image, image2d<T> > : public props_of<category::image>
{
- // intrusive properties
- typedef prop_of<abstract::readwrite_image> image_constness;
- typedef prop_of<abstract::image2d> image_dimension;
+ // intrusive property:
+ typedef is_a<abstract::image2d> image_dimension_type;
typedef mlc::no_type delegated_type;
@@ -82,12 +83,13 @@
// please note that value_storage_type means data_type
// since image2d is an image_with_data
- typedef mlc_encoding_type(T) value_storage_type;
+ typedef T value_storage_type;
+// typedef mlc_encoding_type(T) value_storage_type;
// please note that value_container_type means
// data_container_type (or value_storage_container_type)
// FIXME: find a better name...
- typedef array2d<value_storage_type> value_container_type;
+ typedef array2d<value_storage_type> storage_type;
// functions
@@ -96,11 +98,12 @@
{
typedef image2d<U> ret;
};
-
};
+
+
/*! \class image2d<T>
**
** Common class for 2D images. Pixels values are stored in memory.
Index: oln/core/2d/fwd_piter2d.hh
--- oln/core/2d/fwd_piter2d.hh (revision 50)
+++ oln/core/2d/fwd_piter2d.hh (working copy)
@@ -33,22 +33,28 @@
# include <oln/core/abstract/piter.hh>
# include <oln/core/2d/point2d.hh>
# include <oln/core/2d/size2d.hh>
-# include <oln/core/props.hh>
namespace oln {
+ // fwd decl
struct fwd_piter2d;
- template <> struct category_type<fwd_piter2d> { typedef cat::piter ret; };
+ // category
+ template <>
+ struct set_category<fwd_piter2d> { typedef category::piter ret; };
+
+ // props
template <>
- struct props < cat::piter, fwd_piter2d > : public default_props<cat::piter>
+ struct set_props < category::piter, fwd_piter2d > : public props_of<category::piter>
{
typedef point2d point_type;
typedef size2d size_type;
};
+
+
struct fwd_piter2d : public abstract::piter< fwd_piter2d >
{
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 50)
+++ oln/core/2d/point2d.hh (working copy)
@@ -30,10 +30,9 @@
# include <iostream>
+# include <oln/core/properties.hh>
# include <oln/core/abstract/point.hh>
# include <oln/core/coord.hh>
-# include <oln/core/cats.hh>
-# include <oln/core/props.hh>
// FIXME: doc!
@@ -43,15 +42,23 @@
struct point2d;
struct dpoint2d;
+ // category
template <>
- struct category_type< point2d > { typedef cat::point ret; };
+ struct set_category< point2d > { typedef category::point ret; };
+ // super_type
template <>
- struct props < cat::point, point2d > : default_props< cat::point >
+ struct set_super_type< point2d > { typedef abstract::point< point2d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::point, point2d > : public props_of<category::point>
{
typedef dpoint2d dpoint_type;
};
+
+
struct point2d : public abstract::point< point2d >
{
point2d()
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 50)
+++ oln/core/3d/array3d.hh (working copy)
@@ -36,13 +36,20 @@
namespace oln {
+ // fwd decl
template <typename T> struct array3d;
+
+ // category
template <typename T>
- struct category_type< array3d<T> > { typedef cat::data_storage ret; };
+ struct set_category< array3d<T> > { typedef category::data_storage ret; };
-
+ // super_type
+ template <typename T>
+ struct set_super_type< array3d<T> > { typedef abstract::data_storage< array3d<T> > ret; };
+
+ // props
template <typename T>
- struct props < cat::data_storage, array3d<T> > // FIXME: add inheritance
+ struct set_props < category::data_storage, array3d<T> > : public props_of<category::data_storage>
{
typedef size3d size_type;
typedef point3d point_type;
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 50)
+++ oln/core/3d/image3d.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_IMAGE3D_HH
-# define OLENA_CORE_IMAGE3D_HH
+#ifndef OLENA_CORE_3D_IMAGE3D_HH
+# define OLENA_CORE_3D_IMAGE3D_HH
# include <mlc/traits.hh>
@@ -39,28 +39,27 @@
namespace oln {
+
// fwd decl
template <typename T> class image3d;
- // category decl
- template <typename T>
- struct category_type< image3d<T> > { typedef cat::image ret; };
+ // category
+ template <typename T>
+ struct set_category< image3d<T> > { typedef category::image ret; };
+ // super
+ template <typename T>
+ struct set_super_type < image3d<T> >
+ {
+ typedef abstract::image_with_data< image3d<T> > ret;
+ };
- /*! \class props< abstract::image, image3d<T> >
- **
- ** Properties of common 3D images. Specialization of props<abstraction,type>.
- ** Parameter T is the type of pixel values.
- **
- ** \see image3d<T>, props<category,type>
- */
template <typename T>
- struct props < cat::image, image3d<T> > : public default_props < cat::image >
+ struct set_props < category::image, image3d<T> > : public props_of<category::image>
{
- // intrusive properties
- typedef prop_of<abstract::readwrite_image> image_constness;
- typedef prop_of<abstract::image3d> image_dimension;
+ // intrusive property:
+ typedef is_a<abstract::image3d> image_dimension_type;
typedef mlc::no_type delegated_type;
@@ -68,14 +67,18 @@
typedef point3d point_type;
typedef T value_type;
+// typedef fwd_piter3d piter_type;
+// typedef fwd_piter3d fwd_piter_type;
+
// please note that value_storage_type means data_type
// since image3d is an image_with_data
- typedef mlc_encoding_type(T) value_storage_type;
+ typedef T value_storage_type;
+// typedef mlc_encoding_type(T) value_storage_type;
// please note that value_container_type means
// data_container_type (or value_storage_container_type)
// FIXME: find a better name...
- typedef array3d<value_storage_type> value_container_type;
+ typedef array3d<value_storage_type> storage_type;
// functions
@@ -84,7 +87,6 @@
{
typedef image3d<U> ret;
};
-
};
@@ -127,4 +129,4 @@
} // end of namespace oln
-#endif // ! OLENA_CORE_IMAGE3D_HH
+#endif // ! OLENA_CORE_3D_IMAGE3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 50)
+++ oln/core/3d/point3d.hh (working copy)
@@ -35,14 +35,21 @@
namespace oln {
- struct dpoint3d; // FIXME: not implemented!!
+
struct point3d;
+ struct dpoint3d;
+ // category
template <>
- struct category_type< point3d > { typedef cat::point ret; };
+ struct set_category< point3d > { typedef category::point ret; };
+ // super_type
template <>
- struct props < cat::point, point3d > : default_props< cat::point >
+ struct set_super_type< point3d > { typedef abstract::point< point3d > ret; };
+
+ // props
+ template <>
+ struct set_props < category::point, point3d > : public props_of<category::point>
{
typedef dpoint3d dpoint_type;
};
Index: oln/core/cats.hh
--- oln/core/cats.hh (revision 50)
+++ oln/core/cats.hh (working copy)
@@ -1,79 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_CATS_HH
-# define OLENA_CORE_CATS_HH
-
-# include <mlc/types.hh>
-
-
-/*! \macro FIXME:doc
-*/
-
-# define oln_category_type(T) typename oln::category_type<T>::ret
-
-
-
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
-
-
- /*! \class category_type<T>
- **
- ** FIXME: doc
- **
- */
- template <typename T>
- struct category_type
- {
- typedef mlc::undefined_type ret;
- };
-
-
- /*! \namespace oln::cat
- ** \brief oln::cat namespace.
- */
- namespace cat {
-
- struct image;
- struct data_storage;
- struct piter;
- struct point;
- struct size;
- // FIXME:...
-
- } // end of namespace oln::cat
-
-
-} // end of namespace oln
-
-
-
-
-#endif // ! OLENA_CORE_CATS_HH
Index: oln/core/properties.hh
--- oln/core/properties.hh (revision 0)
+++ oln/core/properties.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_PROPERTIES_HH
+# define OLENA_CORE_PROPERTIES_HH
+
+# include <mlc/properties.hh>
+
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln
+{
+
+ namespace category
+ {
+ struct data_storage;
+ struct image;
+ struct point;
+ struct size;
+ struct piter;
+ struct niter;
+ // FIXME: ...
+ }
+
+ namespace target
+ {
+ struct data_type;
+ struct value_type;
+ struct value_storage_type;
+ struct storage_type;
+ struct point_type;
+ struct dpoint_type;
+ struct fwd_piter_type;
+ struct iter_type;
+ struct delegated_type;
+ struct size_type;
+
+ struct image_constness_type;
+ struct image_dimension_type;
+ // FIXME: ...
+ }
+
+ mlc_equip_namespace_for_properties();
+
+
+ // FIXME: change name?
+ template <template <typename> class abstraction>
+ struct is_a // abstraction
+ {
+ template <typename E>
+ struct instantiated_with // E
+ {
+ typedef abstraction<E> ret;
+ };
+ };
+
+
+} // end of namespace oln
+
+
+
+/// macro to retrieve a type (TARGET) from a class (oln::TYPE)
+
+# define oln_type_of(TYPE, TARGET) mlc_type_of(oln, TYPE, TARGET)
+# define oln_type_of_(TYPE, TARGET) mlc_type_of_(oln, TYPE, TARGET)
+
+
+
+#endif // ! OLENA_CORE_PROPERTIES_HH
1
0
dsl... (connection refused!)
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
* mlc/types.hh (default_type): New.
* mlc/properties.hh: New.
1
0
Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* configure.ac: Add test suite `main' for Integre.
configure.ac | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
Index: configure.ac
--- configure.ac (revision 48)
+++ configure.ac (working copy)
@@ -164,7 +164,7 @@
metalic/tests/check/defs],
[dnl Configuration for the testsuite
- MLC_TESTS_SUBDIRS=""
+ MLC_TESTS_SUBDIRS="main"
AC_CACHE_CHECK([for selection of tests],
[mlc_cv_tests_selection],
@@ -177,6 +177,7 @@
# MLC_TESTS defined in oln-local.m4
+ MLC_TESTS([main])
MLC_TESTS([sanity])
AC_SUBST([MLC_TESTS_SUBDIRS])
3
2
Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* mlc/is_a.hh: New. Test inheritance between two classes.
* tests/main/tests/is_a1: New. Add test for `is_a'.
* tests/main: New. Add new test suite `main'.
* tests/main/tests: New.
* tests/main/Makefile.am: New.
mlc/is_a.hh | 193 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/main/Makefile.am | 3
tests/main/tests/is_a1 | 33 ++++++++
3 files changed, 229 insertions(+)
Index: tests/main/tests/is_a1
--- tests/main/tests/is_a1 (revision 0)
+++ tests/main/tests/is_a1 (revision 0)
@@ -0,0 +1,33 @@
+#include <mlc/bool.hh>
+#include <mlc/is_a.hh>
+
+using namespace mlc;
+
+class A {};
+class B : public A {};
+class C : public B {};
+
+template <class E> class T_A {};
+template <class T> class T_B : public T_A<T> {};
+
+template <class T>
+void foo()
+{
+ is_false<mlc_is_a(int, bool)::ret>::ensure();
+ is_true<mlc_is_a(B, A)::ret>::ensure();
+ is_true<mlc_is_a(C, A)::ret>::ensure();
+ is_false<mlc_is_a(A, B)::ret>::ensure();
+}
+
+int main()
+{
+ is_false<mlc_is_a_(int, bool)::ret>::ensure();
+ is_true<mlc_is_a_(B, A)::ret>::ensure();
+ is_true<mlc_is_a_(C, A)::ret>::ensure();
+ is_false<mlc_is_a_(A, B)::ret>::ensure();
+
+ is_true<mlc_is_a_(T_B<int>, T_A)::ret>::ensure();
+ is_false<mlc_is_a_(T_A<int>, T_B)::ret>::ensure();
+
+ foo<int>();
+}
Index: tests/main/Makefile.am
--- tests/main/Makefile.am (revision 0)
+++ tests/main/Makefile.am (revision 0)
@@ -0,0 +1,3 @@
+## Process this file with Automake to produce Makefile.in -*- Makefile -*-
+
+include ../check/Makefile.runtests
Index: mlc/is_a.hh
--- mlc/is_a.hh (revision 0)
+++ mlc/is_a.hh (revision 0)
@@ -0,0 +1,193 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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, 59 Temple Place - Suite 330, 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 METALIC_IS_A_HH
+# define METALIC_IS_A_HH
+
+# include <mlc/any.hh>
+# include <mlc/bool.hh>
+
+// private macro so do _not_ use it
+# define is_a__check_result_ \
+sizeof(helper<T ,U >::check( (T *) helper<T,U >::makeT() )) \
+== sizeof(mlc::internal::yes_)
+
+
+namespace mlc
+{
+
+ namespace internal
+ {
+
+ //
+ // wrap
+ //
+ // FIXME: This type is a workaround for g++-2.95 problem with implicit
+ // typename in <foo<T>::ret::dim>,
+ // write <wrap<typename foo<T>::ret>::dim instead.
+ //
+
+ template <class T> struct wrap : public T {};
+
+ } // internal
+
+ /*-----.
+ | is_a |
+ `-----*/
+
+ // FIXME: form is a namespace to avoid g++-3.2 bug with template function
+ // overloading in class.
+
+ namespace form
+ {
+ enum {
+ class_ = 1,
+ template_l_class_g_class_ = 2,
+ template_l_class_class_g_class_ = 3
+ // template_l_unsigned_class_g_class_ = 4
+ // ...
+ };
+
+ template<unsigned id>
+ struct desc
+ { char dummy[id]; };
+
+ template<class T>
+ static desc< class_ > get();
+
+ template<template<class> class T>
+ static desc< template_l_class_g_class_ > get();
+
+ template<template<class,class> class T>
+ static desc< template_l_class_class_g_class_ > get();
+
+ // template<template<unsigned,class> class T>
+ // static desc < template_l_unsigned_class_g_class_ > get();
+
+ // ...
+ }
+
+ namespace internal
+ {
+
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+
+ // dev note : below, is_a_<T,id> is a better factorization
+ // but g++ 2.95.4 has some trouble with it
+
+ template<unsigned id>
+ struct is_a_;
+
+ // _class_
+
+
+ template<>
+ struct is_a_< form::class_ >
+ {
+ typedef is_a_< form::class_ > self;
+
+ template<class T, class U>
+ struct helper
+ {
+ static yes_ check(U*);
+ static no_ check(...);
+ static T* makeT();
+ };
+
+ template<class T, class U>
+ struct check
+ : public mlc::returns_bool_<( is_a__check_result_ )>
+ {
+ };
+ };
+
+ // template_l_class_g_class_
+
+ template<>
+ struct is_a_< form::template_l_class_g_class_ >
+ {
+ typedef is_a_< form::template_l_class_g_class_ > self;
+
+ template<class T, template<class> class U>
+ struct helper
+ {
+ template<class V>
+ static yes_ check(U<V>*);
+ static no_ check(...);
+ static T* makeT();
+ };
+
+ template<class T, template<class> class U>
+ struct check
+ : public mlc::returns_bool_<( is_a__check_result_ )>
+ {
+ };
+ };
+
+ // templatee_l_class_class_g_class_
+
+ template<>
+ struct is_a_< form::template_l_class_class_g_class_ >
+ {
+ typedef is_a_< form::template_l_class_class_g_class_ > self;
+
+ template<class T, template<class,class> class U>
+ struct helper
+ {
+ template<class V, class W>
+ static yes_ check(U<V,W>*);
+ static no_ check(...);
+ static T* makeT();
+ };
+
+ template<class T, template<class,class> class U>
+ struct check
+ : public mlc::returns_bool_<( is_a__check_result_ )>
+ {};
+ };
+
+ } // end of internal
+
+} // end of mlc
+
+// private macros: do _not_ use them
+# define is_a__2nd_is_meta(T,U) mlc::internal::is_a_< id_of_typeform(U) >::check<T, U >
+
+// client macros
+
+# define id_of_typeform(T) sizeof(mlc::form::get<T >())
+
+template <class T>
+struct id_ { typedef T ret; };
+
+// FIXME: can we get rid of mlc::wrap ?
+# define mlc_is_a(T, U) mlc::internal::wrap<typename mlc::internal::is_a_< id_of_typeform(U) >::check<T, U > >
+# define mlc_is_a_(T, U) mlc::internal::wrap<mlc::internal::is_a_< id_of_typeform(U) >::check<T, U > >
+
+#endif // ndef METALIC_IS_A_HH
1
0
08 Mar '05
https://svn.lrde.epita.fr/svn/oln/prototypes/proto-1.0
ChangeLog | 6 ++++++
oln/core/abstract/image_with_data.hh | 5 +++++
2 files changed, 11 insertions(+)
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* oln/core/abstract/image_with_data.hh (impl_size, impl_npoints)
(impl_hold, impl_get, impl_set): Ensure that the image contains
data.
Index: olena/oln/core/abstract/image_with_data.hh
--- olena/oln/core/abstract/image_with_data.hh (revision 46)
+++ olena/oln/core/abstract/image_with_data.hh (working copy)
@@ -70,6 +70,7 @@
const oln_size_type(E)& impl_size() const
{
+ precondition(this->has_data());
return this->data_->size();
}
@@ -83,6 +84,7 @@
unsigned long impl_npoints() const
{
+ precondition(this->has_data());
return this->data_->npoints();
}
@@ -97,6 +99,7 @@
bool impl_hold(const oln_point_type(E)& p) const
{
+ precondition(this->has_data());
return this->data_->hold(p);
}
@@ -110,6 +113,7 @@
const oln_value_type(E) impl_get(const oln_point_type(E)& p) const
{
+ precondition(this->has_data());
return this->data_->get(p);
}
@@ -121,6 +125,7 @@
template <typename V>
void impl_set(const oln_point_type(E)& p, const V& v)
{
+ precondition(this->has_data());
this->data_->set(p, v);
}
1
0
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* ntg/real/int_u8.hh: Add i/o support.
* ntg/real/integer.hh: Likewise.
* ntg/enum/enum.hh: Likewise.
* ntg/enum/bin.hh: Likewise.
* ntg/core/macros.hh: Likewise.
* ntg/color/rgb_8.hh: Likewise.
* ntg/color/color.hh: Likewise.
color/color.hh | 12 ++++++++++++
color/rgb_8.hh | 32 +++++++++++++++++++++++++++++++-
core/macros.hh | 6 +++++-
enum/bin.hh | 3 ++-
enum/enum.hh | 3 ++-
real/int_u8.hh | 11 +++++++++--
real/integer.hh | 5 +++--
7 files changed, 64 insertions(+), 8 deletions(-)
Index: ntg/real/int_u8.hh
--- ntg/real/int_u8.hh (revision 35)
+++ ntg/real/int_u8.hh (working copy)
@@ -44,7 +44,8 @@
template <>
struct props<cat::integer, int_u8> : public default_props<cat::integer>
{
- enum { ntg_max_val = 255 };
+ enum { max_val = 255 };
+ typedef char io_type;
};
@@ -71,6 +72,12 @@
return *this;
}
+ int_u8& impl_assign(const unsigned char& rhs)
+ {
+ this->value_ = rhs;
+ return *this;
+ }
+
operator unsigned char() const
{
return value_;
@@ -110,7 +117,7 @@
template <>
struct traits < ntg::int_u8 >
{
- typedef char encoding_type;
+ typedef unsigned char encoding_type;
};
} // end of namespace mlc
Index: ntg/real/integer.hh
--- ntg/real/integer.hh (revision 35)
+++ ntg/real/integer.hh (working copy)
@@ -44,7 +44,8 @@
template <>
struct default_props < cat::integer >
{
- enum { ntg_max_val = 0 };
+ enum { max_val = 0 };
+ typedef mlc::no_type io_type;
protected:
default_props() {}
@@ -58,7 +59,7 @@
template <typename V>
exact_type& operator=(const V& rhs)
{
- return this->exact.impl_assign(rhs);
+ return this->exact().impl_assign(rhs);
}
template <typename V>
Index: ntg/enum/enum.hh
--- ntg/enum/enum.hh (revision 35)
+++ ntg/enum/enum.hh (working copy)
@@ -44,6 +44,7 @@
struct default_props < cat::enum_value >
{
enum { max_val = 0 };
+ typedef mlc::no_type io_type;
protected:
default_props() {}
@@ -57,7 +58,7 @@
template <typename V>
exact_type& operator=(const V& rhs)
{
- return this->exact.impl_assign(rhs);
+ return this->exact().impl_assign(rhs);
}
template <typename V>
Index: ntg/enum/bin.hh
--- ntg/enum/bin.hh (revision 35)
+++ ntg/enum/bin.hh (working copy)
@@ -45,7 +45,8 @@
template <>
struct props<cat::enum_value, bin> : public default_props<cat::enum_value>
{
- enum { max_val = 255 };
+ enum { max_val = 1 };
+ typedef unsigned char io_type;
};
struct bin : public enum_value<bin>
Index: ntg/core/macros.hh
--- ntg/core/macros.hh (revision 35)
+++ ntg/core/macros.hh (working copy)
@@ -28,8 +28,12 @@
#ifndef INTEGRE_CORE_MACROS_HH
# define INTEGRE_CORE_MACROS_HH
-# define ntg_max_val(T) ntg::props<ntg_category_type(T),T>::ntg_max_val
+# define ntg_max_val(T) ntg::props<ntg_category_type(T),T>::max_val
# define ntg_nb_comp(T) ntg::props<ntg_category_type(T),T>::nb_comp
+# define ntg_comp_type(T) typename ntg::props<ntg_category_type(T),T>::comp_type
+
+# define ntg_io_type(T) typename ntg::props<ntg_category_type(T),T>::io_type
+
#endif // ! INTEGRE_CORE_MACROS_HH
Index: ntg/color/rgb_8.hh
--- ntg/color/rgb_8.hh (revision 35)
+++ ntg/color/rgb_8.hh (working copy)
@@ -47,6 +47,7 @@
enum { max_val = 255 };
enum { nb_comp = 3 };
+ typedef char io_type;
typedef unsigned char comp_type;
};
@@ -66,6 +67,12 @@
this->value_[rgb_blue] = 0;
}
+ rgb_8(const unsigned char init[3])
+ {
+ for (unsigned i = 0; i < 3; i++)
+ value_[i] = init[i];
+ }
+
rgb_8(unsigned char red,
unsigned char green,
unsigned char blue)
@@ -104,8 +111,19 @@
this->value_[rgb_blue] != rhs.blue();
}
+ unsigned char& impl_op_sqbr(unsigned int i)
+ {
+ assert(i < 3);
+ return value_[i];
+ }
+ const unsigned char impl_op_sqbr(unsigned int i) const
+ {
+ assert(i < 3);
+ return value_[i];
+ }
+
unsigned char& red()
{
return value_[rgb_red];
@@ -145,13 +163,25 @@
} // end of namespace ntg
+# include <ostream>
+std::ostream& operator<<(std::ostream& ostr, const ntg::rgb_8& to_print)
+{
+ ostr << "(" << unsigned(to_print[0])
+ << "," << unsigned(to_print[1])
+ << "," << unsigned(to_print[2])
+ << ")";
+ return ostr;
+}
+
+
+
namespace mlc {
template <>
struct traits < ntg::rgb_8 >
{
- typedef unsigned char* encoding_type;
+ typedef ntg::rgb_8 encoding_type;
};
} // end of namespace mlc
Index: ntg/color/color.hh
--- ntg/color/color.hh (revision 35)
+++ ntg/color/color.hh (working copy)
@@ -49,6 +49,7 @@
enum { max_val = 0 };
enum { nb_comp = 0 };
typedef mlc::undefined_type comp_type;
+ typedef mlc::undefined_type io_type;
protected:
@@ -59,6 +60,7 @@
struct color : public mlc::any__best_memory<E>
{
typedef E exact_type;
+ typedef typename props<cat::color, E>::comp_type comp_type;
E& operator=(const exact_type& rhs)
{
@@ -75,6 +77,16 @@
return this->exact().impl_not_eq(rhs);
}
+ comp_type& operator [](const unsigned int &i)
+ {
+ return this->exact().impl_op_sqbr(i);
+ }
+
+ const comp_type operator [](const unsigned int &i) const
+ {
+ return this->exact().impl_op_sqbr(i);
+ }
+
protected:
color() {}
};
1
0
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* oln/io/write_image_2d_pnm.hh: Add ppm and pbm output methods.
* oln/io/read_image_2d_pnm.hh: Add ppm and pbm input methods.
* oln/io/utils.hh: Fix an error occuring when writing pbm headers.
* oln/core/abstract/image_with_data.hh: Remove an unexpected `return'.
* oln/core/2d/image2d.hh: Fix circular inclusion problem.
core/2d/image2d.hh | 8 +
core/abstract/image_with_data.hh | 4
io/read_image_2d_pnm.hh | 163 +++++++++++++++++++++++++++++++--------
io/utils.hh | 8 -
io/write_image_2d_pnm.hh | 102 ++++++++++++++++++++++--
6 files changed, 242 insertions(+), 45 deletions(-)
Index: oln/io/write_image_2d_pnm.hh
--- oln/io/write_image_2d_pnm.hh (revision 44)
+++ oln/io/write_image_2d_pnm.hh (working copy)
@@ -53,16 +53,16 @@
namespace impl {
template <typename I>
- struct write_image_2d_pgm_raw
- : public oln::abstract::void_op<write_image_2d_pgm_raw<I> >
+ struct write_image_2d_raw
+ : public oln::abstract::void_op<write_image_2d_raw<I> >
{
typedef oln_value_type(I) value_type;
- typedef typename mlc::traits<value_type>::encoding_type out_type;
+ typedef ntg_io_type(value_type) io_type;
const I& to_write_;
std::ofstream& ostr_;
- write_image_2d_pgm_raw(const I& to_write, std::ofstream& ostr):
+ write_image_2d_raw(const I& to_write, std::ofstream& ostr):
to_write_(to_write),
ostr_(ostr)
{}
@@ -70,19 +70,57 @@
void impl_run()
{
point2d p;
- out_type c;
+ value_type c;
+ bool b;
for (p.row() = 0; p.row() < to_write_.size().nrows(); ++p.row())
for (p.col() = 0; p.col() < to_write_.size().ncols(); ++p.col())
{
c = to_write_[p];
- ostr_ << c;
+ b = write_value_type(c);
}
+ while (b == false)
+ b = write_value_type(c);
ostr_.close();
}
+ bool write_value_type(const ntg::integer<value_type> &c)
+ {
+ ostr_ << (io_type)(c.exact());
+ return true;
+ }
+
+ bool write_value_type(const ntg::color<value_type> &c)
+ {
+ assert ((ntg_nb_comp(value_type) == 3));
+
+ for (unsigned i = 0; i < 3; i++)
+ ostr_ << (io_type)(c[i]);
+ return true;
+ }
+
+ bool write_value_type(const ntg::enum_value<value_type> &c)
+ {
+ assert ((ntg_max_val(value_type) == 1));
+ static int offset = 7;
+ static unsigned char v = 0;
+ bool ret = false;
+
+ if (offset == -1)
+ {
+ ostr_ << v;
+ offset = 7;
+ v = 0;
+ ret = true;
+ }
+ if (c == 1)
+ v |= 1 << offset;
+ offset--;
+ return ret;
+ }
};
+
template <typename I, typename T>
void write(const abstract::image2d<I>& to_write,
const ntg::integer<T>&,
@@ -98,7 +136,7 @@
s.ncols(), s.nrows(),
ntg_max_val(T)))
{
- write_image_2d_pgm_raw<I> tmp(to_write.exact(), ostr);
+ write_image_2d_raw<I> tmp(to_write.exact(), ostr);
tmp.run();
}
else
@@ -108,6 +146,56 @@
<< " file extension (`" << ext << "')" << std::endl;
}
+ template <typename I, typename T>
+ void write(const abstract::image2d<I>& to_write,
+ const ntg::color<T>&,
+ const std::string& name,
+ const std::string& ext)
+ {
+ std::ofstream ostr;
+ point2d p;
+ size2d s = to_write.size();
+
+ if (ext == "ppm")
+ if (internal::write_pnm_header(ostr, name, "P6",
+ s.ncols(), s.nrows(),
+ ntg_max_val(T)))
+ {
+ write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+ tmp.run();
+ }
+ else
+ std::cerr << "error: unable to write header" << std::endl;
+ else
+ std::cerr << "error: image data type (`color') does not match"
+ << " file extension (`" << ext << "')" << std::endl;
+ }
+
+ template <typename I, typename T>
+ void write(const abstract::image2d<I>& to_write,
+ const ntg::enum_value<T>&,
+ const std::string& name,
+ const std::string& ext)
+ {
+ std::ofstream ostr;
+ point2d p;
+ size2d s = to_write.size();
+
+ if (ext == "pbm")
+ if (internal::write_pnm_header(ostr, name, "P4",
+ s.ncols(), s.nrows(),
+ ntg_max_val(T)))
+ {
+ write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+ tmp.run();
+ }
+ else
+ std::cerr << "error: unable to write header" << std::endl;
+ else
+ std::cerr << "error: image data type (`enum_value') does not match"
+ << " file extension (`" << ext << "')" << std::endl;
+ }
+
}
}
Index: oln/io/read_image_2d_pnm.hh
--- oln/io/read_image_2d_pnm.hh (revision 44)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -28,27 +28,56 @@
namespace impl {
+ template <typename I>
+ struct read_image_2d_raw;
+ }
+
+ }
+
+ template <typename I>
+ struct category_type< io::impl::read_image_2d_raw<I> >
+ {
+ typedef cat::image ret;
+ };
+
+ template <typename I>
+ struct props <cat::image, io::impl::read_image_2d_raw<I> >
+ : public props<cat::image, I>
+ {
+ typedef I delegated_type;
+ };
+
+
+
+ namespace io {
+
+ namespace impl {
+
template <typename I>
- struct read_image_2d_pgm_raw:
- oln::abstract::void_op<read_image_2d_pgm_raw<I> >
+ struct read_image_2d_raw:
+ oln::abstract::op<I, read_image_2d_raw<I> >
{
+
+ typedef oln::abstract::op<I, read_image_2d_raw<I> > super_type;
+ typedef oln_value_type(I) value_type;
+ typedef ntg_io_type(value_type) io_type;
+
mlc::box<I> image_;
std::ifstream& istr_;
internal::pnm_info& info_;
- read_image_2d_pgm_raw(I& image,
- std::ifstream &istr,
- internal::pnm_info &info) :
+ read_image_2d_raw(I& image,
+ std::ifstream &istr,
+ internal::pnm_info &info) :
+ super_type(image),
image_(image),
istr_(istr),
info_(info)
{}
- typedef oln_value_type(I) value_type;
- typedef typename mlc::traits<value_type>::encoding_type encoding_type;
- read_image_2d_pgm_raw<I>& output(I& output)
+ read_image_2d_raw<I>& output(I& output)
{
output = *image_;
return *this;
@@ -56,7 +85,9 @@
void impl_run()
{
- encoding_type c;
+ value_type c;
+ point2d p;
+ oln::image2d<value_type> tmp(info_.rows, info_.cols);
if (info_.max_val > ntg_max_val(value_type))
{
@@ -64,26 +95,57 @@
<< std::endl;
return;
}
- point2d p;
- oln::image2d<value_type> tmp(info_.rows, info_.cols);
- std::cout << info_.cols << "," << info_.rows << ","
- << info_.max_val << std::endl;
-
-
for (p.row() = 0; p.row() < info_.rows && !istr_.eof(); ++p.row())
for (p.col() = 0; p.col() < info_.cols && !istr_.eof(); ++p.col())
{
- istr_.read(&c, sizeof (encoding_type));
+ read_value_type(c);
tmp[p] = c;
}
istr_.close();
*image_ = tmp;
- std::cout << "debug : size = " << image_->size() << std::endl;
}
+
+ void read_value_type(ntg::integer<value_type> &c)
+ {
+ io_type v;
+ istr_.read(&v, sizeof (io_type));
+ c = v;
+ }
+
+ void read_value_type(ntg::color<value_type> &c)
+ {
+ assert((ntg_nb_comp(value_type) == 3));
+ io_type v;
+
+ for (unsigned i = 0; i < 3; i++)
+ {
+ istr_.read(&v, sizeof (v));
+ c[i] = v;
+ }
+ }
+
+ void read_value_type(ntg::enum_value<value_type> &c)
+ {
+ static io_type v;
+ static int offset = -1;
+
+ if (offset == -1)
+ {
+ istr_.read((char *)(&v), sizeof (v));
+ offset = 7;
+ }
+ if ((int)(v & (1<<offset--)) == 0)
+ c = 0;
+ else
+ c = 1;
+ }
+
+
};
+
template <typename I, typename T>
void read(abstract::image2d<I>& ima,
const ntg::integer<T>&,
@@ -97,27 +159,25 @@
if (ext == "pgm")
if (info.type == "P5")
{
- read_image_2d_pgm_raw<I> tmp(ima.exact(), istr, info);
+ read_image_2d_raw<I> tmp(ima.exact(), istr, info);
tmp.run();
tmp.output(ima.exact());
}
+ else if (info.type == "P2")
+ std::cerr << "error: read_image_2d_pgm_ascii not implemented"
+ << std::endl;
else
- if (info.type == "P2")
- std::cerr << "error: read_image_2d_pgm_ascii not implemented"
- << std::endl;
- else
- std::cerr << "error: file header (`" << info.type
- << "') does not match file extension (`"
- << ext << "')" << std::endl;
+ std::cerr << "error: file header (`" << info.type
+ << "') does not match file extension (`"
+ << ext << "')" << std::endl;
else
std::cerr << "error: image data type (`integer') does not match"
<< " file extension (`" << ext << "')" << std::endl;
else
std::cerr << "error: unable to get a valid header" << std::endl;
- std::cout << "debug : size = " << ima.size() << std::endl;
+ }
- }
template <typename I, typename T>
void read(abstract::image2d<I>& ima,
@@ -125,7 +185,29 @@
const std::string& filename,
const std::string& ext)
{
- std::cout << "read for image2d<color>" << std::endl;
+ std::ifstream istr;
+ internal::pnm_info info;
+
+ if (internal::read_pnm_header(istr, info, filename))
+ if (ext == "ppm")
+ if (info.type == "P6")
+ {
+ read_image_2d_raw<I> tmp(ima.exact(), istr, info);
+ tmp.run();
+ tmp.output(ima.exact());
+ }
+ else if (info.type == "P3")
+ std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+ << std::endl;
+ else
+ std::cerr << "error: file header (`" << info.type
+ << "') does not match file extension (`"
+ << ext << "')" << std::endl;
+ else
+ std::cerr << "error: image data type (`color') does not match"
+ << " file extension (`" << ext << "')" << std::endl;
+ else
+ std::cerr << "error: unable to get a valid header" << std::endl;
}
template <typename I, typename T>
@@ -134,10 +216,31 @@
const std::string& filename,
const std::string& ext)
{
- std::cout << "read for image2d<enum>" << std::endl;
+ std::ifstream istr;
+ internal::pnm_info info;
+
+ if (internal::read_pnm_header(istr, info, filename))
+ if (ext == "pbm")
+ if (info.type == "P4")
+ {
+ read_image_2d_raw<I> tmp(ima.exact(), istr, info);
+ tmp.run();
+ tmp.output(ima.exact());
+ }
+ else if (info.type == "P1")
+ std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+ << std::endl;
+ else
+ std::cerr << "error: file header (`" << info.type
+ << "') does not match file extension (`"
+ << ext << "')" << std::endl;
+ else
+ std::cerr << "error: image data type (`enum_value') does not match"
+ << " file extension (`" << ext << "')" << std::endl;
+ else
+ std::cerr << "error: unable to get a valid header" << std::endl;
}
-
}
}
Index: oln/io/utils.hh
--- oln/io/utils.hh (revision 44)
+++ oln/io/utils.hh (working copy)
@@ -160,11 +160,11 @@
return false;
}
-
- ostr << "P5" << std::endl
+ ostr << type << std::endl
<< "# Olena 1.0" << std::endl
- << ncols << " " << nrows << std::endl
- << max_val << std::endl;
+ << ncols << " " << nrows << std::endl;
+ if (type != "P1" && type != "P4")
+ ostr << max_val << std::endl;
return true;
}
Index: oln/core/abstract/image_with_data.hh
--- oln/core/abstract/image_with_data.hh (revision 44)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -121,7 +121,7 @@
template <typename V>
void impl_set(const oln_point_type(E)& p, const V& v)
{
- return this->data_->set(p, v);
+ this->data_->set(p, v);
}
/*! \brief True if the image contains data.
@@ -130,8 +130,8 @@
{
return data_ != 0;
}
-
+
protected:
/*! \brief Constructor (protected) with no memory allocation for
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 44)
+++ oln/core/2d/image2d.hh (working copy)
@@ -34,14 +34,20 @@
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/2d/array2d.hh>
# include <oln/core/2d/fwd_piter2d.hh>
-# include <oln/io/read_image.hh>
/*! \namespace oln
** \brief oln namespace.
*/
namespace oln {
+ namespace io {
+ struct filename;
+
+ template <typename I>
+ void do_read(abstract::image<I>&, const filename&);
+ }
+
// fwd decl
template <typename T> class image2d;
1
1
Index: ChangeLog
from simon odou <simon(a)lrde.epita.fr>
* oln/core/entry.hh: g++-3.4 compliance.
entry.hh | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
Index: oln/core/entry.hh
--- oln/core/entry.hh (revision 43)
+++ oln/core/entry.hh (working copy)
@@ -48,9 +48,11 @@
template <typename E>
struct image_entry :
- public props < cat::image, E >::image_constness::inherits<E>::ret,
- public props < cat::image, E >::image_dimension::inherits<E>::ret
- // ...
+ public props < cat::image, E >::image_constness
+ ::template inherits<E>::ret,
+ public props < cat::image, E >::image_dimension
+ ::template inherits<E>::ret
+ // ...
{
protected:
image_entry() {}
1
0
Index: ChangeLog
from simon odou <simon(a)lrde.epita.fr>
* oln/core/entry.hh: New.
Just a basic and temporary property heredity system.
* oln/core/abstract/images.hh: Likewise.
* oln/core/abstract/image_with_data.hh: Likewiwe.
* oln/core/abstract/image_identity.hh: Likewiwe.
* oln/core/1d/image1d.hh: Likewiwe.
* oln/core/2d/image2d.hh: Likewiwe.
* oln/core/3d/image3d.hh: Likewiwe.
* tests/core/tests/readonly_image: Likewiwe.
* tests/core/tests/readwrite_image: Likewiwe.
* oln/core/tags.hh: Remove.
Old heredity system.
* oln/makefile.src: Remove tags.hh, add entry.hh.
oln/core/1d/image1d.hh | 8 -
oln/core/2d/image2d.hh | 8 -
oln/core/3d/image3d.hh | 8 -
oln/core/abstract/image_identity.hh | 2
oln/core/abstract/image_with_data.hh | 2
oln/core/abstract/images.hh | 2
oln/core/entry.hh | 64 +++++++++++++++
oln/core/tags.hh | 144 -----------------------------------
oln/makefile.src | 2
tests/core/tests/readonly_image | 4
tests/core/tests/readwrite_image | 5 -
11 files changed, 85 insertions(+), 164 deletions(-)
Index: tests/core/tests/readonly_image
--- tests/core/tests/readonly_image (revision 41)
+++ tests/core/tests/readonly_image (working copy)
@@ -24,8 +24,8 @@
typedef mlc_encoding_type_(value_type) value_storage_type;
typedef array2d<value_storage_type> value_container_type;
- typedef tag::readonly constness_tag;
- typedef tag::dimension2 dimension_tag;
+ typedef prop_of<abstract::readonly_image> image_constness;
+ typedef prop_of<abstract::image2d> image_dimension;
typedef mlc::no_type delegated_type;
};
Index: tests/core/tests/readwrite_image
--- tests/core/tests/readwrite_image (revision 41)
+++ tests/core/tests/readwrite_image (working copy)
@@ -17,6 +17,9 @@
struct props <cat::image, dummy_image> :
public default_props < cat::image >
{
+ typedef prop_of<abstract::readwrite_image> image_constness;
+ typedef prop_of<abstract::image2d> image_dimension;
+
typedef size2d size_type;
typedef point2d point_type;
typedef ntg::int_u8 value_type;
@@ -24,8 +27,6 @@
typedef mlc_encoding_type_(value_type) value_storage_type;
typedef array2d<value_storage_type> value_container_type;
- typedef tag::readwrite constness_tag;
- typedef tag::dimension2 dimension_tag;
typedef mlc::no_type delegated_type;
};
Index: oln/makefile.src
--- oln/makefile.src (revision 41)
+++ oln/makefile.src (working copy)
@@ -38,7 +38,7 @@
core/coord.hh \
core/macros.hh \
core/props.hh \
- core/tags.hh \
+ core/entry.hh \
core/value_box.hh \
fancy/iota.hh \
fancy/print.hh \
Index: oln/core/entry.hh
--- oln/core/entry.hh (revision 0)
+++ oln/core/entry.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_ENTRY_HH
+# define OLENA_CORE_ENTRY_HH
+
+# include <oln/core/abstract/image_constness.hh>
+# include <oln/core/abstract/image_dimension.hh>
+
+
+namespace oln {
+
+ template <template <typename> class Base>
+ struct prop_of
+ {
+ template <typename E>
+ struct inherits
+ {
+ typedef Base<E> ret;
+ };
+ };
+
+ namespace abstract {
+
+ template <typename E>
+ struct image_entry :
+ public props < cat::image, E >::image_constness::inherits<E>::ret,
+ public props < cat::image, E >::image_dimension::inherits<E>::ret
+ // ...
+ {
+ protected:
+ image_entry() {}
+ };
+
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ENTRY_HH
Index: oln/core/abstract/images.hh
--- oln/core/abstract/images.hh (revision 41)
+++ oln/core/abstract/images.hh (working copy)
@@ -36,7 +36,7 @@
# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/tags.hh>
+# include <oln/core/entry.hh>
#endif // ! OLENA_CORE_ABSTRACT_IMAGES_HH
Index: oln/core/abstract/image_with_data.hh
--- oln/core/abstract/image_with_data.hh (revision 41)
+++ oln/core/abstract/image_with_data.hh (working copy)
@@ -31,7 +31,7 @@
# include <mlc/tracked_ptr.hh>
-# include <oln/core/tags.hh>
+# include <oln/core/entry.hh>
# include <oln/core/macros.hh>
/*! \namespace oln
Index: oln/core/abstract/image_identity.hh
--- oln/core/abstract/image_identity.hh (revision 41)
+++ oln/core/abstract/image_identity.hh (working copy)
@@ -30,7 +30,7 @@
# include <mlc/box.hh>
-# include <oln/core/tags.hh>
+# include <oln/core/entry.hh>
namespace oln {
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 41)
+++ oln/core/1d/image1d.hh (working copy)
@@ -57,6 +57,10 @@
template <typename T>
struct props < cat::image, image1d<T> > : public default_props < cat::image >
{
+ // intrusive properties
+ typedef prop_of<abstract::readwrite_image> image_constness;
+ typedef prop_of<abstract::image1d> image_dimension;
+
typedef mlc::no_type delegated_type;
typedef size1d size_type;
@@ -72,10 +76,6 @@
// FIXME: find a better name...
typedef array1d<value_storage_type> value_container_type;
- // tags
- typedef tag::readwrite constness_tag;
- typedef tag::dimension1 dimension_tag;
-
// functions
template <typename U>
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 41)
+++ oln/core/2d/image2d.hh (working copy)
@@ -61,6 +61,10 @@
template <typename T>
struct props < cat::image, image2d<T> > : public default_props < cat::image >
{
+ // intrusive properties
+ typedef prop_of<abstract::readwrite_image> image_constness;
+ typedef prop_of<abstract::image2d> image_dimension;
+
typedef mlc::no_type delegated_type;
typedef size2d size_type;
@@ -79,10 +83,6 @@
// FIXME: find a better name...
typedef array2d<value_storage_type> value_container_type;
- // tags
- typedef tag::readwrite constness_tag;
- typedef tag::dimension2 dimension_tag;
-
// functions
template <typename U>
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 41)
+++ oln/core/3d/image3d.hh (working copy)
@@ -58,6 +58,10 @@
template <typename T>
struct props < cat::image, image3d<T> > : public default_props < cat::image >
{
+ // intrusive properties
+ typedef prop_of<abstract::readwrite_image> image_constness;
+ typedef prop_of<abstract::image3d> image_dimension;
+
typedef mlc::no_type delegated_type;
typedef size3d size_type;
@@ -73,10 +77,6 @@
// FIXME: find a better name...
typedef array3d<value_storage_type> value_container_type;
- // tags
- typedef tag::readwrite constness_tag;
- typedef tag::dimension3 dimension_tag;
-
// functions
template <typename U>
Index: oln/core/tags.hh
--- oln/core/tags.hh (revision 41)
+++ oln/core/tags.hh (working copy)
@@ -1,144 +0,0 @@
-// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 OLENA_CORE_TAGS_HH
-# define OLENA_CORE_TAGS_HH
-
-# include <oln/core/abstract/image_constness.hh>
-# include <oln/core/abstract/image_dimension.hh>
-
-#define oln_tag_decl(TAG) \
- \
-struct TAG \
-{ \
-protected: \
- TAG() {} \
-}
-
-
-#define oln_tag_decl_case(MTAG, TAG, MCLASS) \
- \
-struct TAG : public MTAG \
-{ \
-protected: \
- TAG() {} \
-}; \
- \
-namespace internal { \
- \
- template <typename E> \
- struct image_case < TAG, E > : public MCLASS <E> \
- { \
- protected: \
- image_case() {} \
- }; \
-}
-
-
-#define oln_tag_decl_retrieve_from_props(TAG) \
- \
-template <typename E> \
-struct retrieve < tag::TAG, E > \
-{ \
- typedef typename props<cat::image,E>::TAG##_tag ret; /* FIXME: ok? */ \
- /* static test if ret derives from tag::TAG */ \
-}
-
-
-
-namespace oln {
-
-
- namespace tag {
-
-
- namespace internal {
-
- template <typename TAG, typename E> struct image_case;
- template <typename TAG, typename E> struct retrieve;
-
- } // end of namespace tag::internal
-
-
- oln_tag_decl ( constness );
- 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 {
-
- template <typename E>
- struct retrieve < tag::constness, E >
- {
- typedef typename props<cat::image,E>::constness_tag ret; // FIXME: ok?
- // 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>
- {
- protected:
- image_switch() {}
- };
-
-
- } // end of namespace tag::internal
-
- } // end of namespace tag
-
-
- namespace abstract {
-
- template <typename E>
- struct image_entry :
- public tag::internal::image_switch < tag::constness, E >,
- public tag::internal::image_switch < tag::dimension, E >
- // ...
- {
- protected:
- image_entry() {}
- };
-
- }
-
-} // end of namespace oln
-
-
-#endif // ! OLENA_CORE_TAGS_HH
2
1