Index: integre/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* ntg/core/macros.hh: Add ntg_nbits macro.
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/utils/buffer.hxx: Add file.
* oln/utils/buffer.hh: Likewise.
* oln/utils/key.hh: Likewise.
* oln/utils/key.hxx: Likewise.
* oln/utils/md5.hh: Likewise.
* oln/utils/md5.hxx: Likewise.
+2004-03-19 Giovanni Palma <giovanni(a)lrde.epita.fr>
+
* oln/convol/fast_gaussian.hh: Correct comments.
* oln/io/se_window.hh: Likewise.
* oln/transforms/dwt.hh: Likewise.
Index: integre/ntg/core/macros.hh
--- integre/ntg/core/macros.hh Sat, 03 Jan 2004 17:25:53 +0100 burrus_n (oln/s/19_macros.hh 1.9 640)
+++ integre/ntg/core/macros.hh Fri, 19 Mar 2004 15:03:05 +0100 palma_g (oln/s/19_macros.hh 1.9 640)
@@ -154,4 +154,10 @@
// FIXME: reimplement when variadic macros will be allowed.
# define ntg_get_value_type(T, E) ntg::type_traits<T>::build_value_type<E>
+
+/* ----.
+| Misc |
+`-----*/
+#define ntg_nbits(T) ntg::internal::typetraits<T>::size
+
#endif // !NTG_CORE_MACROS_HH
Index: olena/oln/utils/buffer.hxx
--- olena/oln/utils/buffer.hxx Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/buffer.hxx Fri, 19 Mar 2004 15:48:04 +0100 palma_g (oln/k/9_buffer.hxx 644)
@@ -0,0 +1,167 @@
+// Copyright (C) 2004 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_OLN_UTILS_BUFFER_HXX
+# define OLENA_OLN_UTILS_BUFFER_HXX
+
+// Ctor implementation
+inline
+buffer::buffer(): current_bit_(0),
+ data_(),
+ len1_(ntg_zero_val(value_type)),
+ len2_(ntg_zero_val(value_type)),
+ padding_appended_(false),
+ length_appended_(false)
+{
+ data_.reserve(length_);
+ data_.push_back(ntg_zero_val(value_type));
+};
+
+// add implementation
+template <class E>
+inline
+void buffer::add(const E &e, bool count)
+{
+ ntg_storage_type(E) mask = 1 << (ntg_nbits(E) - 1);
+ ntg_storage_type(E) e_cast = e;
+
+ while (mask)
+ {
+ push_back(e_cast & mask, !count);
+ mask >>= 1;
+ }
+};
+
+// push_back implementation
+inline
+void buffer::push_back(bool bit, bool is_padding)
+{
+ precondition(current_bit_ < 32);
+
+ current_bit_ += 1;
+ data_.back() *= 2;
+ if (bit)
+ data_.back() += ntg_unit_val(value_type);
+ if (current_bit_ == 32)
+ {
+ if (data_.size() == data_.capacity())
+ data_.reserve(data_.capacity() + length_);
+ current_bit_ = 0;
+ data_.push_back(ntg_zero_val(value_type));
+ }
+ if (!is_padding)
+ {
+ if (len1_ == ntg_max_val(value_type))
+ {
+ if (len2_ == ntg_max_val(value_type))
+ len2_ = ntg_unit_val(value_type);
+ else
+ len2_ += ntg_unit_val(value_type);
+ }
+ len1_ += ntg_unit_val(value_type);
+ }
+}
+
+// reorder implementation
+inline
+buffer::value_type buffer::reorder(value_type x) const
+{
+ ntg_storage_type_(value_type) r = 0;
+ ntg_storage_type_(value_type) mask = 0xFF;
+
+ for (unsigned i = 0; i < (sizeof(ntg_storage_type_(value_type))); ++i)
+ {
+ r <<= 8;
+ r |= (mask & ntg_storage_type_(value_type)(x)) >> (i * 8);
+ mask <<= 8;
+ }
+ return r;
+}
+
+// [] operator implementation
+inline
+ntg::int_u32 buffer::operator[] (unsigned n) const
+{
+ precondition(n < data_.size());
+
+ return reorder(data_[n]);
+};
+
+// append padding implementation
+inline
+void buffer::append_padding()
+{
+ push_back(true, true);
+ while (((data_.size() * 32) % 512) != 448)
+ push_back(false, true);
+ padding_appended_ = true;
+};
+
+// append_length implementation
+inline
+void buffer::append_length()
+{
+ precondition(padding_appended_);
+
+ add(reorder(len2_), false);
+ add(reorder(len1_), false);
+ std::cout << len2_ << len1_<< std::endl;
+ std::cout << (*this)[data_.size()-2] << (*this)[data_.size()-1] << std::endl;
+ std::cout << data_.size() - 1<< std::endl;
+ std::cout << (*this)[14]<< std::endl;
+ length_appended_ = true;
+};
+
+// size implementation.
+inline
+unsigned buffer::size() const
+{
+ return data_.size();
+};
+
+// bit len implementation.
+inline
+unsigned buffer::bit_len() const
+{
+ return data_.size() * 32;
+}
+
+// is_append_padding implementation.
+inline
+bool buffer::is_append_padding() const
+{
+ return padding_appended_;
+}
+
+// is append_length implementation.
+inline
+bool buffer::is_append_length() const
+{
+ return length_appended_;
+}
+
+#endif // !OLENA_OLN_UTILS_BUFFER_HXX
Index: olena/oln/utils/buffer.hh
--- olena/oln/utils/buffer.hh Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/buffer.hh Fri, 19 Mar 2004 15:47:36 +0100 palma_g (oln/k/10_buffer.hh 644)
@@ -0,0 +1,125 @@
+// Copyright (C) 2004 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_OLN_UTILS_BUFFER_HH
+# define OLENA_OLN_UTILS_BUFFER_HH
+
+
+namespace oln {
+ namespace utils {
+ /*!
+ ** \brief Buffer used for MD5 data type abstraction.
+ */
+ class buffer
+ {
+ public:
+ typedef ntg::int_u32 value_type; ///< Used data type.
+
+ /*!
+ ** \brief Initialization of data.
+ */
+ buffer();
+
+ /*!
+ ** \brief Add every bits of e in data.
+ **
+ ** \arg e Element to work on.
+ ** \arg count Tell if you want to count e size in the buffer size.
+ */
+ template <class E>
+ void add(const E &e, bool count = true);
+
+ /*!
+ ** \brief Push back a bit at the end of the buffer.
+ **
+ ** true -> push back a 1\n
+ ** false -> push back a 0\n
+ **
+ ** \arg bit Bit to push.
+ ** \arg is_padding Are you adding padding bytes ?
+ */
+ void push_back(bool bit, bool is_padding = false);
+
+ /*!
+ ** \brief Return the nth word.
+ */
+ ntg::int_u32 operator[] (unsigned n) const;
+
+ /*!
+ ** \brief Append padding bits.
+ */
+ void append_padding();
+
+ /*!
+ ** \brief Append length.
+ */
+ void append_length();
+
+ /*!
+ ** \brief Return the number of words.
+ */
+ unsigned size() const;
+
+ /*!
+ ** \brief Return the length in bits.
+ */
+ unsigned bit_len() const;
+
+ /*!
+ ** \brief Tell if the buffer has already been padded.
+ */
+ bool is_append_padding() const;
+
+ /*!
+ ** \brief Tell if the length has already been appended.
+ */
+ bool is_append_length() const;
+
+ protected:
+ /*!
+ ** \brief Change order of data in a word.
+ **
+ ** \arg x Data to reorder.
+ */
+ value_type reorder(value_type x) const;
+
+ static const unsigned length_ = 100; ///< Capacity chunk.
+ /// Number of the current bit in the current word.
+ unsigned char current_bit_;
+ std::vector<value_type> data_; ///< The buffer data.
+ value_type len1_; ///< first word length
+ value_type len2_; ///< second word length
+ bool padding_appended_; ///< Status of padding.
+ bool length_appended_; ///< Status of length appending.
+ };
+
+# include <oln/utils/buffer.hxx>
+
+ } // !utils
+} // !oln
+#endif // !OLENA_OLN_UTILS_BUFFER_HH
Index: olena/oln/utils/key.hxx
--- olena/oln/utils/key.hxx Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/key.hxx Fri, 19 Mar 2004 15:45:46 +0100 palma_g (oln/k/11_key.hxx 644)
@@ -0,0 +1,72 @@
+// Copyright (C) 2004 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_OLN_UTILS_KEY_HXX
+# define OLENA_OLN_UTILS_KEY_HXX
+
+// Ctor implementation.
+inline
+key::key(const std::vector<value_type> &data)
+{
+ for (unsigned i = 0; i < 16; ++i)
+ data_[i] = data[i];
+}
+
+// [] operator implementation
+inline
+key::value_type &key::operator[](unsigned i)
+{
+ precondition(i < 16);
+ return data_[i];
+};
+
+// [] operator
+inline
+const key::value_type &key::operator[](unsigned i) const
+{
+ precondition(i < 16);
+ return data_[i];
+};
+
+// == operator
+inline
+bool key::operator ==(const key &k)
+{
+ for (unsigned i = 0; i < 16; ++i)
+ if (data_[i] != k[i])
+ return false;
+ return true;
+}
+
+// != operator
+inline
+bool key::operator !=(const key &k)
+{
+ return !(*this == k);
+}
+
+#endif // !OLENA_OLN_UTILS_KEY_HXX
Index: olena/oln/utils/key.hh
--- olena/oln/utils/key.hh Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/key.hh Fri, 19 Mar 2004 15:35:37 +0100 palma_g (oln/k/12_key.hh 644)
@@ -0,0 +1,112 @@
+// Copyright (C) 2004 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_OLN_UTILS_KEY_HH
+# define OLENA_OLN_UTILS_KEY_HH
+# include <ntg/all.hh>
+# include <vector>
+# include <iostream>
+
+namespace oln {
+ namespace utils {
+ /*!
+ ** \brief 16 bytes key
+ **
+ ** Object to have a nice representation of a MD5 result.
+ */
+ class key
+ {
+ public:
+ typedef ntg::int_u8 value_type; ///< Used data type.
+
+ /*!
+ ** \brief Constructor used to initialize the key.
+ **
+ ** \pre There must at least 16 elements in data.
+ ** \arg data Inuput data.
+ */
+ explicit key(const std::vector<value_type> &data);
+
+ /*!
+ ** \brief [] operator.
+ **
+ ** \return the ith byte of the key.
+ **
+ ** \arg i Index of the byte wanted.
+ **
+ ** This is the non const version of the operator.
+ */
+ value_type &operator[](unsigned i);
+
+ /*!
+ ** \brief [] operator.
+ **
+ ** \return the ith byte of the key.
+ **
+ ** \arg i Index of the byte wanted.
+ **
+ ** This is the const version of the operator.
+ */
+ const value_type &operator[](unsigned i) const;
+
+ /*!
+ ** \brief Check equality between two keys.
+ **
+ ** \arg k Key to be compared with.
+ */
+ bool operator ==(const key &k);
+
+ /*!
+ ** \brief Check whether two key are different.
+ **
+ ** \arg k Key to be compared with.
+ */
+ bool operator !=(const key &k);
+
+ /*!
+ ** \brief Write of representation of the key on a stream.
+ **
+ ** stream Stream to put the key on.
+ ** k Key to represent.
+ */
+ friend std::ostream &operator<<(std::ostream &stream, const key &k)
+ {
+ for (unsigned i = 0; i < 16; ++i)
+ stream << std::hex << k[i];
+ return stream;
+ }
+
+
+ protected:
+ value_type data_[16]; ///< Internal data.
+ };
+
+# include <oln/utils/key.hxx>
+
+ } // !utils
+} // !oln
+#endif // !OLENA_OLN_UTILS_KEY_HH
Index: olena/oln/utils/md5.hxx
--- olena/oln/utils/md5.hxx Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/md5.hxx Fri, 19 Mar 2004 15:35:26 +0100 palma_g (oln/k/13_md5.hxx 644)
@@ -0,0 +1,284 @@
+// Copyright (C) 2004 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_OLN_UTILS_MD5_HXX
+# define OLENA_OLN_UTILS_MD5_HXX
+
+// Ctor.
+inline
+MD5::MD5(buffer b): buffer_(b),
+ X(16),
+ T(),
+ current_(0),
+ a(0x67452301),
+ b(0xefcdab89),
+ c(0x98badcfe),
+ d(0x10325476)
+ // a(0x01234567),
+ // b(0x89abcdef),
+ // c(0xfedcba98),
+ // d(0x76543210)
+{
+ precondition(buffer_.is_append_padding());
+ precondition(buffer_.is_append_length());
+ T.reserve(64);
+ T.push_back(0xd76aa478); /* 1 */
+ T.push_back(0xe8c7b756); /* 2 */
+ T.push_back(0x242070db); /* 3 */
+ T.push_back(0xc1bdceee); /* 4 */
+ T.push_back(0xf57c0faf); /* 5 */
+ T.push_back(0x4787c62a); /* 6 */
+ T.push_back(0xa8304613); /* 7 */
+ T.push_back(0xfd469501); /* 8 */
+ T.push_back(0x698098d8); /* 9 */
+ T.push_back(0x8b44f7af); /* 10 */
+ T.push_back(0xffff5bb1); /* 11 */
+ T.push_back(0x895cd7be); /* 12 */
+ T.push_back(0x6b901122); /* 13 */
+ T.push_back(0xfd987193); /* 14 */
+ T.push_back(0xa679438e); /* 15 */
+ T.push_back(0x49b40821); /* 16 */
+ T.push_back(0xf61e2562); /* 17 */
+ T.push_back(0xc040b340); /* 18 */
+ T.push_back(0x265e5a51); /* 19 */
+ T.push_back(0xe9b6c7aa); /* 20 */
+ T.push_back(0xd62f105d); /* 21 */
+ T.push_back(0x2441453); /* 22 */
+ T.push_back(0xd8a1e681); /* 23 */
+ T.push_back(0xe7d3fbc8); /* 24 */
+ T.push_back(0x21e1cde6); /* 25 */
+ T.push_back(0xc33707d6); /* 26 */
+ T.push_back(0xf4d50d87); /* 27 */
+ T.push_back(0x455a14ed); /* 28 */
+ T.push_back(0xa9e3e905); /* 29 */
+ T.push_back(0xfcefa3f8); /* 30 */
+ T.push_back(0x676f02d9); /* 31 */
+ T.push_back(0x8d2a4c8a); /* 32 */
+ T.push_back(0xfffa3942); /* 33 */
+ T.push_back(0x8771f681); /* 34 */
+ T.push_back(0x6d9d6122); /* 35 */
+ T.push_back(0xfde5380c); /* 36 */
+ T.push_back(0xa4beea44); /* 37 */
+ T.push_back(0x4bdecfa9); /* 38 */
+ T.push_back(0xf6bb4b60); /* 39 */
+ T.push_back(0xbebfbc70); /* 40 */
+ T.push_back(0x289b7ec6); /* 41 */
+ T.push_back(0xeaa127fa); /* 42 */
+ T.push_back(0xd4ef3085); /* 43 */
+ T.push_back(0x4881d05); /* 44 */
+ T.push_back(0xd9d4d039); /* 45 */
+ T.push_back(0xe6db99e5); /* 46 */
+ T.push_back(0x1fa27cf8); /* 47 */
+ T.push_back(0xc4ac5665); /* 48 */
+ T.push_back(0xf4292244); /* 49 */
+ T.push_back(0x432aff97); /* 50 */
+ T.push_back(0xab9423a7); /* 51 */
+ T.push_back(0xfc93a039); /* 52 */
+ T.push_back(0x655b59c3); /* 53 */
+ T.push_back(0x8f0ccc92); /* 54 */
+ T.push_back(0xffeff47d); /* 55 */
+ T.push_back(0x85845dd1); /* 56 */
+ T.push_back(0x6fa87e4f); /* 57 */
+ T.push_back(0xfe2ce6e0); /* 58 */
+ T.push_back(0xa3014314); /* 59 */
+ T.push_back(0x4e0811a1); /* 60 */
+ T.push_back(0xf7537e82); /* 61 */
+ T.push_back(0xbd3af235); /* 62 */
+ T.push_back(0x2ad7d2bb); /* 63 */
+ T.push_back(0xeb86d391); /* 64 */
+};
+
+// sav() implementation.
+inline
+void MD5::sav()
+{
+ for (unsigned i = 0; i < 16; ++i)
+ X[i] = buffer_[current_ + i];
+ current_ += 16;
+ aa = a;
+ bb = b;
+ cc = c;
+ dd = d;
+}
+
+// round1() implementation.
+inline
+void MD5::round1()
+{
+ sub_step(F, a, b, c, d, 0, 7, 1);
+ sub_step(F, d, a, b, c, 1, 12, 2);
+ sub_step(F, c, d, a, b, 2, 17, 3);
+ sub_step(F, b, c, d, a, 3, 22, 4);
+ sub_step(F, a, b, c, d, 4, 7, 5);
+ sub_step(F, d, a, b, c, 5, 12, 6);
+ sub_step(F, c, d, a, b, 6, 17, 7);
+ sub_step(F, b, c, d, a, 7, 22, 8);
+ sub_step(F, a, b, c, d, 8, 7, 9);
+ sub_step(F, d, a, b, c, 9, 12, 10);
+ sub_step(F, c, d, a, b, 10, 17, 11);
+ sub_step(F, b, c, d, a, 11, 22, 12);
+ sub_step(F, a, b, c, d, 12, 7, 13);
+ sub_step(F, d, a, b, c, 13, 12, 14);
+ sub_step(F, c, d, a, b, 14, 17, 15);
+ sub_step(F, b, c, d, a, 15, 22, 16);
+}
+
+// round2() implementation.
+inline
+void MD5::round2()
+{
+ sub_step(G, a, b, c, d, 1, 5, 17);
+ sub_step(G, d, a, b, c, 6, 9, 18);
+ sub_step(G, c, d, a, b, 11, 14, 19);
+ sub_step(G, b, c, d, a, 0, 20, 20);
+ sub_step(G, a, b, c, d, 5, 5, 21);
+ sub_step(G, d, a, b, c, 10, 9, 22);
+ sub_step(G, c, d, a, b, 15, 14, 23);
+ sub_step(G, b, c, d, a, 4, 20, 24);
+ sub_step(G, a, b, c, d, 9, 5, 25);
+ sub_step(G, d, a, b, c, 14, 9, 26);
+ sub_step(G, c, d, a, b, 3, 14, 27);
+ sub_step(G, b, c, d, a, 8, 20, 28);
+ sub_step(G, a, b, c, d, 13, 5, 29);
+ sub_step(G, d, a, b, c, 2, 9, 30);
+ sub_step(G, c, d, a, b, 7, 14, 31);
+ sub_step(G, b, c, d, a, 12, 20, 32);
+}
+
+// round3() implementation.
+inline
+void MD5::round3()
+{
+ sub_step(H, a, b, c, d, 5, 4, 33);
+ sub_step(H, d, a, b, c, 8, 11, 34);
+ sub_step(H, c, d, a, b, 11, 16, 35);
+ sub_step(H, b, c, d, a, 14, 23, 36);
+ sub_step(H, a, b, c, d, 1, 4, 37);
+ sub_step(H, d, a, b, c, 4, 11, 38);
+ sub_step(H, c, d, a, b, 7, 16, 39);
+ sub_step(H, b, c, d, a, 10, 23, 40);
+ sub_step(H, a, b, c, d, 13, 4, 41);
+ sub_step(H, d, a, b, c, 0, 11, 42);
+ sub_step(H, c, d, a, b, 3, 16, 43);
+ sub_step(H, b, c, d, a, 6, 23, 44);
+ sub_step(H, a, b, c, d, 9, 4, 45);
+ sub_step(H, d, a, b, c, 12, 11, 46);
+ sub_step(H, c, d, a, b, 15, 16, 47);
+ sub_step(H, b, c, d, a, 2, 23, 48);
+}
+
+// round 4() implementation.
+inline
+void MD5::round4()
+{
+ sub_step(I, a, b, c, d, 0, 6, 49);
+ sub_step(I, d, a, b, c, 7, 10, 50);
+ sub_step(I, c, d, a, b, 14, 15, 51);
+ sub_step(I, b, c, d, a, 5, 21, 52);
+ sub_step(I, a, b, c, d, 12, 6, 53);
+ sub_step(I, d, a, b, c, 3, 10, 54);
+ sub_step(I, c, d, a, b, 10, 15, 55);
+ sub_step(I, b, c, d, a, 1, 21, 56);
+ sub_step(I, a, b, c, d, 8, 6, 57);
+ sub_step(I, d, a, b, c, 15, 10, 58);
+ sub_step(I, c, d, a, b, 6, 15, 59);
+ sub_step(I, b, c, d, a, 13, 21, 60);
+ sub_step(I, a, b, c, d, 4, 6, 61);
+ sub_step(I, d, a, b, c, 11, 10, 62);
+ sub_step(I, c, d, a, b, 2, 15, 63);
+ sub_step(I, b, c, d, a, 9, 21, 64);
+}
+
+// step implementation.
+inline
+void MD5::step()
+{
+ sav();
+ round1();
+ round2();
+ round3();
+ round4();
+ a += aa;
+ b += bb;
+ c += cc;
+ d += dd;
+};
+
+// sub step implementation.
+template <class Fun>
+inline
+void MD5::sub_step(const Fun &fun,
+ storage_type &a,
+ const storage_type &b,
+ const storage_type &c,
+ const storage_type &d,
+ unsigned k,
+ unsigned s,
+ unsigned i)
+{
+ a += fun(b, c, d) + (X[k] + T[i - 1]);
+ a = a<<s | a>>(32-s);
+ a += b;
+ //a = b + ((a + fun(b, c, d) + X[k] + T[i - 1]) << s);
+}
+
+// gen_sub_key implementation.
+inline
+void MD5::gen_sub_key(std::vector<key::value_type> &v,
+ storage_type x,
+ unsigned base)
+{
+ base *= sizeof(value_type);
+
+ for (unsigned i = 0; i < sizeof(value_type); ++i)
+ v[base + i] = (x & (0xFF << (i * 8))) >> (i * 8);
+}
+
+// gen_key implementation.
+
+inline
+key MD5::gen_key()
+{
+ std::vector<key::value_type> k;
+
+ k.reserve(16);
+ gen_sub_key(k, a, 0);
+ gen_sub_key(k, b, 1);
+ gen_sub_key(k, c, 2);
+ gen_sub_key(k, d, 3);
+ return key(k);
+}
+
+// execute implementation.
+inline
+key MD5::execute()
+{
+ while (buffer_.size() > current_)
+ step();
+ return gen_key();
+}
+#endif // !OLENA_OLN_UTILS_MD5_HXX
Index: olena/oln/utils/md5.hh
--- olena/oln/utils/md5.hh Fri, 19 Mar 2004 15:52:00 +0100 palma_g ()
+++ olena/oln/utils/md5.hh Fri, 19 Mar 2004 15:35:12 +0100 palma_g (oln/k/14_md5.hh 644)
@@ -0,0 +1,204 @@
+// Copyright (C) 2004 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_OLN_UTILS_MD5_HH
+# define OLENA_OLN_UTILS_MD5_HH
+
+# include <ntg/all.hh>
+# include <vector>
+
+# include <oln/utils/key.hh>
+# include <oln/utils/buffer.hh>
+
+namespace oln {
+ namespace utils {
+ /*!
+ ** \brief Class used to compute a MD5 digest.
+ */
+ class MD5
+ {
+ public:
+ typedef ntg::int_u32 value_type; ///< Value to work on.
+ typedef ntg_storage_type_(value_type) storage_type; ///< Representation type of value type.
+
+ /*!
+ ** \brief Constructor.
+ **
+ ** Initialization from a buffer.
+ **
+ ** \arg The buffer to use.
+ */
+ explicit MD5(buffer b);
+
+ /*!
+ ** \brief Compute the digest.
+ */
+ key execute();
+
+ /*!
+ ** \brief Generate the key.
+ **
+ ** \pre To avoid meaningless result, you should call execute before.
+ */
+ key gen_key();
+
+ protected:
+ /*!
+ ** \brief initialization of a MD5 algorithm step.
+ */
+ void sav();
+
+ /*!
+ ** \brief Round 1 of the algorithm.
+ */
+ void round1();
+
+ /*!
+ ** \brief Round 2 of the algorithm.
+ */
+ void round2();
+
+ /*!
+ ** \brief Round 3 of the algorithm.
+ */
+ void round3();
+
+ /*!
+ ** \brief Round 4 of the algorithm.
+ */
+ void round4();
+
+ /*!
+ ** \brief A step of the algorithm.
+ */
+ void step();
+
+ /*!
+ ** \brief Sub step to update a register value.
+ */
+ template <class Fun>
+ void sub_step(const Fun &fun,
+ storage_type &a,
+ const storage_type &b,
+ const storage_type &c,
+ const storage_type &d,
+ unsigned k,
+ unsigned s,
+ unsigned i);
+
+ /*!
+ ** \brief Generate a sub part of the key.
+ **
+ ** \arg v Vector of values (output).
+ ** \arg x Data to put in v.
+ ** \arg base Where to put x in v.
+ */
+ void gen_sub_key(std::vector<key::value_type> &v,
+ storage_type x,
+ unsigned base);
+
+
+ buffer buffer_; ///< The buffer to process.
+ std::vector<storage_type> X; ///< Vector of 16 words.
+ std::vector<storage_type> T; ///< Vector of 64 words.
+ unsigned current_; ///< Current position in the buffer.
+ storage_type aa; ///< Save of a.
+ storage_type bb; ///< Save of b.
+ storage_type cc; ///< Save of c.
+ storage_type dd; ///< Save of d.
+ storage_type a; ///< A register.
+ storage_type b; ///< B register.
+ storage_type c; ///< C register.
+ storage_type d; ///< D register.
+
+ /*!
+ ** \brief Functor for bit operations.
+ **
+ ** F(X,Y,Z) = XY v not(X) Z
+ */
+ struct
+ {
+ storage_type operator()(const storage_type &x,
+ const storage_type &y,
+ const storage_type &z) const
+ {
+ // return z ^ (x & (y ^ z));
+ return x & y | ~x & z;
+ }
+ } F;
+
+ /*!
+ ** \brief Functor for bit operations.
+ **
+ ** G(X,Y,Z) = XZ v Y not(Z)
+ */
+ struct
+ {
+ storage_type operator()(const storage_type &x,
+ const storage_type &y,
+ const storage_type &z) const
+ {
+ return x & z | y & ~z;
+ }
+ } G;
+
+ /*!
+ ** \brief Functor for bit operations.
+ **
+ ** H(X,Y,Z) = X xor Y xor Z
+ */
+ struct
+ {
+ storage_type operator()(const storage_type &x,
+ const storage_type &y,
+ const storage_type &z) const
+ {
+ return x ^ y ^ z;
+ }
+ } H;
+
+ /*!
+ ** \brief Functor for bit operations.
+ **
+ ** I(X,Y,Z) = Y xor (X v not(Z))
+ */
+ struct
+ {
+ storage_type operator()(const storage_type &x,
+ const storage_type &y,
+ const storage_type &z) const
+ {
+ return y ^ (x | ~z);
+ }
+ } I;
+ };
+
+#include <oln/utils/md5.hxx>
+
+ } // !utils
+} // !oln
+#endif // !OLENA_OLN_UTILS_MD5_HH
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74
Index: olena/ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* olena/oln/core/bkd_iter1d.hh: Correct comments.
* olena/oln/core/bkd_iter2d.hh: Likewise.
* olena/oln/core/bkd_iter3d.hh: Likewise.
* olena/oln/core/fwd_iter1d.hh: Likewise.
* olena/oln/core/fwd_iter2d.hh: Likewise.
* olena/oln/core/fwd_iter3d.hh: Likewise.
* olena/oln/core/abstract/iter1d.hh: Likewise.
* olena/oln/core/abstract/iter2d.hh: Likewise.
* olena/oln/core/abstract/iter3d.hh: Likewise.
* olena/oln/core/abstract/iter.hh: Likewise.
* olena/oln/core/neighborhood1d.hh: Likewise.
* olena/oln/core/neighborhood2d.hh: Likewise.
* olena/oln/core/neighborhood3d.hh: Likewise.
* olena/oln/core/abstract/neighborhood.hh: Likewise.
* olena/oln/core/abstract/struct_elt.hh: Likewise.
* olena/oln/core/window1d.hh: Likewise.
* olena/oln/core/window2d.hh: Likewise.
* olena/oln/core/window3d.hh: Likewise.
* olena/oln/core/abstract/window.hh: Likewise.
* olena/oln/core/w_window1d.hh: Likewise.
* olena/oln/core/w_window2d.hh: Likewise.
* olena/oln/core/w_window3d.hh: Likewise.
* olena/oln/core/abstract/w_window.hh: Likewise.
* olena/oln/io/base.hh: Likewise.
* olena/oln/core/abstract/window_base.hh: Likewise.
* olena/oln/core/abstract/windownd.hh: Likewise.
* olena/oln/core/abstract/w_windownd.hh: Likewise.
* olena/oln/core/abstract/neighborhoodnd.hh: Likewise.
Index: olena/oln/core/bkd_iter1d.hh
--- olena/oln/core/bkd_iter1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/38_bkd_iter1d 1.18 640)
+++ olena/oln/core/bkd_iter1d.hh Fri, 19 Mar 2004 13:41:07 +0100 odou_s (oln/d/38_bkd_iter1d 1.18 640)
@@ -99,12 +99,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/bkd_iter2d.hh
--- olena/oln/core/bkd_iter2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/37_bkd_iter2d 1.18 640)
+++ olena/oln/core/bkd_iter2d.hh Fri, 19 Mar 2004 13:41:22 +0100 odou_s (oln/d/37_bkd_iter2d 1.18 640)
@@ -98,12 +98,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/bkd_iter3d.hh
--- olena/oln/core/bkd_iter3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/36_bkd_iter3d 1.18 640)
+++ olena/oln/core/bkd_iter3d.hh Fri, 19 Mar 2004 13:41:45 +0100 odou_s (oln/d/36_bkd_iter3d 1.18 640)
@@ -95,12 +95,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string name()
{
return std::string("bkd_iter3d<") + Exact::name() + ">";
Index: olena/oln/core/fwd_iter1d.hh
--- olena/oln/core/fwd_iter1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/21_fwd_iter1d 1.15 640)
+++ olena/oln/core/fwd_iter1d.hh Fri, 19 Mar 2004 13:42:07 +0100 odou_s (oln/d/21_fwd_iter1d 1.15 640)
@@ -97,12 +97,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/fwd_iter2d.hh
--- olena/oln/core/fwd_iter2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/20_fwd_iter2d 1.15 640)
+++ olena/oln/core/fwd_iter2d.hh Fri, 19 Mar 2004 13:45:33 +0100 odou_s (oln/d/20_fwd_iter2d 1.15 640)
@@ -99,12 +99,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/fwd_iter3d.hh
--- olena/oln/core/fwd_iter3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/19_fwd_iter3d 1.15 640)
+++ olena/oln/core/fwd_iter3d.hh Fri, 19 Mar 2004 13:45:32 +0100 odou_s (oln/d/19_fwd_iter3d 1.15 640)
@@ -96,12 +96,7 @@
return super_iter_type::operator=(u);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/iter1d.hh
--- olena/oln/core/abstract/iter1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/10_iter1d.hh 1.19 640)
+++ olena/oln/core/abstract/iter1d.hh Fri, 19 Mar 2004 13:45:36 +0100 odou_s (oln/d/10_iter1d.hh 1.19 640)
@@ -88,12 +88,7 @@
return this->p_.col();
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string name()
{
return std::string("_iter1d<") + Exact::name() + ">";
Index: olena/oln/core/abstract/iter2d.hh
--- olena/oln/core/abstract/iter2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/9_iter2d.hh 1.19 640)
+++ olena/oln/core/abstract/iter2d.hh Fri, 19 Mar 2004 13:45:35 +0100 odou_s (oln/d/9_iter2d.hh 1.19 640)
@@ -101,12 +101,7 @@
return this->p_.col();
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string name()
{
return std::string("_iter2d<") + Exact::name() + ">";
Index: olena/oln/core/abstract/iter3d.hh
--- olena/oln/core/abstract/iter3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/d/8_iter3d.hh 1.19 640)
+++ olena/oln/core/abstract/iter3d.hh Fri, 19 Mar 2004 13:45:35 +0100 odou_s (oln/d/8_iter3d.hh 1.19 640)
@@ -114,12 +114,7 @@
return this->p_.col();
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string name()
{
return std::string("_iter3d<") + Exact::name() + ">";
Index: olena/oln/core/abstract/iter.hh
--- olena/oln/core/abstract/iter.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/40_iter.hh 1.21 640)
+++ olena/oln/core/abstract/iter.hh Fri, 19 Mar 2004 13:45:36 +0100 odou_s (oln/c/40_iter.hh 1.21 640)
@@ -358,12 +358,7 @@
return ! this->operator==(e);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/neighborhood1d.hh
--- olena/oln/core/neighborhood1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/37_neighborho 1.17 640)
+++ olena/oln/core/neighborhood1d.hh Fri, 19 Mar 2004 13:46:58 +0100 odou_s (oln/c/37_neighborho 1.17 640)
@@ -58,7 +58,7 @@
**
** It looks like structuring elements but here, when
** you add an element, you add its opposite.
- ** Points have 1 dimensions.
+ ** Points (dpoint) have 1 dimension.
**
*/
class neighborhood1d :
@@ -139,12 +139,7 @@
add(dpoint_type(crd[i]));
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/neighborhood2d.hh
--- olena/oln/core/neighborhood2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/36_neighborho 1.18 640)
+++ olena/oln/core/neighborhood2d.hh Fri, 19 Mar 2004 13:43:01 +0100 odou_s (oln/c/36_neighborho 1.18 640)
@@ -159,12 +159,7 @@
return r.assign(*this);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/neighborhood3d.hh
--- olena/oln/core/neighborhood3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/35_neighborho 1.17 640)
+++ olena/oln/core/neighborhood3d.hh Fri, 19 Mar 2004 13:43:18 +0100 odou_s (oln/c/35_neighborho 1.17 640)
@@ -140,12 +140,7 @@
add(dpoint_type(crd[i], crd[i+1], crd[i+2]));
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/neighborhood.hh
--- olena/oln/core/abstract/neighborhood.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/38_neighborho 1.21 640)
+++ olena/oln/core/abstract/neighborhood.hh Fri, 19 Mar 2004 16:01:20 +0100 odou_s (oln/c/38_neighborho 1.21 640)
@@ -56,8 +56,7 @@
** \brief Neighborhood.
**
** It looks like structuring elements but here, when
- ** you add an element, you add its opposite (cf mathematical
- ** definition to know more about).
+ ** you add an element, you add its opposite.
** This abstract class defines several virtual methods for his
** subclasses. Its goal is to deal with a set of deplacement points.
**
@@ -93,12 +92,7 @@
enum { dim = struct_elt_traits<Exact>::dim };
///< Set the dim of the points of the neighborhood.
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/struct_elt.hh
--- olena/oln/core/abstract/struct_elt.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/25_structelt. 1.22 640)
+++ olena/oln/core/abstract/struct_elt.hh Fri, 19 Mar 2004 16:01:45 +0100 odou_s (oln/c/25_structelt. 1.22 640)
@@ -56,7 +56,7 @@
namespace abstract {
/*!
- ** Structuring elements (set of points).
+ ** Structuring elements (set of dpoints).
**
** This abstract class defines several virtual methods for its
** subclasses. Its goal is to deal with a set of 'move' points.
@@ -72,12 +72,7 @@
typedef typename struct_elt_traits<Exact>::abstract_type abstract_type;
///< Set the abstract type of hisself.
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/window1d.hh
--- olena/oln/core/window1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/15_window1d.h 1.17 640)
+++ olena/oln/core/window1d.hh Fri, 19 Mar 2004 13:45:31 +0100 odou_s (oln/c/15_window1d.h 1.17 640)
@@ -139,12 +139,7 @@
add(dpoint_type(crd[i]));
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/window2d.hh
--- olena/oln/core/window2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/14_window2d.h 1.19 640)
+++ olena/oln/core/window2d.hh Fri, 19 Mar 2004 13:44:00 +0100 odou_s (oln/c/14_window2d.h 1.19 640)
@@ -160,12 +160,7 @@
return r.assign(*this);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/window3d.hh
--- olena/oln/core/window3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/13_window3d.h 1.18 640)
+++ olena/oln/core/window3d.hh Fri, 19 Mar 2004 13:44:21 +0100 odou_s (oln/c/13_window3d.h 1.18 640)
@@ -139,12 +139,7 @@
add(dpoint_type(crd[i], crd[i+1], crd[i+2]));
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/window.hh
--- olena/oln/core/abstract/window.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/16_window.hh 1.19 640)
+++ olena/oln/core/abstract/window.hh Fri, 19 Mar 2004 13:45:34 +0100 odou_s (oln/c/16_window.hh 1.19 640)
@@ -73,12 +73,7 @@
friend class struct_elt<exact_type>;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/w_window1d.hh
--- olena/oln/core/w_window1d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/19_w_window1d 1.18 640)
+++ olena/oln/core/w_window1d.hh Fri, 19 Mar 2004 13:45:31 +0100 odou_s (oln/c/19_w_window1d 1.18 640)
@@ -163,12 +163,7 @@
return set(dpoint_type(col), weight);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/w_window2d.hh
--- olena/oln/core/w_window2d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/18_w_window2d 1.6.1.13 640)
+++ olena/oln/core/w_window2d.hh Fri, 19 Mar 2004 13:45:31 +0100 odou_s (oln/c/18_w_window2d 1.6.1.13 640)
@@ -182,12 +182,7 @@
return set(dpoint_type(row, col), weight);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/w_window3d.hh
--- olena/oln/core/w_window3d.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/17_w_window3d 1.18 640)
+++ olena/oln/core/w_window3d.hh Fri, 19 Mar 2004 13:45:16 +0100 odou_s (oln/c/17_w_window3d 1.18 640)
@@ -169,12 +169,7 @@
return set(dpoint_type(slice, row, col), weight);
}
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/w_window.hh
--- olena/oln/core/abstract/w_window.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/c/20_w_window.h 1.16 640)
+++ olena/oln/core/abstract/w_window.hh Fri, 19 Mar 2004 13:38:37 +0100 odou_s (oln/c/20_w_window.h 1.16 640)
@@ -75,12 +75,7 @@
///< Set the type of weight.
friend class struct_elt<exact_type>;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/io/base.hh
--- olena/oln/io/base.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/b/20_base.hh 1.9 640)
+++ olena/oln/io/base.hh Fri, 19 Mar 2004 16:25:55 +0100 odou_s (oln/b/20_base.hh 1.9 640)
@@ -47,9 +47,9 @@
namespace internal {
/*!
- ** \brief Read anything from a file.
+ ** \brief Read from a file.
**
- ** The "good" read function is called by template specialization.
+ ** The specialized read function is called by template specialization.
*/
template<typename T>
bool
@@ -61,7 +61,7 @@
/*!
** \brief Write anything to a file.
**
- ** The "good" write function is called by template specialization.
+ ** The specialized write function is called by template specialization.
*/
template<typename T>
bool
@@ -79,10 +79,13 @@
** a window or a neighborhood.
** \arg name The name of the file.
** \return The new object.
+ ** \sa oln::abstract::iter
**
- ** Here is the external interface.
- ** If you would like some examples to know how to use that, go to
- ** oln::abstract::iter
+ ** Call abstract::image::has_impl to test that your image has been
+ ** successfully loaded.
+ ** See oln::io::internal::reader_id to know which file are supported.
+ ** \sa abstract::image::has_impl
+ ** \sa
*/
inline
internal::anything
@@ -92,13 +95,12 @@
}
/*
- ** \brief Load object from a file. This could be an image but also
- ** a window or a neighborhood.
+ ** \brief Load an image or a structuring element from a file.
** \arg output The object to write to a file.
** \arg name The name of the file.
** \return True if successful.
**
- ** Here is the external interface. Depending of T, work is dispatched.
+ ** Depending of T, work is dispatched.
*/
template<class T>
bool
@@ -108,15 +110,14 @@
}
/*
- ** \brief Writing object to a file. This could be an image but also
+ ** \brief Write an image or a structuring element to a file.
** a window or a neighborhood.
** \arg input The object to read.
** \arg name The name of the file.
** \return True if successful.
**
- ** Here is the external interface. Depending of T, work is dispatched.
- ** If you would like some examples to know how to use that, go to
- ** oln::abstract::iter
+ ** Depending of T, work is dispatched.
+ ** \sa oln::abstract::iter
*/
template< typename T >
bool
Index: olena/oln/core/abstract/window_base.hh
--- olena/oln/core/abstract/window_base.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/u/3_window_bas 1.11 640)
+++ olena/oln/core/abstract/window_base.hh Fri, 19 Mar 2004 13:45:34 +0100 odou_s (oln/u/3_window_bas 1.11 640)
@@ -134,12 +134,7 @@
friend class neighborhood<Exact>;
// friend class window_base_friend_traits<Sup>::ret;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/windownd.hh
--- olena/oln/core/abstract/windownd.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/u/4_windownd.h 1.9 640)
+++ olena/oln/core/abstract/windownd.hh Fri, 19 Mar 2004 13:45:33 +0100 odou_s (oln/u/4_windownd.h 1.9 640)
@@ -72,12 +72,7 @@
friend class window<exact_type>;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/w_windownd.hh
--- olena/oln/core/abstract/w_windownd.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/u/5_w_windownd 1.8 640)
+++ olena/oln/core/abstract/w_windownd.hh Fri, 19 Mar 2004 13:39:47 +0100 odou_s (oln/u/5_w_windownd 1.8 640)
@@ -74,12 +74,7 @@
friend class w_window<exact_type>;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
Index: olena/oln/core/abstract/neighborhoodnd.hh
--- olena/oln/core/abstract/neighborhoodnd.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/u/6_neighborho 1.8 640)
+++ olena/oln/core/abstract/neighborhoodnd.hh Fri, 19 Mar 2004 17:35:10 +0100 odou_s (oln/u/6_neighborho 1.8 640)
@@ -53,7 +53,9 @@
** \brief Neighborhood N dimensions.
**
** It looks like structuring elements but here, when
- ** you add an element, you add its opposite.
+ ** you add an element, you add its opposite:
+ ** \f$$\forall d \in N, -d \in N$\f$
+ **
** Points have N dimensions.
**
*/
@@ -74,12 +76,7 @@
friend class neighborhood<exact_type>;
- /*!
- ** \brief Return its type in a string.
- ** \return The type in a string.
- **
- ** Very useful to debug.
- */
+ ///< Return the name of the type.
static std::string
name()
{
--
Simon Odou
simon(a)lrde.epita.fr
Index: integre/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* integre/ntg/core/pred_succ.hh: Add file.
* integre/ntg/Makefile.am: Add file references.
+2004-03-18 Niels Van Vliet <niels(a)lrde.epita.fr>
+
+ * integre/ntg/real/behavior.hh: Change the unsafe::get<T>::check().
+ * integre/ntg/utils/cast.hh: Change cast::force().
+
2004-02-09 Giovanni Palma <giovanni(a)lrde.epita.fr>
* ntg/vect/vec.hh: Add sup() function to vec traits.
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/utils/histogram.hh: Fix doc.
* olena/oln/convert/value_to_point.hh: Likewise.
Index: olena/oln/utils/histogram.hh
--- olena/oln/utils/histogram.hh Thu, 18 Mar 2004 18:24:14 +0100
van-vl_n (oln/10_histogram. 1.6.1.14.1.10 640)
+++ olena/oln/utils/histogram.hh Fri, 19 Mar 2004 11:49:17 +0100
van-vl_n (oln/10_histogram. 1.6.1.14.1.10 640)
@@ -178,11 +178,11 @@
** number of occurrences an image3d (because rgb_8 has 3 components).
**
** \todo FIXME: An image is inside the histogram. This is incorrect
- ** because it is not exactly an image (we do not need any border).
+ ** because it is not exactly an image (no border needed).
**
** \param T Type of the image.
- ** \param CPT Type use to count the occurrences (unsinged).
- ** \param V2P Concersion class to convert a value T to a point.
+ ** \param CPT Type used to count the occurrences (unsigned).
+ ** \param V2P Conversion class to convert a value T to a point.
** \param Exact Exact type of the histogram.
**
** \see oln::abstract::histogram
@@ -227,7 +227,7 @@
/*! \brief Empty histogram.
**
- ** \note The function Init(image) should be used after this
+ ** \note The function init(image) should be used after this
** constructor.
*/
histogram(const value_to_point_type & c2p = value_to_point_type()):
@@ -292,10 +292,10 @@
/*! Minimum value of an histogram.
**
- ** It return the smaller value within the image used to build the
+ ** Return the smaller value within the image used to build the
** histogram.
**
- ** \note It can be slow when the histogram is sparse because it iterate
+ ** \note It can be slow when the histogram is sparse because it
iterates
** over a large range of 0. Use \a histogram_min or \a
histogram_minmax
** instead.
** \see histogram_min
@@ -317,11 +317,11 @@
}
/*! Maximum value of an histogram.
**
- ** It return the higher value within the image used to build the
+ ** Return the higher value within the image used to build the
** histogram.
**
** \note It can be slow when the histogram is sparse because it
- ** iterate over a large range of 0. Use histogram_max or
+ ** iterates over a large range of 0. Use histogram_max or
** histogram_minmax instead.
** \see histogram_max
*/
@@ -357,12 +357,12 @@
/*! Build the histogram and has quick min and max functions.
**
** The idea behind the min- and max-specialized histogram is to
- ** maintain worst min and max bounds while updating histogram. We
- ** don't maintain _exact_ min and max bounds, because this would
+ ** maintain worst min and max bounds while updating histogram. It
+ ** does not maintain _exact_ min and max bounds, because this would
** involve some costly computation when removing values from the
** histogram and maybe this time will be lost if the removed value is
** reinserted before max() or min() is called.\n
- ** So we update the _worst_ min and max bounds whenever the histogram
+ ** So it updates the _worst_ min and max bounds whenever the histogram
** value are accessed, and delay the _real_ min and max computation
** until min() or max() is called.
** \see histogram
@@ -687,10 +687,10 @@
// calculate the histogram of the image
utils::histogram<val> histo(im);
- // initialize the array of pointer to the point in the result
- // with the histogram we can know the number of each color and
- // then calculate an array of pointer for quick access to each
- // value of the image
+ // Initialize the array of pointer to the point in the result.
+ // With the histogram the number of each color can be deduced and
+ // then it calculates an array of pointer for quick access to each
+ // value of the image.
const ntg_cumul_type(val) card = ntg_max_val(val)
- ntg_min_val(val) + 1;
std::vector<oln_point_type(I)* > ptr(card);
@@ -741,7 +741,7 @@
*(ptr[unsigned(im[p] - ntg_min_val(val))]++) = p;
}
- /*! Select staticly the good distrib_sort.
+ /*! Select statically the good distrib_sort.
**
** \param reverse If the sort should be reverted or not.
*/
Index: integre/ntg/Makefile.am
--- integre/ntg/Makefile.am Thu, 27 Nov 2003 11:26:27 +0100 burrus_n
(oln/q/36_Makefile.a 1.8.1.1 640)
+++ integre/ntg/Makefile.am Fri, 19 Mar 2004 11:22:50 +0100 van-vl_n
(oln/q/36_Makefile.a 1.8.1.1 640)
@@ -27,6 +27,7 @@
core/internal/traits.hh \
core/interval.hh \
core/macros.hh \
+ core/pred_succ.hh \
core/predecls.hh \
core/type.hh \
core/type_traits.hh \
Index: olena/oln/convert/value_to_point.hh
--- olena/oln/convert/value_to_point.hh Thu, 18 Mar 2004 18:24:14 +0100
van-vl_n (oln/j/43_value_to_p 1.4 644)
+++ olena/oln/convert/value_to_point.hh Fri, 19 Mar 2004 11:38:53 +0100
van-vl_n (oln/j/43_value_to_p 1.4 644)
@@ -37,7 +37,8 @@
namespace convert {
/*! Convert a value of pixel to a point.
**
- ** For example it transforms an RGB color to a 3D point (ntg::rgb_8
=> oln::point3d).
+ ** For example, transform an RGB color to a 3D point
+ ** (ntg::rgb_8 => oln::point3d).
** This function is useful to build the histogram. \n
** Example:
** \verbatim
@@ -57,14 +58,15 @@
Exact>::ret>
{
private:
- /// By default a scalar is expected. If the type is a vector, a
specialization should be written.
+ /// By default a scalar is expected. If the type is a vector, a
+ /// specialization should be written.
typedef typename ntg_is_a(Argument_type,
ntg::non_vectorial)::ensure_type ensure_type;
public:
- /// By default it return a point1d.
+ /// By default return a point1d.
typedef point1d result_type;
typedef Argument_type argument_type;
- /// This class has bee made because of the lake of operator-- in
ntg::bin
+ /// Convert a binary to a point.
template <typename O, typename I>
struct doit_binary
{
@@ -75,7 +77,7 @@
return input ? O(1) : O(0);
}
};
- /// This class has bee made because of the lake of operator-- in
ntg::bin
+ /// Convert a non vectorial to a point.
template <typename O, typename I>
struct doit_not_binary
{
@@ -99,7 +101,7 @@
/*! Specialization for color of three dimension.
**
- ** \todo It could be generalized to n dimensions if there were a
trait that
+ ** \todo Could be generalized to n dimensions if there were a trait
that
** give a pointkd for a given dimension k.
*/
template <unsigned Qbits, template <unsigned> class S, class Exact>
Index: integre/ntg/core/pred_succ.hh
--- integre/ntg/core/pred_succ.hh Fri, 19 Mar 2004 11:51:05 +0100
van-vl_n ()
+++ integre/ntg/core/pred_succ.hh Fri, 19 Mar 2004 11:15:51 +0100
van-vl_n (oln/k/8_pred_succ. 644)
@@ -0,0 +1,75 @@
+// Copyright (C) 2004 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 NTG_CORE_PRED_SUCC_HH
+# define NTG_CORE_PRED_SUCC_HH
+
+#include <ntg/all.hh>
+#include <mlc/is_a.hh>
+
+namespace ntg {
+
+ namespace internal {
+ //! Return a type which supports inc and dec.
+ template <typename T>
+ struct with_arith
+ {
+ typedef typename ntg_is_a(T, non_vectorial)::ensure_type non_v;
+
+ typedef int_u<1> bool_with_arith;
+ typedef T non_vectorial_with_arith;
+
+ typedef typename mlc::if_<ntg_is_a(T, ntg::binary)::ret,
+ id_<bool_with_arith>,
+ id_<non_vectorial_with_arith> >::ret::ret ret;
+ };
+ }
+
+ /*! Return the successor of \a t.
+ **
+ ** \note The goal is to iterate on types such as ntg::bin.
+ */
+ template <typename T>
+ T
+ succ(const T &t)
+ {
+ return T(internal::with_arith<T>::ret(t) + 1);
+ }
+
+ /*! Return the predecessor of \a t.
+ **
+ ** \note The goal is to iterate on types such as ntg::bin.
+ */
+ template <typename T>
+ T
+ pred(const T&t)
+ {
+ return T(internal::with_arith<T>::ret(t) - 1);
+ }
+}
+
+#endif