Rename Tag.

This commit is contained in:
Marc Glisse 2013-01-01 13:25:40 +01:00
parent 023eaa2270
commit e71d7c93b1
8 changed files with 61 additions and 45 deletions

View File

@ -64,6 +64,8 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
template<class, class=void> struct Type {}; template<class, class=void> struct Type {};
template<class D> struct Type< Point_tag, D> { typedef Vector_ type; }; template<class D> struct Type< Point_tag, D> { typedef Vector_ type; };
template<class D> struct Type<Vector_tag, D> { typedef Vector_ type; }; template<class D> struct Type<Vector_tag, D> { typedef Vector_ type; };
template<class D> struct Type< RT_tag, D> { typedef RT type; };
template<class D> struct Type< FT_tag, D> { typedef FT type; };
typedef typeset<Point_tag> typedef typeset<Point_tag>
::add<Vector_tag>::type ::add<Vector_tag>::type

View File

@ -48,9 +48,9 @@ struct Cartesian_change_FT_base : public
}; };
*/ */
template<class Tag,class Type_> template<class Tag_,class Type_>
struct Construct_cartesian_const_iterator_ { struct Construct_cartesian_const_iterator_ {
typedef typename Get_functor<Kernel_base, Tag>::type Functor_base; typedef typename Get_functor<Kernel_base, Tag_>::type Functor_base;
Construct_cartesian_const_iterator_(){} Construct_cartesian_const_iterator_(){}
Construct_cartesian_const_iterator_(Self const&r):f(r){} Construct_cartesian_const_iterator_(Self const&r):f(r){}
Functor_base f; Functor_base f;
@ -67,9 +67,9 @@ struct Cartesian_change_FT_base : public
typedef Construct_cartesian_const_iterator_<Construct_ttag<Point_cartesian_const_iterator_tag>,Point_cartesian_const_iterator> Construct_point_cartesian_const_iterator; typedef Construct_cartesian_const_iterator_<Construct_ttag<Point_cartesian_const_iterator_tag>,Point_cartesian_const_iterator> Construct_point_cartesian_const_iterator;
typedef Construct_cartesian_const_iterator_<Construct_ttag<Vector_cartesian_const_iterator_tag>,Vector_cartesian_const_iterator> Construct_vector_cartesian_const_iterator; typedef Construct_cartesian_const_iterator_<Construct_ttag<Vector_cartesian_const_iterator_tag>,Vector_cartesian_const_iterator> Construct_vector_cartesian_const_iterator;
template<class Tag> template<class Tag_>
struct Compute_cartesian_coordinate { struct Compute_cartesian_coordinate {
typedef typename Get_functor<Kernel_base, Tag>::type Functor_base; typedef typename Get_functor<Kernel_base, Tag_>::type Functor_base;
Compute_cartesian_coordinate(){} Compute_cartesian_coordinate(){}
Compute_cartesian_coordinate(Self const&r):f(r){} Compute_cartesian_coordinate(Self const&r):f(r){}
Functor_base f; Functor_base f;

View File

@ -10,10 +10,10 @@
namespace CGAL { namespace CGAL {
namespace internal { namespace internal {
template<class K,class Tag,bool=iterator_tag_traits<Tag>::is_iterator> template<class K,class Tag_,bool=iterator_tag_traits<Tag_>::is_iterator>
struct Type_or_iter : K::template Type<Tag> {}; struct Type_or_iter : K::template Type<Tag_> {};
template<class K,class Tag> template<class K,class Tag_>
struct Type_or_iter<K, Tag, true> : K::template Iterator<Tag> {}; struct Type_or_iter<K, Tag_, true> : K::template Iterator<Tag_> {};
} }
template<class K, class Base=K, class List=typename typeset_union<typename K::Object_list,typename K::Iterator_list>::type> struct Define_kernel_types; template<class K, class Base=K, class List=typename typeset_union<typename K::Object_list,typename K::Iterator_list>::type> struct Define_kernel_types;
template<class K, class Base> template<class K, class Base>

View File

@ -52,13 +52,13 @@ template<class Final_, class K1, class K2, class List>
class KernelD_converter_ class KernelD_converter_
: public KernelD_converter_<Final_,K1,K2,typename List::tail> : public KernelD_converter_<Final_,K1,K2,typename List::tail>
{ {
typedef typename List::head Tag; typedef typename List::head Tag_;
typedef typename List::tail Rest; typedef typename List::tail Rest;
typedef KernelD_converter_<Final_,K1,K2,Rest> Base; typedef KernelD_converter_<Final_,K1,K2,Rest> Base;
typedef typename Get_type<K1,Tag>::type K1_Obj; typedef typename Get_type<K1,Tag_>::type K1_Obj;
typedef typename Get_type<K2,Tag>::type K2_Obj; typedef typename Get_type<K2,Tag_>::type K2_Obj;
typedef typename Get_functor<K1, Convert_ttag<Tag> >::type K1_Conv; typedef typename Get_functor<K1, Convert_ttag<Tag_> >::type K1_Conv;
typedef KO_converter<Tag,K1,K2> KOC; typedef KO_converter<Tag_,K1,K2> KOC;
typedef BOOSTD is_same<K1_Conv, Null_functor> no_converter; typedef BOOSTD is_same<K1_Conv, Null_functor> no_converter;
typedef typename internal::Map_taglist_to_typelist<K1,Rest>::type::template contains<K1_Obj> duplicate; typedef typename internal::Map_taglist_to_typelist<K1,Rest>::type::template contains<K1_Obj> duplicate;
@ -68,7 +68,7 @@ class KernelD_converter_
// If Point==Vector, keep only one conversion // If Point==Vector, keep only one conversion
duplicate::value || duplicate::value ||
// For iterator objects, the default is make_transforming_iterator // For iterator objects, the default is make_transforming_iterator
(iterator_tag_traits<Tag>::is_iterator && no_converter::value), (iterator_tag_traits<Tag_>::is_iterator && no_converter::value),
Do_not_use,K1_Obj>::type argument_type; Do_not_use,K1_Obj>::type argument_type;
//typedef typename KOC::argument_type K1_Obj; //typedef typename KOC::argument_type K1_Obj;
//typedef typename KOC::result_type K2_Obj; //typedef typename KOC::result_type K2_Obj;

View File

@ -79,12 +79,12 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
// Kernel_d requires a common iterator type for points and vectors // Kernel_d requires a common iterator type for points and vectors
// TODO: provide this mixed functor in preKernel? // TODO: provide this mixed functor in preKernel?
CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename boost::result_of<CVI(Vector_d,CGAL::Begin_tag)>::type>::type, result_type>::value)); CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename boost::result_of<CVI(Vector_d,CGAL::Begin_tag)>::type>::type, result_type>::value));
template <class Tag> template <class Tag_>
result_type operator()(Point_d const&p, Tag t)const{ result_type operator()(Point_d const&p, Tag_ t)const{
return CPI(this->kernel())(p,t); return CPI(this->kernel())(p,t);
} }
template <class Tag> template <class Tag_>
result_type operator()(Vector_d const&v, Tag t)const{ result_type operator()(Vector_d const&v, Tag_ t)const{
return CVI(this->kernel())(v,t); return CVI(this->kernel())(v,t);
} }

View File

@ -41,16 +41,16 @@ namespace CGAL {
template<class>struct Convert_ttag {}; template<class>struct Convert_ttag {};
template<class> struct map_functor_type { typedef Misc_tag type; }; template<class> struct map_functor_type { typedef Misc_tag type; };
template<class Tag, class Obj, class Base> struct Typedef_tag_type; template<class Tg, class Obj, class Base> struct Typedef_tag_type;
//template<class Kernel, class Tag> struct Read_tag_type {}; //template<class Kernel, class Tg> struct Read_tag_type {};
template<class Kernel, class Tag> template<class Kernel, class Tg>
struct Provides_type struct Provides_type
: Has_type_different_from<Get_type<Kernel, Tag>, Null_type> {}; : Has_type_different_from<Get_type<Kernel, Tg>, Null_type> {};
template<class Kernel, class Tag, class O=void> template<class Kernel, class Tg, class O=void>
struct Provides_functor struct Provides_functor
: Has_type_different_from<Get_functor<Kernel, Tag, O>, Null_functor> {}; : Has_type_different_from<Get_functor<Kernel, Tg, O>, Null_functor> {};
template<class K, class List, bool=boost::mpl::empty<List>::type::value> template<class K, class List, bool=boost::mpl::empty<List>::type::value>
struct Provides_functors : boost::mpl::and_ < struct Provides_functors : boost::mpl::and_ <
@ -67,25 +67,27 @@ namespace CGAL {
struct Provides_types<K, List, true> : boost::true_type {}; struct Provides_types<K, List, true> : boost::true_type {};
namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Type) } namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Type) }
template<class Kernel, class Tag, template<class Kernel, class Tg,
bool = internal::has_Type<Kernel>::value /* false */> bool = internal::has_Type<Kernel>::value /* false */>
struct Provides_type_i : boost::false_type {}; struct Provides_type_i : boost::false_type {};
template<class Kernel, class Tag> template<class Kernel, class Tg>
struct Provides_type_i <Kernel, Tag, true> struct Provides_type_i <Kernel, Tg, true>
: Has_type_different_from<typename Kernel::template Type<Tag>, Null_type> {}; : Has_type_different_from<typename Kernel::template Type<Tg>, Null_type> {};
namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Functor) } namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Functor) }
template<class Kernel, class Tag, class O=void, template<class Kernel, class Tg, class O=void,
bool = internal::has_Functor<Kernel>::value /* false */> bool = internal::has_Functor<Kernel>::value /* false */>
struct Provides_functor_i : boost::false_type {}; struct Provides_functor_i : boost::false_type {};
template<class Kernel, class Tag, class O> template<class Kernel, class Tg, class O>
struct Provides_functor_i <Kernel, Tag, O, true> struct Provides_functor_i <Kernel, Tg, O, true>
: Has_type_different_from<typename Kernel::template Functor<Tag, O>, Null_type> {}; : Has_type_different_from<typename Kernel::template Functor<Tg, O>, Null_type> {};
#define DECL_OBJ(X) struct X##_tag {}; \ #define DECL_OBJ_(X) \
template<class Obj,class Base> \ template<class Obj,class Base> \
struct Typedef_tag_type<X##_tag, Obj, Base> : Base { typedef Obj X; }; struct Typedef_tag_type<X##_tag, Obj, Base> : Base { typedef Obj X; }
#define DECL_OBJ(X) struct X##_tag {}; \
DECL_OBJ_(X)
//namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) }
//template<class Kernel> //template<class Kernel>
@ -97,6 +99,14 @@ namespace CGAL {
DECL_OBJ(FT); DECL_OBJ(FT);
DECL_OBJ(RT); DECL_OBJ(RT);
//DECL_OBJ(Boolean); // FIXME: Boolean_tag is already taken, and is a template :-(
DECL_OBJ(Comparison_result);
DECL_OBJ(Sign);
DECL_OBJ(Orientation); // Note: duplicate with the functor tag!
DECL_OBJ(Oriented_side);
DECL_OBJ(Bounded_side);
DECL_OBJ(Angle);
DECL_OBJ(Vector); DECL_OBJ(Vector);
DECL_OBJ(Point); DECL_OBJ(Point);
DECL_OBJ(Segment); DECL_OBJ(Segment);
@ -108,6 +118,7 @@ namespace CGAL {
DECL_OBJ(Iso_box); DECL_OBJ(Iso_box);
DECL_OBJ(Bbox); DECL_OBJ(Bbox);
DECL_OBJ(Aff_transformation); DECL_OBJ(Aff_transformation);
#undef DECL_OBJ_
#undef DECL_OBJ #undef DECL_OBJ
template<class> struct is_NT_tag { enum { value = false }; }; template<class> struct is_NT_tag { enum { value = false }; };
@ -140,7 +151,7 @@ namespace CGAL {
typedef C##_tag container; \ typedef C##_tag container; \
}; \ }; \
template<class Obj,class Base> \ template<class Obj,class Base> \
struct Typedef_tag_type<X##_tag, Obj, Base> : Base { typedef Obj X; }; struct Typedef_tag_type<X##_tag, Obj, Base> : Base { typedef Obj X; }
//namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) }
//template<class Kernel> //template<class Kernel>
@ -187,8 +198,10 @@ namespace CGAL {
#endif #endif
//FIXME: choose a convention: prefix with Predicate_ ? //FIXME: choose a convention: prefix with Predicate_ ?
#define DECL_PREDICATE(X) struct X##_tag {}; \ #define DECL_PREDICATE_(X) \
template<>struct map_functor_type<X##_tag>{typedef Predicate_tag type;} template<>struct map_functor_type<X##_tag>{typedef Predicate_tag type;}
#define DECL_PREDICATE(X) struct X##_tag {}; \
DECL_PREDICATE_(X)
DECL_PREDICATE(Less_point_cartesian_coordinate); DECL_PREDICATE(Less_point_cartesian_coordinate);
DECL_PREDICATE(Compare_point_cartesian_coordinate); DECL_PREDICATE(Compare_point_cartesian_coordinate);
DECL_PREDICATE(Compare_distance); DECL_PREDICATE(Compare_distance);
@ -196,7 +209,7 @@ namespace CGAL {
DECL_PREDICATE(Less_lexicographically); DECL_PREDICATE(Less_lexicographically);
DECL_PREDICATE(Less_or_equal_lexicographically); DECL_PREDICATE(Less_or_equal_lexicographically);
DECL_PREDICATE(Equal_points); DECL_PREDICATE(Equal_points);
DECL_PREDICATE(Orientation); DECL_PREDICATE_(Orientation); // duplicate with the type
DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_points);
DECL_PREDICATE(Orientation_of_vectors); DECL_PREDICATE(Orientation_of_vectors);
DECL_PREDICATE(Side_of_oriented_sphere); DECL_PREDICATE(Side_of_oriented_sphere);

View File

@ -48,8 +48,8 @@ template <class T,class U> struct is_iterator_type_<T,U,true> :
template <class T> struct is_iterator : template <class T> struct is_iterator :
internal::is_iterator_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type> {}; internal::is_iterator_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type> {};
template <class T,class Tag> struct is_iterator_type : template <class T,class Tg> struct is_iterator_type :
internal::is_iterator_type_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type,Tag> {}; internal::is_iterator_type_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type,Tg> {};
template <class T,class U,bool=is_iterator<T>::value> struct is_iterator_to { template <class T,class U,bool=is_iterator<T>::value> struct is_iterator_to {
enum { value=false }; enum { value=false };

View File

@ -231,14 +231,15 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ )
}; };
} }
// TODO: make a Cartesian-only variant
#define CGAL_STRIP_PAREN_(...) __VA_ARGS__ #define CGAL_STRIP_PAREN_(...) __VA_ARGS__
#define CGAL_STRIP_PAREN(...) CGAL_STRIP_PAREN_ __VA_ARGS__ #define CGAL_STRIP_PAREN(...) CGAL_STRIP_PAREN_ __VA_ARGS__
// What to do with O? pass it down to other functors or drop it? // What to do with O? pass it down to other functors or drop it?
#define CGAL_KD_DEFAULT_FUNCTOR(Tag,Name,ReqTyp,ReqFun) \ #define CGAL_KD_DEFAULT_FUNCTOR(Tg,Name,ReqTyp,ReqFun) \
template <class K, class O> \ template <class K, class O> \
struct Get_functor<K, Tag, O, \ struct Get_functor<K, Tg, O, \
typename boost::mpl::if_c< \ typename boost::mpl::if_c< \
Provides_functor_i<K, Tag, O>::value \ Provides_functor_i<K, Tg, O>::value \
|| !Provides_types<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqTyp> >::value \ || !Provides_types<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqTyp> >::value \
|| !Provides_functors<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqFun> >::value \ || !Provides_functors<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqFun> >::value \
, int, void>::type> \ , int, void>::type> \
@ -247,11 +248,11 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ )
} }
// Not used yet, may need some changes. // Not used yet, may need some changes.
#define CGAL_KD_DEFAULT_TYPE(Tag,Name,ReqTyp,ReqFun) \ #define CGAL_KD_DEFAULT_TYPE(Tg,Name,ReqTyp,ReqFun) \
template <class K> \ template <class K> \
struct Get_type<K, Tag, \ struct Get_type<K, Tg, \
typename boost::mpl::if_c< \ typename boost::mpl::if_c< \
Provides_type_i<K, Tag>::value \ Provides_type_i<K, Tg>::value \
|| !Provides_types<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqTyp> >::value \ || !Provides_types<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqTyp> >::value \
|| !Provides_functors<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqFun> >::value \ || !Provides_functors<K, boost::mpl::vector<CGAL_STRIP_PAREN_ ReqFun> >::value \
, int, void>::type> \ , int, void>::type> \