FeatureBase.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef LVR2_IO_GFeatureBase_HPP
3 #define LVR2_IO_GFeatureBase_HPP
4 
5 #include <memory>
6 #include <tuple>
7 #include <type_traits>
8 
11 
12 namespace lvr2 {
13 
19 template<template<typename> typename Feature, typename Derived>
21 
22 
30 template<template<typename> typename ...Features>
31 class FeatureBase : public Features<FeatureBase<Features...> >...
32 {
33 protected:
34  template <typename T, typename Tuple>
35  struct has_type;
36 
37  template <typename T>
38  struct has_type<T, std::tuple<>> : std::false_type {};
39 
40  template <typename T, typename U, typename... Ts>
41  struct has_type<T, std::tuple<U, Ts...>> : has_type<T, std::tuple<Ts...>> {};
42 
43  template <typename T, typename... Ts>
44  struct has_type<T, std::tuple<T, Ts...>> : std::true_type {};
45 
46 public:
47  static constexpr std::size_t N = sizeof...(Features);
48  using features = std::tuple<Features<FeatureBase<Features...> >...>;
49 
50  template<template<typename> typename F>
51  struct has_feature {
52  static constexpr bool value = has_type<F<FeatureBase>, features>::type::value;
53  };
54 
55  template<
56  template<typename> typename F,
57  template<typename> typename ...Fs
58  >
59  struct add_features;
60 
61  template<
62  template<typename> typename F,
63  template<typename> typename ...Fs
64  >
65  struct add_features {
67  };
68 
69  template<
70  template<typename> typename F
71  >
72  struct add_features<F> {
73  using type = typename std::conditional<
75  FeatureBase<Features...>,
76  FeatureBase<Features...,F>
78  };
79 
80  template<template<typename> typename F>
81  struct add_feature {
82  using type = typename add_features<F>::type;
83  };
84 
85  template<
86  template<typename> typename F,
87  template<typename> typename ...Fs
88  >
90 
91  template<
92  template<typename> typename F,
93  template<typename> typename ...Fs
94  >
95  struct add_features_with_deps {
97  };
98 
99  template<template<typename> typename F>
101  using type = typename FeatureConstruct<F, FeatureBase<Features...> >::type;
102  };
103 
107 
108 
109  template<template<typename> typename F>
110  static constexpr bool HasFeature = has_feature<F>::value;
111 
112  template<template<typename> typename ...F>
113  using AddFeatures = typename add_features_with_deps<F...>::type;
114 
115  template<typename OTHER>
116  using Merge = typename OTHER::template add_features<Features...>::type;
117 
118 
119  #if __cplusplus <= 201500L
120  // feature of c++17
121  #pragma message("using Tp::save... needs c++17 at least or a newer compiler")
122  #endif
123 
124  //using Features<FeatureBase<Features...> >::save...;
125 
127  const FileKernelPtr inKernel,
128  const ScanProjectSchemaPtr inDesc) : m_kernel(inKernel), m_description(inDesc)
129  {
130 
131  }
132 
133  virtual ~FeatureBase() {}
134 
135  template<template<typename> typename F>
136  bool has();
137 
138  template<template<typename> typename F>
139  F<FeatureBase>* scast();
140 
141  template<template<typename> typename F>
142  F<FeatureBase>* dcast();
143 
146 
147 };
148 
149 template<template<typename> typename Feature, typename Derived = FeatureBase<> >
150 struct FeatureConstruct {
151  using type = typename Derived::template add_features<Feature>::type;
152 };
153 
154 template<template<typename> typename Feature>
156 
157 
158 } // namespace lvr2
159 
160 #include "FeatureBase.tcc"
161 
162 #endif // LVR2_IO_GFeatureBase_HPP
lvr2::FeatureBase::add_features::type
typename add_features< F >::type::template add_features< Fs... >::type type
Definition: FeatureBase.hpp:66
lvr2::FeatureBuild
typename FeatureConstruct< Feature >::type FeatureBuild
Definition: FeatureBase.hpp:155
lvr2::FeatureConstruct
Helper class how to construct a IO feature with its dependencies.
Definition: FeatureBase.hpp:20
lvr2::FeatureBase::m_kernel
const FileKernelPtr m_kernel
Definition: FeatureBase.hpp:144
lvr2::FeatureBase::N
static constexpr std::size_t N
Definition: FeatureBase.hpp:47
lvr2::FeatureBase::m_description
const ScanProjectSchemaPtr m_description
Definition: FeatureBase.hpp:145
lvr2::FeatureBase::Merge
typename OTHER::template add_features< Features... >::type Merge
Definition: FeatureBase.hpp:116
lvr2::FeatureBase::features
std::tuple< Features< FeatureBase< Features... > >... > features
Definition: FeatureBase.hpp:48
lvr2::FeatureBase::has_type
Definition: FeatureBase.hpp:35
lvr2::FileKernelPtr
std::shared_ptr< FileKernel > FileKernelPtr
Definition: FileKernel.hpp:110
ScanProjectSchema.hpp
lvr2::FeatureBase::FeatureBase
FeatureBase(const FileKernelPtr inKernel, const ScanProjectSchemaPtr inDesc)
Definition: FeatureBase.hpp:126
lvr2::FeatureBase::add_features_with_deps
Definition: FeatureBase.hpp:89
lvr2::FeatureBase::add_feature::type
typename add_features< F >::type type
Definition: FeatureBase.hpp:82
lvr2::FeatureBase::scast
F< FeatureBase > * scast()
lvr2::FeatureBase::add_features_with_deps< F >::type
typename FeatureConstruct< F, FeatureBase< Features... > >::type type
Definition: FeatureBase.hpp:101
lvr2::FeatureBase::has_feature::value
static constexpr bool value
Definition: FeatureBase.hpp:52
lvr2::FeatureBase::AddFeatures
typename add_features_with_deps< F... >::type AddFeatures
Definition: FeatureBase.hpp:113
lvr2::FeatureBase::has
bool has()
lvr2::FeatureBase::add_features_with_deps::type
typename add_features_with_deps< F >::type::template add_features_with_deps< Fs... >::type type
Definition: FeatureBase.hpp:96
FileKernel.hpp
lvr2::FeatureBase::HasFeature
static constexpr bool HasFeature
USE ONLY THESE METHODS IN APPLICATION ///.
Definition: FeatureBase.hpp:110
lvr2::FeatureBase::add_feature
Definition: FeatureBase.hpp:81
lvr2::FeatureBase::add_features< F >::type
typename std::conditional< FeatureBase< Features... >::has_feature< F >::value, FeatureBase< Features... >, FeatureBase< Features..., F > >::type type
Definition: FeatureBase.hpp:77
lvr2::FeatureBase::dcast
F< FeatureBase > * dcast()
lvr2::FeatureConstruct::type
typename Derived::template add_features< Feature >::type type
Definition: FeatureBase.hpp:151
std
Definition: HalfEdge.hpp:124
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::FeatureBase::add_features
Definition: FeatureBase.hpp:59
lvr2::FeatureBase::has_feature
Definition: FeatureBase.hpp:51
lvr2::FeatureBase
Manager Class for all FeatureBase components located in hdf5 directory.
Definition: FeatureBase.hpp:31
lvr2::FeatureBase::~FeatureBase
virtual ~FeatureBase()
Definition: FeatureBase.hpp:133
lvr2::ScanProjectSchemaPtr
std::shared_ptr< ScanProjectSchema > ScanProjectSchemaPtr
Definition: ScanProjectSchema.hpp:92


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23