Remove the old tentative to document preKernel.

Remove the local patched copies of Handle_for and Lazy, they are
necessary for ref-counting and for Lazy_d, but not for Epick_d.
This commit is contained in:
Marc Glisse 2014-06-20 15:08:36 +02:00
parent 0796b53a91
commit 0d33f5dd9c
22 changed files with 2 additions and 2766 deletions

View File

@ -22,7 +22,7 @@ functors created by another one.
Only the interfaces specific to this class are listed here, refer to the
concepts for the rest.
Known bug: the functor `Intersect_d` is not yet implemented.
Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors.
\cgalModels `Kernel_d`
\cgalModels `DelaunayTriangulationTraits`

View File

@ -1,25 +0,0 @@
\begin{ccRefClass}{Cartesian_complete<Base,bool force=false,Derived=Default>}
\ccInclude{CGAL/NewKernel_d/Cartesian_complete.h}
\ccDefinition
A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base}
which provides at least \ccc{Point} and extends it by defining a number
of classical types and functors. The \ccc{force} parameter says whether
the class should override existing objects from \ccc{Base}.
\ccc{Derived} is the name of the ``final'' class for CRTP patterns,
which by default is \ccc{Cartesian_complete} itself.
This is in particular expected to be enough for the \ccc{Triangulation}
package.
\ccIsModel
\ccRefConceptPage{Kernel}
\ccImplementation
This is split in classes \ccc{Cartesian_complete_predicates},
\ccc{Cartesian_complete_computations},
\ccc{Cartesian_complete_constructions},
\ccc{Cartesian_complete_functors} (a reunion of the previous three),
\ccc{Cartesian_complete_types}, all with the same parameters.
\end{ccRefClass}

View File

@ -1,25 +0,0 @@
\begin{ccRefClass}{Cartesian_filter_K<Base,AK,EK>}
\ccInclude{CGAL/NewKernel_d/Cartesian_filter_K.h}
\ccDefinition
A model for \ccc{Kernel} that derives from \ccc{Base} (already a
\ccc{Kernel}) and redefines the predicates as filtered predicates
using \ccc{AK} as the approximate kernel and \ccc{EK} as the exact
kernel.
\ccIsModel
\ccRefConceptPage{Kernel}
Constructors???
NOTYET:
\begin{itemize}
\item If \ccc{Base::Functor<Tag>::Is_exact::value} is true, don't filter.
\item \ccc{Functor<Tag,No_filter_tag>::type} is taken from Base.
\end{itemize}
\ccImplementation
The implementation uses \ccc{CGAL::Filtered_predicate} and
\ccc{CGAL::KernelD_converter}.
\end{ccRefClass}

View File

@ -1,16 +0,0 @@
\begin{ccRefClass}{Cartesian_mini_d<FT,Dim>}
\ccInclude{CGAL/NewKernel_d/Cartesian_mini_d.h}
\ccDefinition
A minimal model for \ccc{Kernel} where \ccc{FT} and
\ccc{Default_ambient_dimension} are provided as template arguments.
This kernel provides the \ccc{Point} concept and not much more.
The class takes several other template parameters (in particular to
specify \ccc{LA}) that are undocumented for now.
\ccIsModel
\ccRefConceptPage{Kernel}
\ccRefConceptPage{Point}
\end{ccRefClass}

View File

@ -1,27 +0,0 @@
\begin{ccRefClass}{Cartesian_wrap<Base>}
\ccInclude{CGAL/NewKernel_d/Cartesian_wrap.h}
\ccDefinition
This class derives from a \ccc{Kernel} \ccc{Base} and replaces a number
of types (point, segment) with wrappers that have intuitive member
functions that call the corresponding functors. For instance, the
constructors forward to \ccc{Functor<Construct_ttag<Tag>>::type},
\ccc{Point::operator[]} forwards to
\ccc{Functor<Compute_cartesian_coordinate_tag>::type},
\ccc{operator+(Vector,Vector)} forwards to
\ccc{Functor<Construct_sum_of_vectors_tag>::type}, etc.
For stateful kernels, the wrappers will store a pointer to the kernel
instance. This means in particular that for such a kernel, one can't
just create a point from its coordinates (like \ccc{Point M(1,2,3);}),
they have to create it using some functor or an operation on existing
objects.
\ccIsModel
\ccRefConceptPage{Kernel}
\ccImplementation
The implementation \emph{tries} to avoid any extra copying that could be
caused by the wrapping.
\end{ccRefClass}

