1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
// Copyright (c) 2014
// INRIA Saclay-Ile de France (France)
//
// This file is part of CGAL (www.cgal.org)
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/NewKernel_d/include/CGAL/NewKernel_d/store_kernel.h $
// $Id: include/CGAL/NewKernel_d/store_kernel.h b26b07a1242 $
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Marc Glisse
#ifndef CGAL_STORE_KERNEL_H
#define CGAL_STORE_KERNEL_H
#include <CGAL/assertions.h>
#include <type_traits>
namespace CGAL {
namespace internal {
BOOST_MPL_HAS_XXX_TRAIT_DEF(Do_not_store_kernel)
template<class T,bool=std::is_empty<T>::value,bool=has_Do_not_store_kernel<T>::value> struct Do_not_store_kernel {
enum { value=false };
typedef Tag_false type;
};
template<class T> struct Do_not_store_kernel<T,true,false> {
enum { value=true };
typedef Tag_true type;
};
template<class T,bool b> struct Do_not_store_kernel<T,b,true> {
typedef typename T::Do_not_store_kernel type;
enum { value=type::value };
};
}
template<class R_,bool=internal::Do_not_store_kernel<R_>::value>
struct Store_kernel {
Store_kernel(){}
Store_kernel(R_ const&){}
enum { kernel_is_stored = false };
R_ kernel()const{return R_();}
typedef R_ reference_type;
void set_kernel(R_ const&){}
};
template<class R_>
struct Store_kernel<R_,false> {
Store_kernel():rp(0){
CGAL_warning_msg(true,"I should know my kernel");
}
Store_kernel(R_ const& r):rp(&r){}
enum { kernel_is_stored = true };
R_ const& kernel()const{
CGAL_warning_msg(rp!=0,"I should know my kernel");
return *rp;
}
typedef R_ const& reference_type;
void set_kernel(R_ const&r){rp=&r;}
private:
R_ const* rp;
};
//For a second kernel. TODO: find something more elegant
template<class R_,bool=internal::Do_not_store_kernel<R_>::value>
struct Store_kernel2 {
Store_kernel2(){}
Store_kernel2(R_ const&){}
enum { kernel2_is_stored = false };
R_ kernel2()const{return R_();}
typedef R_ reference2_type;
void set_kernel2(R_ const&){}
};
template<class R_>
struct Store_kernel2<R_,false> {
Store_kernel2(){
//CGAL_warning_msg(true,"I should know my kernel");
}
Store_kernel2(R_ const& r):rp(&r){}
enum { kernel2_is_stored = true };
R_ const& kernel2()const{
CGAL_warning_msg(rp==0,"I should know my kernel");
return *rp;
}
typedef R_ const& reference2_type;
void set_kernel2(R_ const&r){rp=&r;}
private:
R_ const* rp;
};
}
#define CGAL_BASE_INIT(X,Y) \
X():Y(){} \
X(R_ const&r):Y(r){}
#define CGAL_FUNCTOR_INIT_STORE(X) CGAL_BASE_INIT(X,Store_kernel<R_>)
#define CGAL_FUNCTOR_INIT_IGNORE(X) \
X(){} \
X(R_ const&){}
#endif // CGAL_STORE_KERNEL_H
|