New implementation of Has_timestamp

This commit is contained in:
Laurent Rineau 2014-04-15 18:00:06 +02:00
parent f8a97dc424
commit 75c61a687d
8 changed files with 66 additions and 92 deletions

View File

@ -471,6 +471,8 @@ public:
}
#endif // CGAL_INTRUSIVE_LIST
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -514,16 +516,6 @@ private:
}; // end class Compact_mesh_cell_base_3
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Cb >
struct Has_timestamp< Compact_mesh_cell_base_3<GT, MT, Cb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
template < class GT, class MT, class Cb >
std::istream&
operator>>(std::istream &is,

View File

@ -59,7 +59,7 @@ struct Detect_polyline_less
{
typedef typename std::iterator_traits<Handle>::value_type Type;
typedef typename boost::mpl::if_c<
CGAL::internal::Mesh_3::Has_timestamp<Type>::value,
CGAL::internal::Has_timestamp<Type>::value,
CGAL_with_time_stamp<Handle>,
CGAL_no_time_stamp<Handle> >::type Comparator;
return Comparator::less(h1, h2);

View File

@ -668,7 +668,7 @@ build_priority_queue(const FT& sliver_bound, PQueue& pqueue) const
int pqueue_size = 0;
typedef typename std::iterator_traits<Vertex_handle>::value_type Vertex;
typedef CGAL::internal::Mesh_3::Has_timestamp<Vertex> Vertex_has_timestamp;
typedef CGAL::internal::Has_timestamp<Vertex> Vertex_has_timestamp;
using CGAL::internal::Mesh_3::VHash;
typedef VHash<Tr, Vertex_has_timestamp::value> Hash_fct;
typedef boost::unordered_map<Vertex_handle,PVertex,Hash_fct> M;

View File

@ -163,6 +163,7 @@ public:
}
#endif // CGAL_INTRUSIVE_LIST
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -184,16 +185,6 @@ private:
}; // end class Mesh_cell_base_3
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Cb >
struct Has_timestamp< Mesh_cell_base_3<GT, MT, Cb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
template < class GT, class MT, class Cb >
std::istream&
operator>>(std::istream &is,

View File

@ -63,6 +63,8 @@ public:
indices.insert(i);
}
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -101,6 +103,8 @@ public:
this->opposite()->feature_edge = b;
}
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -133,6 +137,8 @@ public:
patch_id_ = i;
}
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -185,33 +191,6 @@ struct Mesh_polyhedron_3
typedef type Type;
};
namespace internal {
namespace Mesh_3 {
template <typename Refs, typename Tag, typename Pt, typename P_id>
struct Has_timestamp<CGAL::Mesh_3::Mesh_polyhedron_vertex<Refs, Tag, Pt, P_id> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
namespace internal {
namespace Mesh_3 {
template <class Refs, class Tprev, class Tv, class Tf>
struct Has_timestamp<CGAL::Mesh_3::Mesh_polyhedron_halfedge<Refs, Tprev, Tv, Tf> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
namespace internal {
namespace Mesh_3 {
template <class Refs, class T_, class Pln_, class Pid_>
struct Has_timestamp<CGAL::Mesh_3::Mesh_polyhedron_face<Refs, T_, Pln_, Pid_> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
} // end namespace CGAL
#endif // CGAL_MESH_POLYHEDRON_3_H

View File

@ -126,6 +126,8 @@ public:
}
#endif
typedef Tag_true Has_timestamp;
std::size_t time_stamp() const {
return time_stamp_;
}
@ -192,15 +194,6 @@ private:
}; // end class Mesh_vertex_base_3
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Vb >
struct Has_timestamp< Mesh_vertex_base_3<GT, MT, Vb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
template<class GT,
class MD,
class Vb>

View File

@ -149,6 +149,22 @@ public:
void reset() {}
};
template <class T,
class TimeStamper_,
bool has_ts = CGAL::internal::Has_timestamp<T>::value>
struct CC_ts_impl_impl : public CGAL_time_stamper<T>
{};
template <class T,
class TimeStamper_>
struct CC_ts_impl_impl<T, TimeStamper_, false> : public CGAL_no_time_stamp<T>
{};
template <class T,
class TimeStamper_>
struct CC_ts_impl : public CC_ts_impl_impl<T, TimeStamper_>
{};
template < class T,
class Allocator_ = Default,
class TimeStamper_ = Default >
@ -158,11 +174,7 @@ class Compact_container
typedef typename Default::Get< Al, CGAL_ALLOCATOR(T) >::type Allocator;
typedef TimeStamper_ Ts;
typedef typename boost::mpl::if_c<
CGAL::internal::Mesh_3::Has_timestamp<T>::value,
CGAL_time_stamper<T>,
CGAL_no_time_stamp<T> >::type Time_stamper_;
typedef typename Default::Get<Ts, Time_stamper_>::type Time_stamper;
typedef CC_ts_impl<T, Ts> Time_stamper_impl;
typedef Compact_container <T, Al, Ts> Self;
typedef Compact_container_traits <T> Traits;
@ -185,7 +197,7 @@ public:
explicit Compact_container(const Allocator &a = Allocator())
: alloc(a)
, time_stamper()
, time_stamper(new Time_stamper_impl())
{
init();
}
@ -194,7 +206,7 @@ public:
Compact_container(InputIterator first, InputIterator last,
const Allocator & a = Allocator())
: alloc(a)
, time_stamper()
, time_stamper(new Time_stamper_impl())
{
init();
std::copy(first, last, CGAL::inserter(*this));
@ -203,11 +215,11 @@ public:
// The copy constructor and assignment operator preserve the iterator order
Compact_container(const Compact_container &c)
: alloc(c.get_allocator())
, time_stamper()
, time_stamper(new Time_stamper_impl())
{
init();
block_size = c.block_size;
time_stamper = c.time_stamper;
*time_stamper = *c.time_stamper;
std::copy(c.begin(), c.end(), CGAL::inserter(*this));
}
@ -223,6 +235,7 @@ public:
~Compact_container()
{
clear();
delete time_stamper;
}
void swap(Self &c)
@ -281,7 +294,7 @@ public:
new (ret) value_type(args...);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
#else
@ -296,7 +309,7 @@ public:
new (ret) value_type();
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -312,7 +325,7 @@ public:
new (ret) value_type(t1);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -328,7 +341,7 @@ public:
new (ret) value_type(t1, t2);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -344,7 +357,7 @@ public:
new (ret) value_type(t1, t2, t3);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -360,7 +373,7 @@ public:
new (ret) value_type(t1, t2, t3, t4);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -377,7 +390,7 @@ public:
new (ret) value_type(t1, t2, t3, t4, t5);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -395,7 +408,7 @@ public:
new (ret) value_type(t1, t2, t3, t4, t5, t6);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -413,7 +426,7 @@ public:
new (ret) value_type(t1, t2, t3, t4, t5, t6, t7);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -431,7 +444,7 @@ public:
new (ret) value_type(t1, t2, t3, t4, t5, t6, t7, t8);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
#endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
@ -446,7 +459,7 @@ public:
alloc.construct(ret, t);
CGAL_assertion(type(ret) == USED);
++size_;
time_stamper.set_time_stamp(ret);
time_stamper->set_time_stamp(ret);
return iterator(ret, 0);
}
@ -637,7 +650,7 @@ private:
first_item = NULL;
last_item = NULL;
all_items = All_items();
time_stamper.reset();
time_stamper->reset();
}
allocator_type alloc;
@ -648,7 +661,7 @@ private:
pointer first_item;
pointer last_item;
All_items all_items;
Time_stamper time_stamper;
Time_stamper_impl* time_stamper;
};
template < class T, class Allocator, class TimeStamper>
@ -794,7 +807,6 @@ namespace internal {
typedef typename DSC::value_type value_type;
typedef typename DSC::size_type size_type;
typedef typename DSC::difference_type difference_type;
typedef typename DSC::Time_stamper TimeStamper;
typedef typename boost::mpl::if_c< Const, const value_type*,
value_type*>::type pointer;
typedef typename boost::mpl::if_c< Const, const value_type&,
@ -830,6 +842,8 @@ namespace internal {
private:
typedef typename DSC::Time_stamper_impl Time_stamper_impl;
union {
pointer p;
void *vp;
@ -932,23 +946,23 @@ namespace internal {
// For std::less...
bool operator<(const CC_iterator& other) const
{
return TimeStamper::less(m_ptr.p, other.m_ptr.p);
return Time_stamper_impl::less(m_ptr.p, other.m_ptr.p);
}
bool operator>(const CC_iterator& other) const
{
return TimeStamper::less(other.m_ptr.p, m_ptr.p);
return Time_stamper_impl::less(other.m_ptr.p, m_ptr.p);
}
bool operator<=(const CC_iterator& other) const
{
return TimeStamper::less(m_ptr.p, other.m_ptr.p)
return Time_stamper_impl::less(m_ptr.p, other.m_ptr.p)
|| (*this == other);
}
bool operator>=(const CC_iterator& other) const
{
return TimeStamper::less(other.m_ptr.p, m_ptr.p)
return Time_stamper_impl::less(other.m_ptr.p, m_ptr.p)
|| (*this == other);
}

View File

@ -17,8 +17,8 @@
//
// Author(s) : Jane Tournois
#ifndef CGAL_MESH_3_HAS_TIMESTAMP_H
#define CGAL_MESH_3_HAS_TIMESTAMP_H
#ifndef CGAL_HAS_TIMESTAMP_H
#define CGAL_HAS_TIMESTAMP_H
#include <boost/mpl/has_xxx.hpp>
#include <CGAL/tags.h>
@ -26,18 +26,23 @@
namespace CGAL {
namespace internal {
namespace Mesh_3 {
BOOST_MPL_HAS_XXX_TRAIT_DEF(Has_timestamp)
// to have Mesh_3 deterministic,
// a partial specialization of this class should be written next to
// every class that implements concepts MeshCellBase_3 or MeshVertexBase_3
template <typename T>
struct Has_timestamp : public CGAL::Tag_false
template <typename T, bool has_ts = has_Has_timestamp<T>::value>
struct Has_timestamp : public T::Has_timestamp
// when T does not have a partial specialization of Has_timestamp
{};
template <typename T>
struct Has_timestamp<T, false> : public Tag_false
// when T does not have a partial specialization of Has_timestamp
{};
} // end namespace internal::Mesh_3
} // end namespace internal
} // end namespace CGAL
#endif // CGAL_MESH_3_HAS_TIMESTAMP_H
#endif // CGAL_HAS_TIMESTAMP_H