View File

@ -1,18 +0,0 @@
\begin{ccRefClass}{Define_segment<Base,Derived=Default>}
\ccInclude{CGAL/NewKernel_d/Define_segment.h}
\ccDefinition
A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base}
which provides at least \ccc{Point} and extends it by providing
\ccc{Segment}.
\ccc{Derived} is the name of the ``final'' class for CRTP patterns,
which by default is \ccc{Define_segment} itself.
\ccIsModel
\ccRefConceptPage{Kernel}
\ccRefConceptPage{Segment}
\ccImplementation
The segment type is defined as an \ccc{std::pair} of points.
\end{ccRefClass}

View File

@ -1,14 +0,0 @@
\begin{ccRefFunctionObjectClass}{KernelD_converter<K1,K2,List=K1::Object_list>}
\ccInclude{CGAL/NewKernel_d/KernelD_converter.h}
\ccDefinition
A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor<Convert_ttag<Tag>::type} for \ccc{K1::Type<Tag>::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it.
\ccCreation
\ccConstructor{KernelD_converter(K1 const&,K2 const&)}{main constructor}
\ccConstructor{KernelD_converter()}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.}
\ccOperations
\ccMethod{K2::SomeThing operator()(K1::SomeThing) const;}{returns a converted object.}
\end{ccRefFunctionObjectClass}

View File

@ -1,16 +0,0 @@
\begin{ccRefClass}{Kernel_2_interface<Base>}
\ccInclude{CGAL/NewKernel_d/Kernel_2_interface.h}
\ccDefinition
This class derives from a \ccc{Kernel} \ccc{Base} and defines a number
of typedefs and functions to give it an interface close to that of the
classical \ccc{Kernel_23}, restricted to 2D. As an example, it contains:
\ccc{typedef Type<Point_tag>::type Point_2}\\
\ccc{struct Less_x_2}\\
\ccc{Less_x_2 less_x_2_object()const}
Assuming that \ccc{Base} provides everything required, this provides
an interface suitable for the \ccc{Triangulation_2} package.
\end{ccRefClass}

View File

@ -1,16 +0,0 @@
\begin{ccRefClass}{Kernel_3_interface<Base>}
\ccInclude{CGAL/NewKernel_d/Kernel_3_interface.h}
\ccDefinition
This class derives from a \ccc{Kernel} \ccc{Base} and defines a number
of typedefs and functions to give it an interface close to that of the
classical \ccc{Kernel_23}, restricted to 3D. As an example, it contains:
\ccc{typedef Type<Point_tag>::type Point_3}\\
\ccc{struct Side_of_oriented_sphere_3}\\
\ccc{Side_of_oriented_sphere_3 side_of_oriented_sphere_3_object()const}
Assuming that \ccc{Base} provides everything required, this provides
an interface suitable for the \ccc{Triangulation_2} package.
\end{ccRefClass}

View File

@ -1,19 +0,0 @@
\begin{ccRefClass}{Kernel_d_interface<Base>}
\ccInclude{CGAL/NewKernel_d/Kernel_d_interface.h}
\ccDefinition
This class derives from a \ccc{Kernel} \ccc{Base} and defines a number
of typedefs and functions to give it an interface close to that of the
classical \ccc{Kernel_d}. As an example, it contains:
\ccc{typedef Type<Point_tag>::type Point_d}\\
\ccc{typedef Functor<Compare_lexicographically_tag>::type Compare_lexicographically_d}\\
\ccc{Compare_lexicographically_d compare_lexicographically_d_object()const{ return Compare_lexicographically_d(*this); }}
Assuming that \ccc{Base} provides everything required, this provides
an interface suitable for the \ccc{Triangulation} package.
\ccIsModel
\ccRefConceptPage{Triangulation_traits}
\end{ccRefClass}

View File

@ -1,19 +0,0 @@
\begin{ccRefConcept}[Kernel::]{Functor<Tag,Option=Default>}
Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel is stateless (as tested with \ccc{boost::is_empty<Kernel>}), functors may (must???) also have a default constructor. Functors follow the \ccc{result_of}-protocol.
Member functions provided by each functor are described in their concept. Some special cases are:
\begin{itemize}
\item A constructor is a functor represented by a tag \ccc{Construct_ttag<Some_tag>}. It contains member functions \ccc{Kernel::Type<Some_tag>::type operator()(Args...) const}.
\item A converter is a functor represented by a tag \ccc{Convert_ttag<Some_tag>}. It contains a member function \ccc{template <class K2, class Converter> K2::Type<Some_tag>::type operator()(K2 const&, Converter, Kernel::Type<Some_tag>::type) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor<Construct_segment_extremity_tag>}, then convert them to \ccc{K2::Type<Point_tag>} using \ccc{Converter} and finally build a \ccc{K2::Type<Segment_tag>} with \ccc{K2::Functor<Construct_segment_tag>}.
%TODO: clarify this Converter business
\end{itemize}
\ccc{Option} is used to specify a specific version of the functor. For instance, for a predicate, you might ask for a fast inexact version with \ccc{Fast_tag}.
For each functor tag \ccc{Tag}, \ccc{map_functor_type<Tag>::type} shall be
\ccc{Predicate_tag}, \ccc{Construct_tag}, \ccc{Compute_tag} or \ccc{Misc_tag}
depending on the kind of functor it is. Predicates output a discrete value, for instance \ccc{Kernel::Boolean}. Computations output a number of type \ccc{Kernel::FT} or \ccc{Kernel::RT}. Constructions output an object of type \ccc{Kernel::Type<map_result_tag<Tag>::type>::type} where \ccc{map_result_tag} is specialized to specify the tag of the result. All others are miscellaneous.
\end{ccRefConcept}

View File

@ -1,17 +0,0 @@
\begin{ccRefClass}{Lazy_kernel<EK,AK,E2A=KernelD_converter<EK,AK>>}
\ccInclude{CGAL/NewKernel_d/Lazy_kernel.h}
\ccDefinition
A model for \ccc{Kernel}.
\ccc{AK} is an approximate kernel (with an interval number type) and \ccc{EK}
is an exact kernel.
\ccIsModel
\ccRefConceptPage{Kernel}
\ccImplementation
For each object, this kernel stores both an approximate object from
\ccc{AK} and either an exact object from \ccc{EK} or a graph that
allows it to compute such an exact object when needed.
\end{ccRefClass}

View File

@ -1,8 +0,0 @@
\begin{ccPkgDescription}{dD Kernel}
\ccPkgSummary{
A new d-dimensional kernel.
}
\ccPkgIntroducedInCGAL{42.0}
\ccPkgLicense{\ccLicenseLGPL}
\end{ccPkgDescription}

View File

@ -1,27 +0,0 @@
\begin{ccRefConcept}{Point}
The concept of a {\em Point} is defined by a set of requirements on
the provision of certain types in a \ccc{Kernel}.
\ccRefines
\ccc{Kernel}
\ccNestedType{Object_list}{shall contain at least \ccc{Point_tag} and \ccc{Point_cartesian_const_iterator_tag}.}
\ccNestedType{Type<Point_tag>::type}{shall be CopyConstructible.}
\ccNestedType{Type<Point_cartesian_const_iterator_tag>::type}{shall be a forward iterator (except that it may return an rvalue) whose \ccc{value_type} is \ccc{Kernel::Type<Point_tag>::type}.}
\ccNestedType{Functor<Convert_ttag<Point_tag>>::type}{[Optional] A default converter it available to \ccc{Kernel_converter}, but may be unsuitable if your Point type is too original.}
\ccNestedType{Functor<Construct_ttag<Point_cartesian_const_iterator_tag>>::type}{shall provide \ccc{Type<Point_cartesian_const_iterator_tag>::type operator()(Type<Point_tag>::type const&, Extremity_tag)const} where \ccc{Extemity_tag} is \ccc{Begin_tag} or \ccc{End_tag}.}
\ccNestedType{Functor<Compute_cartesian_coordinate_tag>::type}{shall provide \ccc{FT operator()(Type<Point_tag>::type,int k)const} which returns the $k$th Cartesian coordinate of the point.}
\ccNestedType{Functor<Point_dimension_tag>::type}{shall provide \ccc{int operator()(Type<Point_tag>::type)const} which returns the dimension of a point.}
\ccNestedType{Functor<Construct_ttag<Point_tag>>::type}{shall provide:\\
\ccc{Type<Point_tag>::type operator()(int dim)const} which constructs a point at the origin;\\
\ccc{Type<Point_tag>::type operator()()const} the same, when \ccc{Default_ambient_dimension} is known;\\
\ccc{Type<Point_tag>::type operator()(Type<Point_tag>::type)const} which copies (???);\\
\ccc{Type<Point_tag>::type operator()(Iter, Iter, Cartesian_tag)const} which reads the Cartesian coordinates from the iterators;\\
\ccc{Type<Point_tag>::type operator()(Iter, Iter)const} same as above;\\
\ccc{Type<Point_tag>::type operator()(FT...)const} which reads the Cartesian coordinates from the arguments, when \ccc{Default_ambient_dimension} is known.
}
\end{ccRefConcept}

View File

@ -1,150 +0,0 @@
% +------------------------------------------------------------------------+
% | Reference manual page: PreKernel.tex
% +------------------------------------------------------------------------+
% | 21.05.2012 Marc Glisse
% | Package: NewKernel_d
% |
\RCSdef{\RCSPreKernelRev}{$Id$}
\RCSdefDate{\RCSPreKernelDate}{$Date$}
% |
\ccRefPageBegin
%%RefPage: end of header, begin of main body
% +------------------------------------------------------------------------+
\begin{ccRefConcept}{PreKernel}
%% \ccHtmlCrossLink{} %% add further rules for cross referencing links
%% \ccHtmlIndexC[concept]{} %% add further index entries
\ccDefinition
%copied from Kernel_23
The concept of a {\em prekernel} is defined by a set of requirements on
the provision of certain types and access member functions to create
objects of these types. The types are function object classes to be used
within the algorithms and data structures of \cgal. This allows you to
use any model of a kernel as a traits class in the Cgal algorithms and
data structures, unless they require types beyond those provided by a
kernel.
A kernel provides types, construction objects, and generalized
predicates. The former replace constructors of the kernel classes and
constructive procedures in the kernel. There are also function objects
replacing operators, especially for equality testing.
Types and functors are identified by tags, which may be any type (like
\ccc{CGAL::Segment_tag}). As a special case, the construction functor of
a type identified by \ccc{Some_tag} is identified by the tag
\ccc{Construct_ttag<Some_tag>}, and the conversion functor by
\ccc{Convert_ttag<Some_tag>}.
Depending on \ccc{Default_ambient_dimension}, a kernel has 2
constructors, a default constructor and a constructor that takes as
argument an \ccc{int} for the dimension.
%\ccGeneralizes
%
%ThisConcept \\
%ThatConcept
\ccTypes
\ccNestedType{Default_ambient_dimension}{\ccc{Dimension_tag<d>} where \ccc{d} is the ambient dimension or \ccc{Dynamic_dimension_tag} if the dimension is unknown.}
\ccGlue
\ccNestedType{Max_ambient_dimension}{\ccc{Dimension_tag<d>} where \ccc{d} is an upper bound on the ambient dimension or \ccc{Dynamic_dimension_tag}.}
\ccNestedType{FT}{a model of \ccc{FieldNumberType}}
\ccGlue
\ccNestedType{RT}{a model of \ccc{RingNumberType}}
% Not documented in the first version
\ccNestedType{LA}{a model of \ccc{LinearAlgebraSomething} using \ccc{RT}}
The following types describe the return types of predicates. They typically
map to \ccc{bool} and \cgal\ kernel enum types, except when an interval arithmetic
number type is used such as within the filtering kernels, in which case it is
\ccc{Uncertain<bool>} or similar.
\ccNestedType{Boolean}{\ccc{bool} or \ccc{Uncertain<bool>}}
\ccGlue
\ccNestedType{Sign}{\ccc{CGAL::Sign} or \ccc{Uncertain<CGAL::Sign>}}
\ccGlue
\ccNestedType{Comparison_result}{\ccc{CGAL::Comparison_result} or \ccc{Uncertain<CGAL::Comparison_result>}}
\ccGlue
\ccNestedType{Orientation}{\ccc{CGAL::Orientation} or \ccc{Uncertain<CGAL::Orientation>}}
\ccGlue
\ccNestedType{Oriented_side}{\ccc{CGAL::Oriented_side} or \ccc{Uncertain<CGAL::Oriented_side>}}
\ccGlue
\ccNestedType{Bounded_side}{\ccc{CGAL::Bounded_side} or \ccc{Uncertain<CGAL::Bounded_side>}}
\ccGlue
\ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain<CGAL::Angle>}}
\ccHeading{Geometric Objects}
%\ccNestedType{template <class Tag> struct Type<Tag>}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type<Point_tag>::type} is the type of points.}
\ccNestedType{Point, \ldots}{Geometric object type}
\ccNestedType{Object_list}{A typedef for \ccc{typeset<Point_tag,...>}
with the list of tags corresponding to the provided geometric object
types.}
\ccHeading{Iterators}
\ccNestedType{Point_cartesian_const_iterator, \ldots}{Iterator}
\ccNestedType{Iterator_list}{A typedef for
\ccc{typeset<Point_cartesian_const_iterator_tag,...>} with the list of
tags corresponding to the provided iterators.}
\ccHeading{Function objects}
\ccNestedType{template <class Tag, class Option> struct Functor<Tag,Option=Default>}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor<Orientation_tag>::type} is the orientation predicate. Functors that are not provided should all be \ccc{Null_functor}.}
\ccCreation
\ccCreationVariable{kernel} %% choose variable name
\ccConstructor{PreKernel();}{default constructor.}
\ccConstructor{PreKernel(int d);}{constructor for dimension $d$.}
\ccOperations
\ccMethod{int dimension();}{returns the dimension (or UNKNOWN\_DIMENSION)}
\ccHasModels
\ccc{Some_class},
\ccc{Some_other_class}.
\ccSeeAlso
Kernel\_d
%Some\_other\_concept,
%%\ccc{some_other_function}.
%\ccExample
%
%A short example program.
%Instead of a short program fragment, a full running program can be
%included using the
%\verb|\ccIncludeExampleCode{Package/PreKernel.C}|
%macro. The program example would be part of the source code distribution and
%also part of the automatic test suite.
%
%\begin{ccExampleCode}
%void your_example_code() {
%}
%\end{ccExampleCode}
%% \ccIncludeExampleCode{Package/PreKernel.C}
\end{ccRefConcept}
% +------------------------------------------------------------------------+
%%RefPage: end of main body, begin of footer
\ccRefPageEnd
% EOF
% +------------------------------------------------------------------------+

