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
Manager Class for all FeatureBase components located in hdf5 directory.
Definition: FeatureBase.hpp:31
Helper class how to construct a IO feature with its dependencies.
Definition: FeatureBase.hpp:20
typename Derived::template add_features< Feature >::type type
const FileKernelPtr m_kernel
typename FeatureConstruct< Feature >::type FeatureBuild
typename std::conditional< FeatureBase< Features... >::has_feature< F >::value, FeatureBase< Features... >, FeatureBase< Features..., F > >::type type
Definition: FeatureBase.hpp:77
virtual ~FeatureBase()
typename add_features< F >::type::template add_features< Fs... >::type type
Definition: FeatureBase.hpp:66
typename add_features_with_deps< F... >::type AddFeatures
std::tuple< Features< FeatureBase< Features... > >... > features
Definition: FeatureBase.hpp:48
typename OTHER::template add_features< Features... >::type Merge
FeatureBase(const FileKernelPtr inKernel, const ScanProjectSchemaPtr inDesc)
static constexpr std::size_t N
Definition: FeatureBase.hpp:47
F< FeatureBase > * dcast()
static constexpr bool HasFeature
USE ONLY THESE METHODS IN APPLICATION ///.
typename add_features< F >::type type
Definition: FeatureBase.hpp:82
F< FeatureBase > * scast()
std::shared_ptr< ScanProjectSchema > ScanProjectSchemaPtr
const ScanProjectSchemaPtr m_description
std::shared_ptr< FileKernel > FileKernelPtr
Definition: FileKernel.hpp:110
typename FeatureConstruct< F, FeatureBase< Features... > >::type type
typename add_features_with_deps< F >::type::template add_features_with_deps< Fs... >::type type
Definition: FeatureBase.hpp:96


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 Mon Feb 28 2022 22:46:06