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
lvr2::Hdf5IO::add_feature::type
typename add_features< F >::type type
Definition: HDF5FeatureBase.hpp:89
lvr2::Hdf5IO
Manager Class for all Hdf5IO components located in hdf5 directory.
Definition: HDF5FeatureBase.hpp:38
lvr2::Hdf5IO::has_feature::value
static constexpr bool value
Definition: HDF5FeatureBase.hpp:59
lvr2::Hdf5IO::m_filename
std::string m_filename
Definition: HDF5FeatureBase.hpp:158
lvr2::Hdf5IO::m_compress
bool m_compress
Definition: HDF5FeatureBase.hpp:154
lvr2::Hdf5IO::has_feature
Definition: HDF5FeatureBase.hpp:58
lvr2::Hdf5IO::m_usePreviews
bool m_usePreviews
Definition: HDF5FeatureBase.hpp:156
lvr2::Hdf5Construct::type
typename Derived::template add_features< Feature >::type type
Definition: HDF5FeatureBase.hpp:165
lvr2::Hdf5IO::dcast
F< Hdf5IO > * dcast()
lvr2::Hdf5IO::N
static constexpr std::size_t N
Definition: HDF5FeatureBase.hpp:54
lvr2::Hdf5IO< lvr2::hdf5features::ArrayIO, lvr2::hdf5features::ChannelIO, lvr2::hdf5features::VariantChannelIO, lvr2::hdf5features::MeshIO >::features
std::tuple< lvr2::hdf5features::ArrayIO< Hdf5IO< lvr2::hdf5features::ArrayIO ... > >... > features
Definition: HDF5FeatureBase.hpp:55
H5File.hpp
lvr2::Hdf5IO::add_feature
Definition: HDF5FeatureBase.hpp:88
lvr2::Hdf5IO< lvr2::hdf5features::ArrayIO, lvr2::hdf5features::ChannelIO, lvr2::hdf5features::VariantChannelIO, lvr2::hdf5features::MeshIO >::Merge
typename OTHER::template add_features< lvr2::hdf5features::ArrayIO ... >::type Merge
Definition: HDF5FeatureBase.hpp:123
lvr2::Hdf5IO::~Hdf5IO
virtual ~Hdf5IO()
Definition: HDF5FeatureBase.hpp:141
lvr2::Hdf5IO::add_features::type
typename add_features< F >::type::template add_features< Fs... >::type type
Definition: HDF5FeatureBase.hpp:73
lvr2::Hdf5IO::m_chunkSize
size_t m_chunkSize
Definition: HDF5FeatureBase.hpp:155
lvr2::Hdf5IO::add_features_with_deps< F >::type
typename Hdf5Construct< F, Hdf5IO< Features... > >::type type
Definition: HDF5FeatureBase.hpp:108
lvr2::Hdf5IO::m_previewReductionFactor
unsigned int m_previewReductionFactor
Definition: HDF5FeatureBase.hpp:157
H5DataSet.hpp
H5DataSpace.hpp
lvr2::Hdf5IO::Hdf5IO
Hdf5IO()
Definition: HDF5FeatureBase.hpp:133
lvr2::Hdf5IO::has
bool has()
scripts.normalize_multiple.filename
filename
Definition: normalize_multiple.py:60
lvr2::Hdf5IO::add_features
Definition: HDF5FeatureBase.hpp:66
lvr2::Hdf5IO::add_features_with_deps
Definition: HDF5FeatureBase.hpp:96
lvr2::Hdf5IO::add_features_with_deps::type
typename add_features_with_deps< F >::type::template add_features_with_deps< Fs... >::type type
Definition: HDF5FeatureBase.hpp:103
Hdf5Util.hpp
lvr2::Hdf5IO::scast
F< Hdf5IO > * scast()
lvr2::Hdf5IO::add_features< F >::type
typename std::conditional< Hdf5IO< Features... >::has_feature< F >::value, Hdf5IO< Features... >, Hdf5IO< Features..., F > >::type type
Definition: HDF5FeatureBase.hpp:84
lvr2::Hdf5IO::open
void open(std::string filename)
std
Definition: HalfEdge.hpp:124
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Hdf5IO< lvr2::hdf5features::ArrayIO, lvr2::hdf5features::ChannelIO, lvr2::hdf5features::VariantChannelIO, lvr2::hdf5features::MeshIO >::AddFeatures
typename add_features_with_deps< F... >::type AddFeatures
Definition: HDF5FeatureBase.hpp:120
lvr2::Hdf5Build
typename Hdf5Construct< Feature >::type Hdf5Build
Definition: HDF5FeatureBase.hpp:169
lvr2::Hdf5IO::has_type
Definition: HDF5FeatureBase.hpp:42
lvr2::Hdf5IO::HasFeature
static constexpr bool HasFeature
USE ONLY THESE METHODS IN APPLICATION ///.
Definition: HDF5FeatureBase.hpp:117
lvr2::Hdf5Construct
Helper class how to construct a IO feature with its dependencies.
Definition: HDF5FeatureBase.hpp:27
lvr2::Hdf5IO::m_hdf5_file
std::shared_ptr< HighFive::File > m_hdf5_file
Definition: HDF5FeatureBase.hpp:159


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