View File

@ -1,28 +0,0 @@
\begin{ccRefConcept}{Segment}
The concept of a {\em Segment} is defined by a set of requirements on
the provision of certain types in a \ccc{Kernel} that already provides
the concept of a \ccc{Point}.
\ccRefines
\ccc{Point}
\ccNestedType{Object_list}{shall contain at least \ccc{Segment_tag}.}
\ccNestedType{Type<Segment_tag>::type}{shall be CopyConstructible.}
\ccNestedType{Functor<Convert_ttag<Segment_tag>>::type}{[Optional] A default converter it available to \ccc{Kernel_converter}, but may be unsuitable if your Segment type is too original.}
\ccNestedType{Functor<Construct_segment_extremity_tag>::type}{shall
provide \ccc{Type<Point_tag>::type operator()(Type<Segment_tag>::type,
int k)const} which returns the $k$th ($0$ or $1$) extremity of the segment.}
\ccNestedType{Functor<Construct_ttag<Segment_tag>>::type}{shall provide:\\
\ccc{Type<Segment_tag>::type
operator()(Type<Point_tag>::type,Type<Point_tag>::type)const} which
constructs a segment from its extremities;\\
\ccc{Type<Segment_tag>::type operator()(piecewise_construct_t,
tuple<U...> u, tuple<V...> v)const} which calls
\ccc{Functor<Construct_ttag<Point_tag>>::type} on the content of each
tuple to create the extremities.
}
\end{ccRefConcept}

View File

@ -1,25 +0,0 @@
% +------------------------------------------------------------------------+
% | CBP Reference Manual: main.tex
% +------------------------------------------------------------------------+
% | Automatically generated driver file for the reference manual chapter
% | of this package. Do not edit manually, you may loose your changes.
% +------------------------------------------------------------------------+
\input{NewKernel_d_ref/Cartesian_complete.tex}
\input{NewKernel_d_ref/Cartesian_filter_K.tex}
\input{NewKernel_d_ref/Cartesian_mini_d.tex}
\input{NewKernel_d_ref/Cartesian_wrap.tex}
\input{NewKernel_d_ref/Define_segment.tex}
\input{NewKernel_d_ref/KernelD_converter.tex}
\input{NewKernel_d_ref/Kernel_2_interface.tex}
\input{NewKernel_d_ref/Kernel_3_interface.tex}
\input{NewKernel_d_ref/Kernel_d_interface.tex}
\input{NewKernel_d_ref/Kernel_functor.tex}
\input{NewKernel_d_ref/Lazy_kernel.tex}
\input{NewKernel_d_ref/PkgDescription.tex}
\input{NewKernel_d_ref/Point.tex}
\input{NewKernel_d_ref/PreKernel.tex}
\input{NewKernel_d_ref/Segment.tex}
\input{NewKernel_d_ref/typeset.tex}
%% EOF

