* mln/core/site_set/p_complex.hh (mln::p_complex<D, P>::cplx_):
* mln/core/site_set/p_faces.hh (mln::p_faces<D, P>::cplx_):
Remove the tracked_ptr wrapper and change type to
mutable complex<D>.
(p_complex<D, P>::p_complex(const complex<D>&))
(p_faces<N, D, P>::p_faces(const complex<D>&)):
Adjust ctors.
(p_complex<D, P>::nfaces)
(p_complex<D, P>::is_valid)
(p_complex<D, P>::cplx)
(p_faces<N, D, P>::nfaces)
(p_faces<N, D, P>::is_valid)
(p_faces<N, D, P>::cplx)
(operator==(const p_complex<D, P>&, const p_complex<D, P>&))
(operator< (const p_complex<D, P>&, const p_complex<D, P>&))
(operator==(const p_faces<N, D, P>&, const p_faces<N, D, P>&))
(operator< (const p_faces<N, D, P>&, const p_faces<N, D, P>&)):
Adjust.
---
milena/ChangeLog | 23 ++++++++++++++
milena/mln/core/site_set/p_complex.hh | 55 ++++++++++++--------------------
milena/mln/core/site_set/p_faces.hh | 44 +++++++++++++++-----------
3 files changed, 69 insertions(+), 53 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5ace73e..6e0cd55 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -74,6 +74,29 @@
2008-09-23 Roland Levillain <roland(a)lrde.epita.fr>
+ No longer hold complexes through tracked_ptr in site sets.
+
+ * mln/core/site_set/p_complex.hh (mln::p_complex<D, P>::cplx_):
+ * mln/core/site_set/p_faces.hh (mln::p_faces<D, P>::cplx_):
+ Remove the tracked_ptr wrapper and change type to
+ mutable complex<D>.
+ (p_complex<D, P>::p_complex(const complex<D>&))
+ (p_faces<N, D, P>::p_faces(const complex<D>&)):
+ Adjust ctors.
+ (p_complex<D, P>::nfaces)
+ (p_complex<D, P>::is_valid)
+ (p_complex<D, P>::cplx)
+ (p_faces<N, D, P>::nfaces)
+ (p_faces<N, D, P>::is_valid)
+ (p_faces<N, D, P>::cplx)
+ (operator==(const p_complex<D, P>&, const p_complex<D, P>&))
+ (operator< (const p_complex<D, P>&, const p_complex<D, P>&))
+ (operator==(const p_faces<N, D, P>&, const p_faces<N, D, P>&))
+ (operator< (const p_faces<N, D, P>&, const p_faces<N, D, P>&)):
+ Adjust.
+
+2008-09-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Have the compiler check more code, even in NDEBUG mode.
* mln/core/complex.hh (mln::complex<D>::add_face): Use
diff --git a/milena/mln/core/site_set/p_complex.hh
b/milena/mln/core/site_set/p_complex.hh
index 6065df4..6c30c25 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -33,7 +33,6 @@
# include <mln/core/internal/site_set_base.hh>
-# include <mln/util/tracked_ptr.hh>
# include <mln/core/complex.hh>
# include <mln/core/complex_psite.hh>
@@ -44,6 +43,8 @@ namespace mln
{
// Forward declarations.
+ template <unsigned D, typename P> class p_complex;
+
template <unsigned D, typename P> class p_complex_fwd_piter_;
template <unsigned D, typename P> class p_complex_bkd_piter_;
@@ -98,9 +99,6 @@ namespace mln
/// \brief Construct a complex psite set from a complex.
///
/// \param gr The complex upon which the complex psite set is built.
- ///
- /// \a gr is \em copied internally, so that the complex psite set is
- /// still valid after the initial complex has been removed.
p_complex (const complex<D>& cplx);
/// Associated types.
@@ -161,29 +159,20 @@ namespace mln
private:
/// The complex on which this pset is built.
- /* FIXME:Get rid of this `mutable' qualifier. This is needed for
- compatiblity reasons with any_face_handle (see p_complex_piter)
+ /* FIXME: Get rid of this `mutable' qualifier. This is needed for
+ compatiblity reasons with any_face_handle (see
+ p_complex_piter).
We should either
- - do not use any_face_handle in the implementation of
- p_complex_piter;
-
- - have an additional version of any_face_handles holding a
+ - have an additional version of any_face_handle holding a
const (not mutable) complex;
- - or even have face_handle and any_face_handle do not hold a
- reference on a complex, leading to a design of complexes
- similar to graphs, where vertex and edge handles (named `id's)
- are not tied to a specific graph. */
- mutable util::tracked_ptr< complex<D> > cplx_;
-
- // FIXME: Remove as soon as the tracked_ptr is move into the
- // complex itself.
- template <unsigned D_, typename P_>
- friend
- bool operator==(const p_complex<D_, P_>& lhs,
- const p_complex<D_, P_>& rhs);
+ - have face_handle and any_face_handle do not hold a reference
+ on a complex, leading to a design of complexes similar to
+ graphs, where vertex and edge handles (named `id's) are not
+ tied to a specific graph. */
+ mutable complex<D> cplx_;
};
@@ -214,8 +203,7 @@ namespace mln
template <unsigned D, typename P>
inline
p_complex<D, P>::p_complex(const complex<D>& cplx)
- // Create a deep, managed copy of CPLX.
- : cplx_(new complex<D>(cplx))
+ : cplx_(cplx)
{
}
@@ -232,7 +220,7 @@ namespace mln
std::size_t
p_complex<D, P>::nfaces() const
{
- return cplx_->nfaces();
+ return cplx_.nfaces();
}
template <unsigned D, typename P>
@@ -240,8 +228,7 @@ namespace mln
bool
p_complex<D, P>::is_valid() const
{
- // FIXME: Might be too low-level, again.
- return (cplx_.ptr_);
+ return true;
}
template <unsigned D, typename P>
@@ -272,7 +259,7 @@ namespace mln
p_complex<D, P>::cplx() const
{
mln_precondition(is_valid());
- return *cplx_.ptr_;
+ return cplx_;
}
template <unsigned D, typename P>
@@ -280,7 +267,7 @@ namespace mln
p_complex<D, P>::cplx()
{
mln_precondition(is_valid());
- return *cplx_.ptr_;
+ return cplx_;
}
@@ -292,17 +279,17 @@ namespace mln
bool
operator==(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs)
{
- /* FIXME: We should not rely on pointer equality here, as graph
- will soon become shells using (shared) tracked pointers to
- actual data. So, delegate the equality test to the graphs
- themselves. */
- return lhs.cplx_.ptr_ == rhs.cplx_.ptr_;
+ /* FIXME: When actual location data is attached to a p_complex,
+ check also the equlity w.r.t. to these data. */
+ return lhs.cplx() == rhs.cplx();
}
template <unsigned D, typename P>
bool
operator<=(const p_complex<D, P>& lhs, const p_complex<D, P>&
rhs)
{
+ /* FIXME: When actual location data is attached to a p_complex,
+ check also the equality w.r.t. to these data. */
return lhs == rhs;
}
diff --git a/milena/mln/core/site_set/p_faces.hh b/milena/mln/core/site_set/p_faces.hh
index 025023d..3c48100 100644
--- a/milena/mln/core/site_set/p_faces.hh
+++ b/milena/mln/core/site_set/p_faces.hh
@@ -35,7 +35,6 @@
# include <mln/core/internal/site_set_base.hh>
# include <mln/accu/bbox.hh>
-# include <mln/util/tracked_ptr.hh>
# include <mln/core/complex.hh>
# include <mln/core/faces_psite.hh>
@@ -77,12 +76,10 @@ namespace mln
typedef p_faces<N, D, P> self_;
typedef internal::site_set_base_< faces_psite<N, D, P>, self_ > super_;
- /// \brief Construct a complex psite set from a complex.
+ /// \brief Construct a faces psite set from an mln::complex.
///
/// \param gr The complex upon which the complex psite set is built.
///
- /// \a gr is \em copied internally, so that the complex psite set is
- /// still valid after the initial complex has been removed.
p_faces (const complex<D>& cplx);
/// Associated types.
@@ -144,12 +141,19 @@ namespace mln
private:
/// The complex on which this pset is built.
- util::tracked_ptr< complex<D> > cplx_;
+ /* FIXME: Get rid of this `mutable' qualifier. This is needed for
+ compatiblity reasons with face_handle (see p_faces_piter).
- template <unsigned D_, unsigned N_, typename P_>
- friend
- bool operator==(const p_faces<D_, N_, P_>& lhs,
- const p_faces<D_, N_, P_>& rhs);
+ We should either
+
+ - have an additional version of face_handle holding a const
+ (not mutable) complex;
+
+ - have face_handle and any_face_handle do not hold a reference
+ on a complex, leading to a design of complexes similar to
+ graphs, where vertex and edge handles (named `id's) are not
+ tied to a specific graph. */
+ mutable complex<D> cplx_;
};
@@ -180,8 +184,7 @@ namespace mln
template <unsigned N, unsigned D, typename P>
inline
p_faces<N, D, P>::p_faces(const complex<D>& cplx)
- // Create a deep, managed copy of CPLX.
- : cplx_(new complex<D>(cplx))
+ : cplx_(cplx)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
@@ -200,7 +203,7 @@ namespace mln
std::size_t
p_faces<N, D, P>::nfaces() const
{
- return cplx_->template nfaces<N>();
+ return cplx_.template nfaces<N>();
}
template <unsigned N, unsigned D, typename P>
@@ -208,8 +211,7 @@ namespace mln
bool
p_faces<N, D, P>::is_valid() const
{
- // FIXME: Might be too low-level, again.
- return (cplx_.ptr_);
+ return true;
}
template <unsigned N, unsigned D, typename P>
@@ -239,16 +241,16 @@ namespace mln
complex<D>&
p_faces<N, D, P>::cplx() const
{
- mln_precondition(cplx_);
- return *cplx_.ptr_;
+ mln_precondition(is_valid());
+ return cplx_;
}
template <unsigned N, unsigned D, typename P>
complex<D>&
p_faces<N, D, P>::cplx()
{
- mln_precondition(cplx_);
- return *cplx_.ptr_;
+ mln_precondition(is_valid());
+ return cplx_;
}
@@ -260,13 +262,17 @@ namespace mln
bool
operator==(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs)
{
- return lhs.cplx_.ptr_ == rhs.cplx_.ptr_;
+ /* FIXME: When actual location data is attached to a p_faces,
+ check also the equality w.r.t. to these data. */
+ return lhs.cplx() == rhs.cplx();
}
template <unsigned N, unsigned D, typename P>
bool
operator<=(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs)
{
+ /* FIXME: When actual location data is attached to a p_faces,
+ check also the equality w.r.t. to these data. */
return lhs == rhs;
}
--
1.6.0.1