HDF5FeatureBase.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef LVR2_IO_GHDF5IO_HPP
3 #define LVR2_IO_GHDF5IO_HPP
4 
5 #include <memory>
6 #include <tuple>
7 #include <type_traits>
8 
10 
11 #include <H5Tpublic.h>
12 #include <hdf5_hl.h>
13 #include <highfive/H5DataSet.hpp>
14 #include <highfive/H5DataSpace.hpp>
15 #include <highfive/H5File.hpp>
16 
17 
18 
19 namespace lvr2 {
20 
26 template<template<typename> typename Feature, typename Derived>
28 
29 
37 template<template<typename> typename ...Features>
38 class Hdf5IO : public Features<Hdf5IO<Features...> >...
39 {
40 protected:
41  template <typename T, typename Tuple>
42  struct has_type;
43 
44  template <typename T>
45  struct has_type<T, std::tuple<>> : std::false_type {};
46 
47  template <typename T, typename U, typename... Ts>
48  struct has_type<T, std::tuple<U, Ts...>> : has_type<T, std::tuple<Ts...>> {};
49 
50  template <typename T, typename... Ts>
51  struct has_type<T, std::tuple<T, Ts...>> : std::true_type {};
52 
53 public:
54  static constexpr std::size_t N = sizeof...(Features);
55  using features = std::tuple<Features<Hdf5IO<Features...> >...>;
56 
57  template<template<typename> typename F>
58  struct has_feature {
59  static constexpr bool value = has_type<F<Hdf5IO>, features>::type::value;
60  };
61 
62  template<
63  template<typename> typename F,
64  template<typename> typename ...Fs
65  >
66  struct add_features;
67 
68  template<
69  template<typename> typename F,
70  template<typename> typename ...Fs
71  >
72  struct add_features {
74  };
75 
76  template<
77  template<typename> typename F
78  >
79  struct add_features<F> {
80  using type = typename std::conditional<
81  Hdf5IO<Features...>::has_feature<F>::value,
82  Hdf5IO<Features...>,
83  Hdf5IO<Features...,F>
85  };
86 
87  template<template<typename> typename F>
88  struct add_feature {
89  using type = typename add_features<F>::type;
90  };
91 
92  template<
93  template<typename> typename F,
94  template<typename> typename ...Fs
95  >
97 
98  template<
99  template<typename> typename F,
100  template<typename> typename ...Fs
101  >
102  struct add_features_with_deps {
104  };
105 
106  template<template<typename> typename F>
108  using type = typename Hdf5Construct<F, Hdf5IO<Features...> >::type;
109  };
110 
114 
115 
116  template<template<typename> typename F>
117  static constexpr bool HasFeature = has_feature<F>::value;
118 
119  template<template<typename> typename ...F>
120  using AddFeatures = typename add_features_with_deps<F...>::type;
121 
122  template<typename OTHER>
123  using Merge = typename OTHER::template add_features<Features...>::type;
124 
125 
126  #if __cplusplus <= 201500L
127  // feature of c++17
128  #pragma message("using Tp::save... needs c++17 at least or a newer compiler")
129  #endif
130 
131  using Features<Hdf5IO<Features...> >::save...;
132 
134  :m_compress(true),
135  m_chunkSize(1e7),
136  m_usePreviews(true)
137  {
138 
139  }
140 
141  virtual ~Hdf5IO() {}
142 
143  void open(std::string filename);
144 
145  template<template<typename> typename F>
146  bool has();
147 
148  template<template<typename> typename F>
149  F<Hdf5IO>* scast();
150 
151  template<template<typename> typename F>
152  F<Hdf5IO>* dcast();
153 
155  size_t m_chunkSize;
158  std::string m_filename;
159  std::shared_ptr<HighFive::File> m_hdf5_file;
160 
161 };
162 
163 template<template<typename> typename Feature, typename Derived = Hdf5IO<> >
164 struct Hdf5Construct {
165  using type = typename Derived::template add_features<Feature>::type;
166 };
167 
168 template<template<typename> typename Feature>
170 
171 
172 } // namespace lvr2
173 
174 #include "HDF5FeatureBase.tcc"
175 
176 #endif // LVR2_IO_GHDF5IO_HPP
void open(std::string filename)
typename Hdf5Construct< F, Hdf5IO< Features... > >::type type
std::shared_ptr< HighFive::File > m_hdf5_file
F< Hdf5IO > * scast()
typename std::conditional< Hdf5IO< Features... >::has_feature< F >::value, Hdf5IO< Features... >, Hdf5IO< Features..., F > >::type type
typename add_features_with_deps< F >::type::template add_features_with_deps< Fs... >::type type
typename Hdf5Construct< Feature >::type Hdf5Build
static constexpr std::size_t N
std::string m_filename
Helper class how to construct a IO feature with its dependencies.
typename add_features< F >::type::template add_features< Fs... >::type type
Manager Class for all Hdf5IO components located in hdf5 directory.
static constexpr bool HasFeature
USE ONLY THESE METHODS IN APPLICATION ///.
static constexpr bool value
unsigned int m_previewReductionFactor
typename Derived::template add_features< Feature >::type type
F< Hdf5IO > * dcast()
typename add_features< F >::type type


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