View File

@ -1,17 +0,0 @@
\begin{ccRefClass}{typeset<...>}
\ccInclude{CGAL/typeset.h}
\ccDefinition
This class provides a set of types, where each type appears at most once. Iterating through the set should be done by looking at \ccc{head} and recursing on \ccc{tail}, testing whether a set is empty by comparing it to \ccc{typeset<>}.
\ccNestedType{head}{One element from the list.}
\ccNestedType{tail}{A typeset of the other elements from list.}
\ccNestedType{add<X>::type}{A typeset with \ccc{X} added to the list.}
\ccNestedType{contains<X>::value}{A boolean that says whether \ccc{X} is in the list.}
In C++11, \ccc{add<X>} is already a typeset so one can omit \ccc{::type}, and \ccc{contains<X>} derives from \ccc{true_type} or \ccc{false_type}.
\ccImplementation
In C++11, the list looks like \ccc{typeset<type1,type2,type3>} whereas in C++03 it looks like \ccc{typeset<type1,typeset<type2,typeset<type3,typeset<> > > >} (an alternative would have been \ccc{typeset<type1,type2,type3,void,void,void,void>}, as in \ccc{boost::tuple}).
\end{ccRefClass}

View File

@ -1,2 +0,0 @@
include/CGAL/Handle_for.h
include/CGAL/Lazy.h

View File

