URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-15 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Review the mln/literal directory.
* mln/literal/black.hh,
* mln/literal/colors.hh,
* mln/literal/grays.hh,
* mln/literal/one.hh,
* mln/literal/origin.hh,
* mln/literal/white.hh,
* tests/literal/black.cc: Use extern const ref, not static. Move
impl. within MLN_INCLUDE_ONLY.
Move/add some unit tests.
* tests/literal/literal_medium_gray.cc: Rename as...
* tests/literal/medium_gray.cc: ...this.
* tests/literal/literal_zero.cc: Rename as...
* tests/literal/zero.cc: ...this.
* tests/literal/one.cc: New.
* tests/literal/white.cc: New.
---
mln/literal/black.hh | 9 +++++-
mln/literal/colors.hh | 14 ++++++++--
mln/literal/grays.hh | 9 +++++-
mln/literal/one.hh | 4 ++
mln/literal/origin.hh | 9 +++++-
mln/literal/white.hh | 9 +++++-
tests/literal/black.cc | 52 ++++++++++++++++++++++++++++++++++++++
tests/literal/medium_gray.cc | 57 ++++++++++++++++++++++++++++++++++++++++++
tests/literal/one.cc | 58 +++++++++++++++++++++++++++++++++++++++++++
tests/literal/white.cc | 53 +++++++++++++++++++++++++++++++++++++++
tests/literal/zero.cc | 58 +++++++++++++++++++++++++++++++++++++++++++
11 files changed, 323 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/literal/literal_zero.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal/literal_medium_gray.cc (deleted)
===================================================================
Index: trunk/milena/tests/literal/black.cc
===================================================================
--- trunk/milena/tests/literal/black.cc (revision 0)
+++ trunk/milena/tests/literal/black.cc (revision 1484)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/black.cc
+ *
+ * \brief Tests on mln::literal::black.
+ */
+
+#include <mln/value/rgb8.hh>
+#include <mln/literal/black.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+ using literal::black;
+
+ {
+ rgb8 c(0, 0, 0);
+
+ c.green() = 254;
+ mln_assertion(c != black);
+
+ c = black;
+ mln_assertion(c == black);
+ }
+}
Index: trunk/milena/tests/literal/zero.cc
===================================================================
--- trunk/milena/tests/literal/zero.cc (revision 0)
+++ trunk/milena/tests/literal/zero.cc (revision 1484)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/zero.cc
+ *
+ * \brief Tests on mln::literal::zero.
+ */
+
+#include <mln/literal/zero.hh>
+#include <mln/literal/one.hh>
+#include <mln/literal/ops.hh>
+#include <mln/value/int_u8.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::zero;
+ mln_assertion(c == 0);
+
+ double d;
+ d = literal::zero;
+ mln_assertion(d == 0);
+
+ mln_assertion(literal::zero != literal::one);
+
+ value::int_u8 u(literal::zero), uu;
+ uu = literal::zero;
+
+ mln_assertion(u == 0 && 0 == u);
+}
Index: trunk/milena/tests/literal/white.cc
===================================================================
--- trunk/milena/tests/literal/white.cc (revision 0)
+++ trunk/milena/tests/literal/white.cc (revision 1484)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/white.cc
+ *
+ * \brief Tests on mln::literal::white.
+ */
+
+#include <mln/value/rgb8.hh>
+#include <mln/literal/white.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+ using literal::white;
+
+ {
+ rgb8 c(255, 255, 255);
+
+
+ c.green() = 254;
+ mln_assertion(c != white);
+
+ c = white;
+ mln_assertion(c == white);
+ }
+}
Index: trunk/milena/tests/literal/one.cc
===================================================================
--- trunk/milena/tests/literal/one.cc (revision 0)
+++ trunk/milena/tests/literal/one.cc (revision 1484)
@@ -0,0 +1,58 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/one.cc
+ *
+ * \brief Tests on mln::literal::one.
+ */
+
+#include <mln/literal/one.hh>
+#include <mln/literal/zero.hh>
+#include <mln/literal/ops.hh>
+#include <mln/value/int_u8.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char c;
+ c = literal::one;
+ mln_assertion(c == 1);
+
+ double d;
+ d = literal::one;
+ mln_assertion(d == 1);
+
+ mln_assertion(literal::one != literal::zero);
+
+ value::int_u8 u(literal::one), uu;
+ uu = literal::one;
+
+ mln_assertion(u == 1 && 1 == u);
+}
Index: trunk/milena/tests/literal/medium_gray.cc
===================================================================
--- trunk/milena/tests/literal/medium_gray.cc (revision 0)
+++ trunk/milena/tests/literal/medium_gray.cc (revision 1484)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/literal/medium_gray.cc
+ *
+ * \brief Tests on mln::literal::medium_gray.
+ */
+
+#include <mln/literal/grays.hh>
+#include <mln/value/graylevel.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ using literal::medium_gray;
+ using value::gl8;
+ using value::gl16;
+
+ gl8 a;
+ gl16 b;
+
+ a = medium_gray;
+
+ std::cout << int(a.value()) << std::endl;
+
+ b = a;
+ std::cout << int(b.value()) << std::endl;
+
+ b = medium_gray;
+ std::cout << int(b.value()) << std::endl;
+}
Index: trunk/milena/mln/literal/colors.hh
===================================================================
--- trunk/milena/mln/literal/colors.hh (revision 1483)
+++ trunk/milena/mln/literal/colors.hh (revision 1484)
@@ -58,13 +58,21 @@
/// Literal red.
- static red_t red = red_t();
+ extern const red_t& red;
/// Literal green.
- static green_t green = green_t();
+ extern const green_t& green;
/// Literal blue.
- static blue_t blue = blue_t();
+ extern const blue_t& blue;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const red_t& red = red_t();
+ const green_t& green = green_t();
+ const blue_t& blue = blue_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/one.hh
===================================================================
--- trunk/milena/mln/literal/one.hh (revision 1483)
+++ trunk/milena/mln/literal/one.hh (revision 1484)
@@ -54,7 +54,7 @@
/// Literal one.
- static one_t one = one_t();
+ extern const one_t& one;
# ifndef MLN_INCLUDE_ONLY
@@ -66,6 +66,8 @@
return 1;
}
+ const one_t& one = one_t();
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/grays.hh
===================================================================
--- trunk/milena/mln/literal/grays.hh (revision 1483)
+++ trunk/milena/mln/literal/grays.hh (revision 1484)
@@ -47,7 +47,14 @@
};
/// Literal medium_gray.
- static medium_gray_t medium_gray = medium_gray_t();
+ extern const medium_gray_t& medium_gray;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const medium_gray_t& medium_gray = medium_gray_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/origin.hh
===================================================================
--- trunk/milena/mln/literal/origin.hh (revision 1483)
+++ trunk/milena/mln/literal/origin.hh (revision 1484)
@@ -47,9 +47,14 @@
{
};
-
/// Literal origin.
- static origin_t origin = origin_t();
+ extern const origin_t& origin;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const origin_t& origin = origin_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/black.hh
===================================================================
--- trunk/milena/mln/literal/black.hh (revision 1483)
+++ trunk/milena/mln/literal/black.hh (revision 1484)
@@ -48,7 +48,14 @@
/// Literal black.
- static black_t black = black_t();
+ extern const black_t& black;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const black_t& black = black_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: trunk/milena/mln/literal/white.hh
===================================================================
--- trunk/milena/mln/literal/white.hh (revision 1483)
+++ trunk/milena/mln/literal/white.hh (revision 1484)
@@ -48,7 +48,14 @@
/// Literal white.
- static white_t white = white_t();
+ extern const white_t& white;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ const white_t& white = white_t();
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal