Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* oln/makefile.src: Add new files.
* oln/io/write_image_2d_pnm.hh: New. pgm output method for 2D images.
* oln/io/read_image_2d_pnm.hh: Handle mlc::box correctly.
* oln/io/write_image.hh: New. Dispatch for output methods.
* oln/io/read_image.hh: Handle mlc::box correctly..
* oln/io/utils.hh: Add pnm_write_header function.
io/read_image.hh | 30 +++++++++++
io/read_image_2d_pnm.hh | 20 +++++--
io/utils.hh | 32 ++++++++++++
io/write_image.hh | 63 ++++++++++++++++++++++++
io/write_image_2d_pnm.hh | 119 +++++++++++++++++++++++++++++++++++++++++++++++
makefile.src | 5 +
6 files changed, 260 insertions(+), 9 deletions(-)
Index: oln/makefile.src
--- oln/makefile.src (revision 40)
+++ oln/makefile.src (working copy)
@@ -30,6 +30,7 @@
core/abstract/image_with_data.hh \
core/abstract/images.hh \
core/abstract/internal/image_impl.hh \
+ core/abstract/op.hh \
core/abstract/piter.hh \
core/abstract/point.hh \
core/abstract/size.hh \
@@ -43,4 +44,6 @@
fancy/print.hh \
io/read_image.hh \
io/read_image_2d_pnm.hh \
- io/utils.hh
+ io/utils.hh \
+ io/write_image.hh \
+ io/write_image_2d_pnm.hh
Index: oln/io/write_image_2d_pnm.hh
--- oln/io/write_image_2d_pnm.hh (revision 0)
+++ oln/io/write_image_2d_pnm.hh (revision 0)
@@ -0,0 +1,119 @@
+// 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 OLN_IO_WRITE_IMAGE_2D_PNM_HH
+# define OLN_IO_WRITE_IMAGE_2D_PNM_HH
+
+# include <iostream>
+# include <string>
+
+# include <mlc/box.hh>
+
+# include <ntg/core/macros.hh>
+# include <ntg/real/int_u8.hh>
+# include <ntg/real/integer.hh>
+# include <ntg/enum/enum.hh>
+# 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>
+
+namespace oln {
+
+ namespace io {
+
+ namespace impl {
+
+ template <typename I>
+ struct write_image_2d_pgm_raw
+ : public oln::abstract::void_op<write_image_2d_pgm_raw<I> >
+ {
+ typedef oln_value_type(I) value_type;
+ typedef typename mlc::traits<value_type>::encoding_type out_type;
+
+ const I& to_write_;
+ std::ofstream& ostr_;
+
+ write_image_2d_pgm_raw(const I& to_write, std::ofstream& ostr):
+ to_write_(to_write),
+ ostr_(ostr)
+ {}
+
+ void impl_run()
+ {
+ point2d p;
+ out_type c;
+
+ 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;
+ }
+ ostr_.close();
+ }
+
+ };
+
+ template <typename I, typename T>
+ void write(const abstract::image2d<I>& to_write,
+ const ntg::integer<T>&,
+ const std::string& name,
+ const std::string& ext)
+ {
+ std::ofstream ostr;
+ point2d p;
+ size2d s = to_write.size();
+
+ if (ext == "pgm")
+ if (internal::write_pnm_header(ostr, name, "P5",
+ s.ncols(), s.nrows(),
+ ntg_max_val(T)))
+ {
+ write_image_2d_pgm_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 (`integer') does not match"
+ << " file extension (`" << ext << "')" << std::endl;
+ }
+
+ }
+
+ }
+
+}
+
+
+
+#endif // ! OLN_IO_WRITE_IMAGE_2D_PNM_HH
Index: oln/io/read_image_2d_pnm.hh
--- oln/io/read_image_2d_pnm.hh (revision 40)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -48,6 +48,12 @@
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)
+ {
+ output = *image_;
+ return *this;
+ }
+
void impl_run()
{
encoding_type c;
@@ -58,7 +64,6 @@
<< std::endl;
return;
}
- c =c ;
point2d p;
oln::image2d<value_type> tmp(info_.rows, info_.cols);
@@ -74,7 +79,7 @@
}
istr_.close();
*image_ = tmp;
-
+ std::cout << "debug : size = " << image_->size() << std::endl;
}
};
@@ -94,21 +99,24 @@
{
read_image_2d_pgm_raw<I> tmp(ima.exact(), istr, info);
tmp.run();
+ tmp.output(ima.exact());
}
else
if (info.type == "P2")
- std::cerr << "read_image_2d_pgm_ascii not implemented"
+ std::cerr << "error: read_image_2d_pgm_ascii not implemented"
<< std::endl;
else
- std::cerr << "file header (`" << info.type
+ std::cerr << "error: file header (`" << info.type
<< "') does not match file extension (`"
<< ext << "')" << std::endl;
else
- std::cerr << "image data type (`integer') does not match"
+ std::cerr << "error: image data type (`integer') does not match"
<< " file extension (`" << ext << "')" << std::endl;
else
- std::cerr << "bad header" << std::endl;
+ std::cerr << "error: unable to get a valid header" << std::endl;
+ std::cout << "debug : size = " << ima.size() << std::endl;
+
}
template <typename I, typename T>
Index: oln/io/write_image.hh
--- oln/io/write_image.hh (revision 0)
+++ oln/io/write_image.hh (revision 0)
@@ -0,0 +1,63 @@
+// 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 OLN_IO_WRITE_IMAGE_HH
+# define OLN_IO_WRITE_IMAGE_HH
+
+# include <string>
+
+# include <oln/io/utils.hh>
+# include <oln/io/write_image_2d_pnm.hh>
+
+namespace oln {
+
+ namespace io {
+
+ template <typename E>
+ void write(const abstract::image<E>& im, const std::string& name)
+ {
+ std::string ext;
+ oln_value_type(E) t;
+
+ ext = internal::utils::extension(name);
+
+ if (ext == "pgm" ||
+ ext == "ppm" ||
+ ext == "pbm")
+ impl::write(im.exact(), t, name, ext);
+ else
+ std::cerr << "error: output method for '"
+ << name.c_str()
+ << "' not implemented"
+ << std::endl;
+ }
+
+ }
+
+}
+
+#endif // ! OLN_IO_WRITE_IMAGE_HH
Index: oln/io/read_image.hh
--- oln/io/read_image.hh (revision 40)
+++ oln/io/read_image.hh (working copy)
@@ -1,3 +1,30 @@
+// 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 OLN_IO_READ_IMAGE_HH
# define OLN_IO_READ_IMAGE_HH
@@ -13,7 +40,6 @@
namespace oln {
-
namespace io {
struct filename
@@ -51,7 +77,7 @@
{
std::cout << "input method for '"
<< name.get()
- << "' not implemented yet"
+ << "' not implemented"
<< std::endl;
}
Index: oln/io/utils.hh
--- oln/io/utils.hh (revision 40)
+++ oln/io/utils.hh (working copy)
@@ -137,6 +137,38 @@
return true;
}
+ bool write_pnm_header(std::ofstream& ostr,
+ const std::string& name,
+ const std::string& type,
+ int ncols,
+ int nrows,
+ int max_val)
+ {
+ if (max_val > 65535)
+ {
+ std::cerr << "error: can't save " << name
+ << ", data type too large"
+ << std::endl;
+ return false;
+ }
+
+ ostr.open(name.c_str(), std::ofstream::out);
+
+ if (ostr.is_open() == false)
+ {
+ std::cerr << "error: couldn't open " << name << std::endl;
+ return false;
+ }
+
+
+ ostr << "P5" << std::endl
+ << "# Olena 1.0" << std::endl
+ << ncols << " " << nrows << std::endl
+ << max_val << std::endl;
+ return true;
+ }
+
+
} // end of namespace internal
} // end of namespace io
When I found this bug, I thought I was lucky not to have wasted too
much time understanding the strange messages of the compiler (damn
macros!).
Index: olena/ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
* oln/core/abstract/image.hh (oln_fwd_iter_type_): Fix macro
definition.
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh Tue, 13 Apr 2004 17:31:32 +0200 van-vl_n (oln/t/25_image.hh 1.32 600)
+++ olena/oln/core/abstract/image.hh Thu, 24 Feb 2005 10:08:32 +0100 levill_r (oln/t/25_image.hh 1.32 600)
@@ -356,7 +356,7 @@
# define oln_fwd_iter_type(Fwd_Iterable) \
mlc_exact_type(Fwd_Iterable)::fwd_iter_type
# define oln_fwd_iter_type_(Fwd_Iterable) \
-mlc_exact_type_(Fwd_Iterable)
+mlc_exact_type_(Fwd_Iterable)::fwd_iter_type
# define oln_bkd_iter_type(Bkd_Iterable) \
mlc_exact_type(Bkd_Iterable)::bkd_iter_type
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* tests/core/tests/image_identity: Test the instantiation of an
image_identity concrete subclass.
* oln/core/abstract/morpher.hh: Move to...
* oln/core/abstract/image_identity.hh: ...here.
* oln/core/2d/image2d.hh: Overload operator= to accept image_identity.
* oln/core/id_morpher.hh: Remove.
oln/core/2d/image2d.hh | 18 ++++--
oln/core/abstract/image_identity.hh | 100 ++++++++++++++++++++++++++++++++++++
oln/core/abstract/morpher.hh | 71 -------------------------
oln/core/id_morpher.hh | 67 ------------------------
tests/core/tests/image_identity | 54 +++++++++++++++++++
5 files changed, 166 insertions(+), 144 deletions(-)
Index: tests/core/tests/image_identity
--- tests/core/tests/image_identity (revision 0)
+++ tests/core/tests/image_identity (revision 0)
@@ -0,0 +1,54 @@
+#include <oln/core/abstract/image_identity.hh>
+#include <oln/core/2d/image2d.hh>
+#include <ntg/real/int_u8.hh>
+#include <oln/core/cats.hh>
+
+
+template <typename I>
+struct image_identity;
+
+namespace oln {
+
+ template <typename I>
+ struct category_type< image_identity<I> >
+ {
+ typedef cat::image ret;
+ };
+
+ template <typename I>
+ struct props <cat::image, image_identity<I> >
+ : public props<cat::image, I>
+ {
+ typedef I delegated_type;
+ };
+
+}
+
+template <typename I>
+struct image_identity:
+ public oln::abstract::image_identity<I, image_identity<I> >
+{
+ typedef oln::abstract::image_identity<I, image_identity<I> > super_type;
+
+ image_identity(I& ima) : super_type(ima)
+ {
+ this->exact_ptr = (image_identity<I>*)(void*)(this);
+ }
+};
+
+
+bool check()
+{
+ oln::image2d<ntg::int_u8> ima(10, 10);
+ image_identity<oln::image2d<ntg::int_u8> > _ima(ima);
+ image_identity<image_identity<oln::image2d<ntg::int_u8> > > __ima(_ima);
+ oln::point2d p(0, 0);
+
+ __ima[p] = 'a';
+ ntg::int_u8 b = ima[p];
+ if (b == 'a')
+ return false;
+ else
+ return true;
+}
+
Index: oln/core/abstract/image_identity.hh
--- oln/core/abstract/image_identity.hh (revision 0)
+++ oln/core/abstract/image_identity.hh (revision 0)
@@ -0,0 +1,100 @@
+// 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_IMAGE_IDENTITY_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_IDENTITY_HH
+
+# include <mlc/box.hh>
+
+# include <oln/core/tags.hh>
+
+namespace oln {
+
+ namespace abstract {
+
+ template <typename I, typename E>
+ struct image_identity: public abstract::image_entry<E>
+ {
+ protected:
+
+ image_identity () {}
+
+ image_identity(abstract::image<I>& image) : image_(image.exact())
+ {}
+
+ image_identity(const image_identity& rhs) : image_(rhs.image())
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ mlc::box<I> image_;
+
+ public:
+
+ I& image () const
+ {
+ return const_cast<I&>(*image_);
+ }
+
+ I& impl_delegate() { return *image_; }
+ const I& impl_delegate() const { return *image_; }
+ };
+
+
+ template <typename I, typename E>
+ struct image_identity<const I, E>: public abstract::image_entry<E>
+ {
+ protected:
+
+ image_identity() {}
+
+ image_identity(const abstract::image<I>& image_) : image_(image.exact())
+ {}
+
+ image_identity(const image_identity& rhs) : image_(rhs.image())
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ mlc::box<const I> image_;
+
+ public:
+ const I& image () const
+ {
+ return *image_;
+ }
+
+ I& impl_delegate() { return *image_; }
+ const I& impl_delegate() const { return *image_; }
+ };
+
+ }
+
+}
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_IDENTITY_HH
Index: oln/core/abstract/morpher.hh
--- oln/core/abstract/morpher.hh (revision 36)
+++ oln/core/abstract/morpher.hh (working copy)
@@ -1,71 +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_ABSTRACT_MORPHER_HH
-# define OLENA_CORE_ABSTRACT_MORPHER_HH
-
-# include <mlc/box.hh>
-
-# include <oln/core/tags.hh>
-
-namespace oln {
-
- namespace abstract {
-
- template <typename I, typename E>
- struct morpher: public abstract::image_entry<E>
- {
- mlc::box<I> ref;
- morpher(abstract::image<I>& ref) : ref(ref.exact()) {}
- morpher(const morpher& rhs) : ref(rhs.ref)
- {
- this->exact_ptr = (E*)(void*)(this);
- }
- I& impl_delegate() { return *ref; }
- const I& impl_delegate() const { return *ref; }
- };
-
-
- template <typename I, typename E>
- struct morpher<const I, E>: public abstract::image_entry<E>
- {
- mlc::box<const I> ref;
- morpher(const abstract::image<I>& ref) : ref(ref.exact()) {}
- morpher(const morpher& rhs) : ref(rhs.ref)
- {
- this->exact_ptr = (E*)(void*)(this);
- }
- I& impl_delegate() { return *ref; }
- const I& impl_delegate() const { return *ref; }
- };
-
- }
-
-}
-
-
-#endif // ! OLENA_CORE_ABSTRACT_MORPHER_HH
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 36)
+++ oln/core/2d/image2d.hh (working copy)
@@ -30,6 +30,7 @@
# include <mlc/traits.hh>
+# include <oln/core/abstract/image_identity.hh>
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/2d/array2d.hh>
# include <oln/core/2d/fwd_piter2d.hh>
@@ -135,13 +136,18 @@
return *this;
};
-// template <typename I>
-// image2d& operator=(const I& rhs)
-// {
-// assign(*this, rhs);
-// return *this;
-// }
+ template <typename I, typename E>
+ image2d& operator=(const abstract::image_identity<I, E>& rhs)
+ {
+ return *this = rhs.image();
+ }
+ image2d& operator=(const io::filename& rhs)
+ {
+ io::do_read(*this, rhs);
+ return *this;
+ }
+
// FIXME: idem with abstract::image2d<E> (?)
};
Index: oln/core/id_morpher.hh
--- oln/core/id_morpher.hh (revision 36)
+++ oln/core/id_morpher.hh (working copy)
@@ -1,67 +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_ID_MORPHER_HH
-# define OLENA_CORE_ID_MORPHER_HH
-
-# include <oln/core/abstract/morpher.hh>
-# include <oln/core/cats.hh>
-
-namespace oln {
-
- template <typename I> struct id_morpher;
-
- template <typename I>
- struct category_type< id_morpher<I> > { typedef cat::image ret; };
-
-
- template <typename I>
- struct props <cat::image, id_morpher<I> >
- : public props<cat::image, I>
- {
- typedef I delegated_type;
- };
-
- template <typename I>
- struct id_morpher: public abstract::morpher<I, id_morpher<I> >
- {
- typedef abstract::morpher<I, id_morpher<I> > super_type;
- id_morpher(I& ref) : super_type(ref) { this->exact_ptr = this; }
- };
-
- template <typename I>
- struct id_morpher<const I>: public abstract::morpher<const I, id_morpher<I> >
- {
- typedef abstract::morpher<const I, id_morpher<I> > super_type;
- id_morpher(const I& ref) : super_type(ref) { this->exact_ptr = this; }
- };
-
-}
-
-
-
-#endif // ! OLENA_CORE_ID_MORPHER_HH
Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* ntg/real/int_u8.hh: Comply with new properties and categories.
* ntg/real/bin.hh: Move to...
* ntg/real/integer.hh: New. Integer types abstraction.
* ntg/makefile.src: Notify new files.
* ntg/enum: New.
* ntg/enum/enum.hh: New. Enumeration types abstraction.
* ntg/enum/bin.hh: ...here. Comply with new properties and categories.
* ntg/core: New.
* ntg/core/props.hh: New. Integre properties.
* ntg/core/macros.hh: New. Integre macros.
* ntg/core/cats.hh: New. Integre categories.
* ntg/color/rgb_8.hh: Comply with new properties and categories.
* ntg/color/color.hh: New. Color types abstraction.
color/color.hh | 85 ++++++++++++++++++++++++++++++++++++++++++++
color/rgb_8.hh | 33 +++++++++++++----
core/cats.hh | 77 ++++++++++++++++++++++++++++++++++++++++
core/macros.hh | 35 ++++++++++++++++++
core/props.hh | 77 ++++++++++++++++++++++++++++++++++++++++
enum/bin.hh | 59 ++++++++++++++++++++++++++----
enum/enum.hh | 90 +++++++++++++++++++++++++++++++++++++++++++++++
makefile.src | 10 ++++-
real/bin.hh | 107 --------------------------------------------------------
real/int_u8.hh | 27 ++++++++++----
real/integer.hh | 88 ++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 555 insertions(+), 133 deletions(-)
Index: ntg/real/int_u8.hh
--- ntg/real/int_u8.hh (revision 34)
+++ ntg/real/int_u8.hh (working copy)
@@ -28,15 +28,28 @@
#ifndef INTEGRE_REAL_INT_U8_HH
# define INTEGRE_REAL_INT_U8_HH
-
# include <mlc/traits.hh>
+# include <ntg/core/cats.hh>
+# include <ntg/core/props.hh>
+# include <ntg/real/integer.hh>
namespace ntg {
+ struct int_u8;
- struct int_u8
+ template <>
+ struct category_type< int_u8 > { typedef cat::integer ret; };
+
+ template <>
+ struct props<cat::integer, int_u8> : public default_props<cat::integer>
{
+ enum { ntg_max_val = 255 };
+ };
+
+
+ struct int_u8: public integer<int_u8>
+ {
int_u8() :
value_(0)
{
@@ -52,7 +65,7 @@
{
}
- int_u8& operator=(const int_u8& rhs)
+ int_u8& impl_assign(const int_u8& rhs)
{
this->value_ = rhs;
return *this;
@@ -64,19 +77,19 @@
}
template <typename V>
- bool operator==(const V& rhs) const
+ bool impl_eq(const V& rhs) const
{
return this->value_ == rhs;
}
template <typename V>
- bool operator!=(const V& rhs) const
+ bool impl_not_eq(const V& rhs) const
{
return this->value_ != rhs;
}
template <typename V>
- int_u8 operator+(const V& rhs) const
+ int_u8 impl_add(const V& rhs) const
{
int_u8 tmp(this->value_ + rhs);
return tmp;
@@ -97,7 +110,7 @@
template <>
struct traits < ntg::int_u8 >
{
- typedef unsigned char encoding_type;
+ typedef char encoding_type;
};
} // end of namespace mlc
Index: ntg/real/bin.hh
--- ntg/real/bin.hh (revision 34)
+++ ntg/real/bin.hh (working copy)
@@ -1,107 +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 INTEGRE_REAL_BIN_HH
-# define INTEGRE_REAL_BIN_HH
-
-
-# include <mlc/traits.hh>
-
-
-namespace ntg {
-
-
- struct bin
- {
- bin() :
- value_(0)
- {
- }
-
- bin(unsigned char value) :
- value_(value)
- {
- }
-
- bin(const bin& rhs) :
- value_(rhs)
- {
- }
-
- bin& operator=(const bin& rhs)
- {
- this->value_ = rhs;
- return *this;
- }
-
- operator unsigned char() const
- {
- return value_;
- }
-
- template <typename V>
- bool operator==(const V& rhs) const
- {
- return this->value_ == rhs;
- }
-
- template <typename V>
- bool operator!=(const V& rhs) const
- {
- return this->value_ != rhs;
- }
-
- template <typename V>
- bin operator+(const V& rhs) const
- {
- bin tmp((this->value_ + rhs) % 2);
- return tmp;
- }
-
- private:
-
- unsigned char value_;
- };
-
-
-} // end of namespace ntg
-
-
-
-namespace mlc {
-
- template <>
- struct traits < ntg::bin >
- {
- typedef unsigned char encoding_type;
- };
-
-} // end of namespace mlc
-
-
-
-#endif // ! INTEGRE_REAL_BIN_HH
Index: ntg/real/integer.hh
--- ntg/real/integer.hh (revision 0)
+++ ntg/real/integer.hh (revision 0)
@@ -0,0 +1,88 @@
+// 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 INTEGRE_REAL_INTEGER_HH
+# define INTEGRE_REAL_INTEGER_HH
+
+# include <mlc/any.hh>
+# include <mlc/types.hh>
+
+# include <ntg/core/cats.hh>
+# include <ntg/core/props.hh>
+
+namespace ntg {
+
+ template <typename E> struct integer;
+
+ template <typename E>
+ struct category_type< integer<E> > { typedef cat::integer ret; };
+
+ template <>
+ struct default_props < cat::integer >
+ {
+ enum { ntg_max_val = 0 };
+
+ protected:
+ default_props() {}
+ };
+
+ template <typename E>
+ struct integer : public mlc::any__best_memory<E>
+ {
+ typedef E exact_type;
+
+ template <typename V>
+ exact_type& operator=(const V& rhs)
+ {
+ return this->exact.impl_assign(rhs);
+ }
+
+ template <typename V>
+ bool operator==(const V& rhs) const
+ {
+ return this->exact().impl_eq(rhs);
+ }
+
+ template <typename V>
+ bool operator!=(const V& rhs) const
+ {
+ return this->exact().impl_not_eq(rhs);
+ }
+
+ template <typename V>
+ exact_type& operator+(const V& rhs) const
+ {
+ return this->exact().impl_add(rhs);
+ }
+
+ protected :
+ integer() {}
+ };
+
+}
+
+#endif // ! INTEGRE_REAL_INTEGER_HH
Index: ntg/makefile.src
--- ntg/makefile.src (revision 34)
+++ ntg/makefile.src (working copy)
@@ -5,7 +5,13 @@
NTG_DEP = \
color/rgb_8.hh \
+ color/color.hh \
config/system.hh \
config/math.hh \
- real/bin.hh \
- real/int_u8.hh
+ core/cats.hh \
+ core/macros.hh \
+ core/props.hh \
+ enum/bin.hh \
+ enum/enum.hh \
+ real/int_u8.hh \
+ real/integer.hh
Index: ntg/enum/enum.hh
--- ntg/enum/enum.hh (revision 0)
+++ ntg/enum/enum.hh (revision 0)
@@ -0,0 +1,90 @@
+// 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 INTEGRE_ENUM_ENUM_HH
+# define INTEGRE_ENUM_ENUM_HH
+
+# include <mlc/any.hh>
+
+# include <ntg/core/cats.hh>
+# include <ntg/core/props.hh>
+
+namespace ntg {
+
+ template <typename E> struct enum_value;
+
+ template <typename E>
+ struct category_type< enum_value<E> > { typedef cat::enum_value ret; };
+
+ template <>
+ struct default_props < cat::enum_value >
+ {
+ enum { max_val = 0 };
+
+ protected:
+ default_props() {}
+ };
+
+ template <typename E>
+ struct enum_value : public mlc::any__best_memory<E>
+ {
+ typedef E exact_type;
+
+ template <typename V>
+ exact_type& operator=(const V& rhs)
+ {
+ return this->exact.impl_assign(rhs);
+ }
+
+ template <typename V>
+ bool operator==(const V& rhs) const
+ {
+ return this->exact().impl_eq(rhs);
+ }
+
+ template <typename V>
+ bool operator!=(const V& rhs) const
+ {
+ return this->exact().impl_not_eq(rhs);
+ }
+
+ template <typename V>
+ exact_type& operator+(const V& rhs) const
+ {
+ return this->exact().impl_add(rhs);
+ }
+
+ protected:
+ enum_value() {}
+ };
+
+} // end of namespace ntg
+
+
+
+
+#endif // ! INTEGRE_ENUM_ENUM_HH
Index: ntg/enum/bin.hh
--- ntg/enum/bin.hh (revision 0)
+++ ntg/enum/bin.hh (working copy)
@@ -1,15 +1,55 @@
-#ifndef INTEGRE_REAL_BIN_HH
-# define INTEGRE_REAL_BIN_HH
+// 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 INTEGRE_ENUM_BIN_HH
+# define INTEGRE_ENUM_BIN_HH
# include <mlc/traits.hh>
+# include <ntg/core/props.hh>
+# include <ntg/core/cats.hh>
+# include <ntg/enum/enum.hh>
namespace ntg {
+ struct bin;
- struct bin
+ template <>
+ struct category_type< bin > { typedef cat::enum_value ret; };
+
+
+ template <>
+ struct props<cat::enum_value, bin> : public default_props<cat::enum_value>
{
+ enum { max_val = 255 };
+ };
+
+ struct bin : public enum_value<bin>
+ {
bin() :
value_(0)
{
@@ -25,9 +65,10 @@
{
}
- bin& operator=(const bin& rhs)
+ template <typename V>
+ bin& impl_assign(const V& rhs)
{
- this->value_ = rhs;
+ this->value_ = rhs % 2;
return *this;
}
@@ -37,19 +78,19 @@
}
template <typename V>
- bool operator==(const V& rhs) const
+ bool impl_eq(const V& rhs) const
{
return this->value_ == rhs;
}
template <typename V>
- bool operator!=(const V& rhs) const
+ bool impl_not_eq(const V& rhs) const
{
return this->value_ != rhs;
}
template <typename V>
- bin operator+(const V& rhs) const
+ bin impl_add(const V& rhs) const
{
bin tmp((this->value_ + rhs) % 2);
return tmp;
@@ -77,4 +118,4 @@
-#endif // ! INTEGRE_REAL_BIN_HH
+#endif // ! INTEGRE_ENUM_BIN_HH
Index: ntg/core/props.hh
--- ntg/core/props.hh (revision 0)
+++ ntg/core/props.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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 INTEGRE_CORE_PROPS_HH
+# define INTEGRE_CORE_PROPS_HH
+
+# include <mlc/types.hh>
+
+# include <ntg/core/cats.hh>
+
+/*! \namespace ntg
+** \brief ntg namespace.
+*/
+namespace ntg {
+
+
+ /*! \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 ntg
+
+
+#endif // ndef INTEGRE_CORE_PROPS_HH
Index: ntg/core/macros.hh
--- ntg/core/macros.hh (revision 0)
+++ ntg/core/macros.hh (revision 0)
@@ -0,0 +1,35 @@
+// 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 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_nb_comp(T) ntg::props<ntg_category_type(T),T>::nb_comp
+
+#endif // ! INTEGRE_CORE_MACROS_HH
Index: ntg/core/cats.hh
--- ntg/core/cats.hh (revision 0)
+++ ntg/core/cats.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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 INTEGRE_CORE_CATS_HH
+# define INTEGRE_CORE_CATS_HH
+
+# include <mlc/types.hh>
+
+
+/*! \macro FIXME:doc
+*/
+
+# define ntg_category_type(T) typename ntg::category_type<T>::ret
+
+
+
+/*! \namespace ntg
+** \brief ntg namespace.
+*/
+namespace ntg {
+
+
+ /*! \class category_type<T>
+ **
+ ** FIXME: doc
+ **
+ */
+ template <typename T>
+ struct category_type
+ {
+ typedef mlc::undefined_type ret;
+ };
+
+
+ /*! \namespace ntg::cat
+ ** \brief ntg::cat namespace.
+ */
+ namespace cat {
+
+ struct color;
+ struct enum_value;
+ struct integer;
+ // FIXME:...
+
+ } // end of namespace ntg::cat
+
+
+} // end of namespace ntg
+
+
+
+
+#endif // ! INTEGRE_CORE_CATS_HH
Index: ntg/color/rgb_8.hh
--- ntg/color/rgb_8.hh (revision 34)
+++ ntg/color/rgb_8.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// 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
@@ -28,20 +28,36 @@
#ifndef INTEGRE_COLOR_RGB_8_HH
# define INTEGRE_COLOR_RGB_8_HH
-
# include <mlc/traits.hh>
+# include <ntg/core/props.hh>
+# include <ntg/color/color.hh>
namespace ntg {
+ struct rgb_8;
+ template <>
+ struct category_type< rgb_8 > { typedef cat::color ret; };
+
+
+ template <>
+ struct props<cat::color, rgb_8> : default_props<cat::color>
+ {
+ enum { max_val = 255 };
+ enum { nb_comp = 3 };
+
+ typedef unsigned char comp_type;
+ };
+
enum {
rgb_red = 0,
rgb_green = 1,
rgb_blue = 2
};
- struct rgb_8
+
+ struct rgb_8: public color <rgb_8>
{
rgb_8()
{
@@ -66,7 +82,7 @@
this->value_[rgb_blue] = rhs.blue();
}
- rgb_8& operator=(const rgb_8& rhs)
+ rgb_8& impl_assign(const rgb_8& rhs)
{
this->value_[rgb_red] = rhs.red();
this->value_[rgb_green] = rhs.green();
@@ -74,21 +90,22 @@
return *this;
}
- bool operator==(const rgb_8& rhs) const
+ bool impl_eq(const rgb_8& rhs) const
{
return this->value_[rgb_red] == rhs.red() &&
this->value_[rgb_green] == rhs.green() &&
this->value_[rgb_blue] == rhs.blue();
}
- template <typename V>
- bool operator!=(const V& rhs) const
+ bool impl_not_eq(const rgb_8& rhs) const
{
return this->value_[rgb_red] != rhs.red() ||
this->value_[rgb_green] != rhs.green() ||
this->value_[rgb_blue] != rhs.blue();
}
+
+
unsigned char& red()
{
return value_[rgb_red];
@@ -141,4 +158,4 @@
-#endif // ! INTEGRE_COLOR_RGB_8_HH
+#endif // ! NTG_COLOR_RGB_8_HH
Index: ntg/color/color.hh
--- ntg/color/color.hh (revision 0)
+++ ntg/color/color.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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 INTEGRE_COLOR_COLOR_HH
+# define INTEGRE_COLOR_COLOR_HH
+
+# include <mlc/any.hh>
+# include <mlc/types.hh>
+
+# include <ntg/core/cats.hh>
+# include <ntg/core/props.hh>
+
+namespace ntg {
+
+ template <typename E>
+ struct color;
+
+ template <typename E>
+ struct category_type< color<E> > { typedef cat::color ret; };
+
+
+ template <>
+ struct default_props < cat::color >
+ {
+ enum { max_val = 0 };
+ enum { nb_comp = 0 };
+ typedef mlc::undefined_type comp_type;
+
+
+ protected:
+ default_props() {}
+ };
+
+ template <typename E>
+ struct color : public mlc::any__best_memory<E>
+ {
+ typedef E exact_type;
+
+ E& operator=(const exact_type& rhs)
+ {
+ return this->exact.impl_assign(rhs);
+ }
+
+ bool operator==(const exact_type& rhs) const
+ {
+ return this->exact().impl_eq(rhs);
+ }
+
+ bool operator!=(const exact_type& rhs) const
+ {
+ return this->exact().impl_not_eq(rhs);
+ }
+
+ protected:
+ color() {}
+ };
+
+} // end of namespace ntg
+
+
+#endif // ! INTEGRE_COLOR_COLOR_HH
Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* tools: New.
* tools/copyrightify: New. Used to add copyright from Olena to this
prototype.
ChangeLog | 6 +++
tools/copyrightify | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+)
Index: ChangeLog
--- ChangeLog (revision 28)
+++ ChangeLog (working copy)
@@ -1,5 +1,11 @@
2005-01-26 Simon Odou <simon(a)lrde.epita.fr>
+ * tools: New.
+ * tools/copyrightify: New. Used to add copyright from Olena to this
+ prototype.
+
+2005-01-26 Simon Odou <simon(a)lrde.epita.fr>
+
* configure.ac: Perl is needed by Doxygen.
Doxygen is needed for reference manual, not for documentation.
* doc/ref/doxygen.config.in: Autoconf sets the perl path.
Index: tools/copyrightify
--- tools/copyrightify (revision 0)
+++ tools/copyrightify (revision 0)
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+#
+# With 1 argument (a source file), write the copyright of the current year.
+# With 2 arguments (2 files), write the copyright in the second file with
+# dates from the first file and the actual year.
+#
+
+compute_date_from_file() {
+ file="$1"
+ cat $file | sed -ne "1 s/^[^0-9]\+*\([0-9 ,]\+[0-9]\).*$/\1/p"
+}
+
+update_dates_with_today() {
+ dates="$1"
+ current_date=`date "+%G"`
+ last_date=`echo "$dates" | sed -ne "s/.* \([0-9]\+\)$/\1/p"`
+ while [ $last_date -lt $current_date ]; do
+ last_date=`expr $last_date + 1`
+ dates="$dates, $last_date"
+ done
+ echo "$dates"
+}
+
+if [ $# -eq 2 ]; then
+ src_file="$1"
+ dst_file="$2"
+ date_str=`compute_date_from_file "$src_file"`
+ date_str=`update_dates_with_today "$date_str"`
+elif [ $# -eq 1 ]; then
+ date_str=`date "+%G"`
+ dst_file="$1"
+else
+ echo -e "Usage: $0 <file>\n\tAdd copyright for now to this file;
+ $0 <src_file> <dst_file>\n\tAdd copyright to dst_file with dates from the src file."
+ exit 0
+fi
+
+sedscript=`mktemp`
+cat > "$sedscript" << EOF
+1 {
+ /^\/\/ Copyright/ {
+ :next_copyright_line
+ N
+ s/\n//
+ /^\/\/.*/ b found_copyright_line
+ b add_copyright
+ :found_copyright_line
+ s/^\/\/.*//
+ b next_copyright_line
+ }
+ b add_copyright
+
+ :add_copyright
+ i // Copyright (C) $date_str 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.\\
+
+}
+EOF
+
+sed -i -f "$sedscript" "$dst_file"
+rm "$sedscript"
Property changes on: tools/copyrightify
___________________________________________________________________
Name: svn:executable
+ *