@ -1,324 +0,0 @@
// Copyright (c) 1999,2001,2003
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Stefan Schirra, Sylvain Pion
#ifndef CGAL_HANDLE_FOR_H
#define CGAL_HANDLE_FOR_H
#include <boost/config.hpp>
#include <CGAL/memory.h>
#include <algorithm>
#include <cstddef>
#include <CGAL/marcutils.h>
#include <boost/preprocessor/repetition.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable:4345) // Avoid warning http://msdn.microsoft.com/en-us/library/wewb47ee(VS.80).aspx
#endif
namespace CGAL {
template <class T, class Alloc = CGAL_ALLOCATOR(T) >
class Handle_for
{
// Wrapper that adds the reference counter.
struct RefCounted {
T t;
unsigned int count;
};
typedef typename Alloc::template rebind<RefCounted>::other Allocator;
typedef typename Allocator::pointer pointer_;
static Allocator allocator;
pointer_ ptr_;
public:
typedef T element_type;
typedef std::ptrdiff_t Id_type ;
Handle_for()
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(); // we get the warning here
ptr_->count = 1;
}
Handle_for(const element_type& t)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(t);
ptr_->count = 1;
}
#ifndef CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE
Handle_for(element_type && t)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(std::move(t));
ptr_->count = 1;
}
#endif
/* I comment this one for now, since it's preventing the automatic conversions
to take place. We'll see if it's a problem later.
template < typename T1 >
Handle_for(const T1& t1)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) T(t1);
ptr_->count = 1;
}
*/
#if !defined CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES && !defined CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE
template < typename T1, typename T2, typename... Args >
Handle_for(T1 && t1, T2 && t2, Args && ... args)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(std::forward<T1>(t1), std::forward<T2>(t2), std::forward<Args>(args)...);
ptr_->count = 1;
}
template < typename F, typename... Args >
Handle_for(Eval_functor &&, F && f, Args && ... args)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(std::forward<F>(f)(std::forward<Args>(args)...));
ptr_->count = 1;
}
#else
#define CGAL_CODE(Z,N,_) template <BOOST_PP_ENUM_PARAMS(N,class T)> \
Handle_for(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \
: ptr_(allocator.allocate(1)) \
{ \
new (&(ptr_->t)) element_type(BOOST_PP_ENUM_PARAMS(N,t)); \
ptr_->count = 1; \
}
BOOST_PP_REPEAT_FROM_TO(2,11,CGAL_CODE,_)
#undef CGAL_CODE
#define CGAL_CODE(Z,N,_) template <class F,BOOST_PP_ENUM_PARAMS(N,class T)> \
Handle_for(Eval_functor,F const&f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \
: ptr_(allocator.allocate(1)) \
{ \
new (&(ptr_->t)) element_type(f(BOOST_PP_ENUM_PARAMS(N,t))); \
ptr_->count = 1; \
}
BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_)
#undef CGAL_CODE
template <class F>
Handle_for(Eval_functor,F const&f)
: ptr_(allocator.allocate(1))
{
new (&(ptr_->t)) element_type(f());
ptr_->count = 1;
}
#endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
Handle_for(const Handle_for& h)
: ptr_(h.ptr_)
{
++(ptr_->count);
}
Handle_for&
operator=(const Handle_for& h)
{
Handle_for tmp = h;
swap(tmp);
return *this;
}
Handle_for&
operator=(const element_type &t)
{
if (is_shared())
*this = Handle_for(t);
else
ptr_->t = t;
return *this;
}
#ifndef CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE
// Note : I don't see a way to make a useful move constructor, apart
// from e.g. using NULL as a ptr value, but this is drastic.
Handle_for&
operator=(Handle_for && h)
{
swap(h);
return *this;
}
Handle_for&
operator=(element_type && t)
{
if (is_shared())
*this = Handle_for(std::move(t));
else
ptr_->t = std::move(t);
return *this;
}
#endif
~Handle_for()
{
if (! is_shared() ) {
allocator.destroy( ptr_);
allocator.deallocate( ptr_, 1);
}
else
--(ptr_->count);
}
void
initialize_with(const element_type& t)
{
// kept for backward compatibility. Use operator=(t) instead.
*this = t;
}
Id_type id() const { return Ptr() - static_cast<T const*>(0); }
bool identical(const Handle_for& h) const { return Ptr() == h.Ptr(); }
// Ptr() is the "public" access to the pointer to the object.
// The non-const version asserts that the instance is not shared.
const element_type *
Ptr() const
{
return &(ptr_->t);
}
/*
// The assertion triggers in a couple of places, so I comment it for now.
T *
Ptr()
{
CGAL_assertion(!is_shared());
return &(ptr_->t);
}
*/
bool
is_shared() const
{
return ptr_->count > 1;
}
bool
unique() const
{
return !is_shared();
}
long
use_count() const
{
return ptr_->count;
}
void
swap(Handle_for& h)
{
std::swap(ptr_, h.ptr_);
}
protected:
void
copy_on_write()
{
if ( is_shared() )
{
pointer_ tmp_ptr = allocator.allocate(1);
new (&(tmp_ptr->t)) element_type(ptr_->t);
tmp_ptr->count = 1;
--(ptr_->count);
ptr_ = tmp_ptr;
}
}
// ptr() is the protected access to the pointer. Both const and non-const.
// Redundant with Ptr().
element_type *
ptr()
{ return &(ptr_->t); }
const element_type *
ptr() const
{ return &(ptr_->t); }
};
template <class T, class Allocator>
typename Handle_for<T, Allocator>::Allocator
Handle_for<T, Allocator>::allocator;
template <class T, class Allocator>
inline
void
swap(Handle_for<T, Allocator> &h1, Handle_for<T, Allocator> &h2)
{
h1.swap(h2);
}
template <class T, class Allocator>
inline
bool
identical(const Handle_for<T, Allocator> &h1,
const Handle_for<T, Allocator> &h2)
{
return h1.identical(h2);
}
template <class T> inline bool identical(const T &t1, const T &t2) { return &t1 == &t2; }
template <class T, class Allocator>
inline
const T&
get(const Handle_for<T, Allocator> &h)
{
return *(h.Ptr());
}
template <class T>
inline
const T&
get(const T &t)
{
return t;
}
} //namespace CGAL
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif // CGAL_HANDLE_FOR_H

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ namespace CGAL {
namespace SFA { // static filter adapter
// Note that this would be quite a bit simpler without stateful kernels
template <class Base_,class R_> struct Orientation_of_points_2 : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2);
CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2)
typedef typename Get_type<R_, Point_tag>::type Point;
typedef typename Get_type<R_, Orientation_tag>::type result_type;
typedef typename Get_type<R_, FT_tag>::type FT;