Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Clean code.
* oln/core/rle/rle_image.hh, oln/core/rle/rle_psite.hh,
* oln/core/rle/rle_pset.hh, oln/core/encode/sparse_encode.hh: .
* oln/core/encode/rle_encode.hh: clean code, add comments, change comments form...
encode/rle_encode.hh | 12 +++++----
encode/sparse_encode.hh | 15 ++++++-----
rle/rle_image.hh | 30 ++++++++++++-----------
rle/rle_pset.hh | 61 +++++++++++++++++++++++++-----------------------
rle/rle_psite.hh | 19 +++++++-------
5 files changed, 73 insertions(+), 64 deletions(-)
Index: oln/core/rle/rle_image.hh
--- oln/core/rle/rle_image.hh (revision 886)
+++ oln/core/rle/rle_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Copyright (C) 2007 EPITA
// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_RLE_RLE_IMAGE_HH_
-# define OLN_CORE_RLE_RLE_IMAGE_HH_
+#ifndef OLN_CORE_RLE_RLE_IMAGE_HH
+# define OLN_CORE_RLE_RLE_IMAGE_HH
# include <map>
# include <utility>
@@ -78,13 +78,6 @@
** \class rle_image
** \brief rle image (use a pair of point range and value as representation)
**
- ** method:
- ** pset impl_points() const : return image pset
- ** bool impl_has(const point& p) const : rle_image has p?
- ** bool impl_owns_(const psite& p) const : same has impl_has
- ** void insert(const point& p, unsigned len, value val) : insert a new range on the
image
- ** rvalue impl_read(const psite& p) const : return value associated
to psite (for reading)
- ** lvalue impl_read_write(const psite& p) : lvalue
impl_read_write(const psite& p) (for writing)
*/
template < typename P, typename T>
class rle_image : public internal::primitive_image_< rle_image<P, T> >
@@ -103,11 +96,17 @@
rle_image();
+ /// pset impl_points() const : return image pset
pset impl_points() const;
+ /// bool impl_has(const point& p) const : rle_image has p?
bool impl_has(const point& p) const;
+ /// bool impl_owns_(const psite& p) const : same has impl_has
bool impl_owns_(const psite& p) const;
+ /// void insert(const point& p, unsigned len, value val) : insert a new range on
the image
void insert(const point& p, unsigned len, value val);
+ /// rvalue impl_read(const psite& p) const : return value
associated to psite (for reading)
rvalue impl_read(const psite& p) const;
+ /// lvalue impl_read_write(const psite& p) : lvalue
impl_read_write(const psite& p) (for writing)
lvalue impl_read_write(const psite& p);
};
@@ -143,7 +142,8 @@
template <typename P, typename T>
void
- rle_image<P, T>::insert(const typename rle_image<P, T>::point& p,
unsigned len, rle_image<P, T>::value val)
+ rle_image<P, T>::insert(const typename rle_image<P, T>::point& p,
+ unsigned len, rle_image<P, T>::value val)
{
this->data_->first.insert(p, len);
this->data_->second[p] = val;
@@ -156,7 +156,8 @@
typename std::map<point, value>::const_iterator irun;
irun = this->data_->second.find(ps.start_);
- assert(irun != this->data_->second.end() && ps.index_ <
this->data_->first.range_len_(ps.start_));
+ assert(irun != this->data_->second.end() &&
+ ps.index_ < this->data_->first.range_len_(ps.start_));
return irun->second;
}
@@ -167,7 +168,8 @@
typename std::map<point, value>::iterator irun;
irun = this->data_->second.find(ps.start_);
- assert(irun != this->data_->second.end() && ps.index_ <
this->data_->first.range_len_(ps.start_));
+ assert(irun != this->data_->second.end() &&
+ ps.index_ < this->data_->first.range_len_(ps.start_));
return irun->second;
}
@@ -175,4 +177,4 @@
} // end of namespace oln
-#endif /* !OLN_CORE_RLE_RLE_IMAGE_HH_ */
+#endif // !OLN_CORE_RLE_RLE_IMAGE_HH
Index: oln/core/rle/rle_psite.hh
--- oln/core/rle/rle_psite.hh (revision 886)
+++ oln/core/rle/rle_psite.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+// 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
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_RLE_RLE_PSITE_HH_
-# define OLN_CORE_RLE_RLE_PSITE_HH_
+#ifndef OLN_CORE_RLE_RLE_PSITE_HH
+# define OLN_CORE_RLE_RLE_PSITE_HH
# include <map>
@@ -44,9 +44,6 @@
** \brief psite for rle image
**
** Note: P must be a point type
- ** method:
- ** to_point: convert the psite to corresponding point
- ** operator P(): convert psite to the corresponding point
*/
template <typename P>
class rle_psite
@@ -54,11 +51,15 @@
public:
rle_psite();
+ // to_point: convert the psite to corresponding point
P to_point() const;
+ // operator P(): convert psite to the corresponding point
operator P () const;
- P start_; /*!< start of the range which contains the psite */
- unsigned index_; /*!< index of the point in the range */
+ /// start of the range which contains the psite
+ P start_;
+ /// index of the point in the range
+ unsigned index_;
};
# ifndef OLN_INCLUDE_ONLY
@@ -88,4 +89,4 @@
//end of class rle_psite
}
-#endif /* !OLN_CORE_RLE_RLE_PSITE_HH_ */
+#endif // !OLN_CORE_RLE_RLE_PSITE_HH
Index: oln/core/rle/rle_pset.hh
--- oln/core/rle/rle_pset.hh (revision 886)
+++ oln/core/rle/rle_pset.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+// 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
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_RLE_RLE_PSET_HH_
-# define OLN_CORE_RLE_RLE_PSET_HH_
+#ifndef OLN_CORE_RLE_RLE_PSET_HH
+# define OLN_CORE_RLE_RLE_PSET_HH
# include <set>
# include <utility>
@@ -71,13 +71,6 @@
** \brief pset correspoding to the rle_image class
**
** Note: P must be a point type
- ** method:
- ** unsigned impl_npoints() const : return number of point in the point set
- ** const box& impl_bbox() const : return a box which includes all poin into
the set
- ** void insert(const P& p, unsigned len): insert a new range on the point set
- ** bool impl_has(const P& p) const : if p include in the set
- ** const std_container& con() const : return the container of the point
- **
*/
template <typename P>
class rle_pset : public internal::point_set_base_<rle_pset <P> >
@@ -92,17 +85,25 @@
rle_pset();
+ /// unsigned impl_npoints() const : return number of point in the point set
unsigned impl_npoints() const;
+ /// const box& impl_bbox() const : return a box which includes all poin
into the set
const box& impl_bbox() const;
+ /// void insert(const P& p, unsigned len): insert a new range on the point set
void insert(const P& p, unsigned len);
+ /// bool impl_has(const P& p) const : if p include in the set
bool impl_has(const P& p) const;
+ /// const std_container& con() const : return the container of the point
const std_container& con() const;
unsigned range_len_(const P& range_len_) const;
protected:
- unsigned npts; /*!< number of point in the set*/
- std_container con_; /*!< container of the set*/
- fbbox_<point> fb_; /*!< pset box*/
+ /// number of point in the set
+ unsigned npts;
+ /// container of the set
+ std_container con_;
+ /// pset box
+ fbbox_<point> fb_;
};
@@ -204,12 +205,6 @@
** \brief foward iterator for rle_pset
**
** P must be a point type
- ** method:
- ** void impl_start(): set the iterator to the start of pset
- ** void impl_next(): go to next point
- ** void impl_invalidate(): invalidate iterator
- ** void impl_valid(): is the iterator valid?
- ** + conversions methods
*/
template <typename P>
class rle_pset_fwd_piter_ : public Iterator_on_Points< rle_pset_fwd_piter_<P>
>
@@ -221,11 +216,16 @@
rle_pset_fwd_piter_(const rle_pset<P>& con);
+ /// void impl_start(): set the iterator to the start of pset
void impl_start();
+ /// void impl_next(): go to next point
void impl_next();
+ /// void impl_invalidate(): invalidate iterator
void impl_invalidate();
+ /// void impl_valid(): is the iterator valid?
bool impl_is_valid() const;
+ /// conversion method
const rle_psite<P>& impl_to_psite() const;
point impl_to_point() const;
const point* impl_psite_adr() const;
@@ -235,13 +235,15 @@
protected:
const typename rle_pset<P>::std_container& con_;
typename rle_pset<P>::std_container::const_iterator it_;
- rle_psite<P> ps_; /*!< current point */
+ /// current point
+ rle_psite<P> ps_;
};
# ifndef OLN_INCLUDE_ONLY
template <typename P>
- rle_pset_fwd_piter_<P>::rle_pset_fwd_piter_(const rle_pset<P>& cont) :
con_(cont.con())
+ rle_pset_fwd_piter_<P>::rle_pset_fwd_piter_(const rle_pset<P>& cont) :
+ con_(cont.con())
{
this->it_ = this->con_.end();
}
@@ -340,12 +342,6 @@
** \brief backward iterator for rle_pset
**
** P must be a point type
- ** method:
- ** void impl_start(): set the iterator to the start of pset
- ** void impl_next(): go to next point
- ** void impl_invalidate(): invalidate iterator
- ** void impl_valid(): is the iterator valid?
- ** + conversion method
*/
template <typename P>
class rle_pset_bkd_piter_ : public Iterator_on_Points< rle_pset_bkd_piter_<P>
>
@@ -357,10 +353,16 @@
rle_pset_bkd_piter_(const rle_pset<P>& con);
+ /// void impl_start(): set the iterator to the start of pset
void impl_start();
+ /// void impl_next(): go to next point
void impl_next();
+ /// void impl_invalidate(): invalidate iterator
void impl_invalidate();
+ /// void impl_valid(): is the iterator valid?
bool impl_is_valid() const;
+
+ /// conversion methods
const rle_psite<P>& impl_to_psite() const;
point impl_to_point() const;
const point* impl_psite_adr() const;
@@ -369,7 +371,8 @@
protected:
const typename rle_pset<P>::std_container& con_;
typename rle_pset<P>::std_container::const_reverse_iterator it_;
- rle_psite<P> ps_; /*!< current point*/
+ /// current point
+ rle_psite<P> ps_;
};
# ifndef OLN_INCLUDE_ONLY
@@ -454,4 +457,4 @@
} // end of namespace oln
-#endif /* !OLN_CORE_RLE_RLE_PSET_HH_ */
+#endif // !OLN_CORE_RLE_RLE_PSET_HH
Index: oln/core/encode/sparse_encode.hh
--- oln/core/encode/sparse_encode.hh (revision 886)
+++ oln/core/encode/sparse_encode.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Copyright (C) 2007 EPITA
// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef SPARSE_ENCODE_HH_
-# define SPARSE_ENCODE_HH_
+#ifndef OLN_CORE_ENCODE_SPARSE_ENCODE_HH
+# define OLN_CORE_ENCODE_SPARSE_ENCODE_HH
# include <oln/core/concept/image.hh>
@@ -61,16 +61,17 @@
return output;
rstart = p;
+
//FIXME: is it generall ?
old = (p.to_point())[0];
- values.push_back(input(p.to_point()));
+ values.push_back(input(p));
p.next();
while (p.is_valid())
{
if ((p.to_point())[0] - 1 == old)
{
++len;
- values.push_back(input(p.to_point()));
+ values.push_back(input(p));
}
else
{
@@ -78,7 +79,7 @@
rstart = p;
len = 1;
values.clear();
- values.push_back(input(p.to_point()));
+ values.push_back(input(p));
}
old = (p.to_point())[0];
p.next();
@@ -88,4 +89,4 @@
}
}
-#endif /* !SPARSE_ENCODE_HH_ */
+#endif // !OLN_CORE_ENCODE_SPARSE_ENCODE_HH
Index: oln/core/encode/rle_encode.hh
--- oln/core/encode/rle_encode.hh (revision 886)
+++ oln/core/encode/rle_encode.hh (working copy)
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef RLE_ENCODE_HH_
-# define RLE_ENCODE_HH_
+#ifndef OLN_CORE_ENCODE_RLE_ENCODE_HH
+# define OLN_CORE_ENCODE_RLE_ENCODE_HH
# include <oln/core/concept/image.hh>
@@ -50,8 +50,10 @@
rle_image<typename I::point, typename I::value> output;
typename I::piter p (input.points());
unsigned len = 1;
- typename I::point rstart; /*!< range pointstart */
- typename I::value rvalue; /*!< range value */
+ /// range point start
+ typename I::point rstart;
+ /// range value
+ typename I::value rvalue;
p.start();
if (!p.is_valid())
@@ -78,4 +80,4 @@
}
} // end of namespace oln
-#endif /* !RLE_ENCODE_HH_ */
+#endif /* !OLN_CORE_ENCODE_RLE_ENCODE_HH */