HighFive  2.2.2
HighFive - Header-only C++ HDF5 interface
H5PropertyList.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c), 2017-2018, Adrien Devresse <adrien.devresse@epfl.ch>
3  * Juan Hernando <juan.hernando@epfl.ch>
4  * Distributed under the Boost Software License, Version 1.0.
5  * (See accompanying file LICENSE_1_0.txt or copy at
6  * http://www.boost.org/LICENSE_1_0.txt)
7  *
8  */
9 #ifndef H5PROPERTY_LIST_HPP
10 #define H5PROPERTY_LIST_HPP
11 
12 #include <vector>
13 
14 #include <H5Ppublic.h>
15 
16 #include "H5Exception.hpp"
17 #include "H5Object.hpp"
18 
19 namespace HighFive {
20 
24 enum class PropertyType : int {
40 };
41 
45 template <PropertyType T>
46 class PropertyList {
47  public:
48  ~PropertyList();
49 
50  PropertyList(const PropertyList<T>&) = delete;
52  PropertyList(PropertyList&& other) noexcept;
53  PropertyList& operator=(PropertyList&& other) noexcept;
54  constexpr PropertyType getType() const { return T; }
55 
56  hid_t getId() const { return _hid; }
57 
58  PropertyList() noexcept;
59 
60  template <typename P>
61  PropertyList(const std::initializer_list<P>&);
62 
68  template <typename P>
69  void add(const P& property);
70 
71  protected:
72  void _initializeIfNeeded();
73 
74  hid_t _hid;
75 };
76 
78 typedef PropertyList<PropertyType::FILE_ACCESS> FileAccessProps ;
79 typedef PropertyList<PropertyType::DATASET_CREATE> DataSetCreateProps;
80 typedef PropertyList<PropertyType::DATASET_ACCESS> DataSetAccessProps;
82 
87 template <PropertyType T>
88 class RawPropertyList : public PropertyList<T> {
89  public:
90  template <typename F, typename... Args>
91  void add(const F& funct, const Args&... args);
92 };
93 
94 
95 class Chunking {
96  public:
97  explicit Chunking(const std::vector<hsize_t>& dims)
98  : _dims(dims) {}
99 
100  Chunking(const std::initializer_list<hsize_t>& items)
101  : Chunking(std::vector<hsize_t>{items}) {}
102 
103  template <typename... Args>
104  explicit Chunking(hsize_t item, Args... args)
105  : Chunking(std::vector<hsize_t>{item, static_cast<hsize_t>(args)...}) {}
106 
107  const std::vector<hsize_t>& getDimensions() const noexcept {
108  return _dims;
109  }
110 
111  private:
112  friend DataSetCreateProps;
113  void apply(hid_t hid) const;
114  const std::vector<hsize_t> _dims;
115 };
116 
117 class Deflate {
118  public:
119  explicit Deflate(unsigned level)
120  : _level(level) {}
121 
122  private:
123  friend DataSetCreateProps;
124  void apply(hid_t hid) const;
125  const unsigned _level;
126 };
127 
128 class Shuffle {
129  public:
130  Shuffle() = default;
131 
132  private:
133  friend DataSetCreateProps;
134  void apply(hid_t hid) const;
135 };
136 
139 class Caching {
140  public:
143  Caching(const size_t numSlots,
144  const size_t cacheSize,
145  const double w0 = static_cast<double>(H5D_CHUNK_CACHE_W0_DEFAULT))
146  : _numSlots(numSlots)
147  , _cacheSize(cacheSize)
148  , _w0(w0) {}
149 
150  private:
151  friend DataSetAccessProps;
152  void apply(hid_t hid) const;
153  const size_t _numSlots;
154  const size_t _cacheSize;
155  const double _w0;
156 };
157 
158 } // namespace HighFive
159 
161 
162 #endif // H5PROPERTY_LIST_HPP
Definition: H5PropertyList.hpp:139
Caching(const size_t numSlots, const size_t cacheSize, const double w0=static_cast< double >(H5D_CHUNK_CACHE_W0_DEFAULT))
Definition: H5PropertyList.hpp:143
Definition: H5PropertyList.hpp:95
const std::vector< hsize_t > & getDimensions() const noexcept
Definition: H5PropertyList.hpp:107
Chunking(hsize_t item, Args... args)
Definition: H5PropertyList.hpp:104
Chunking(const std::vector< hsize_t > &dims)
Definition: H5PropertyList.hpp:97
Chunking(const std::initializer_list< hsize_t > &items)
Definition: H5PropertyList.hpp:100
Definition: H5PropertyList.hpp:117
Deflate(unsigned level)
Definition: H5PropertyList.hpp:119
Base HDF5 property List.
Definition: H5PropertyList.hpp:46
PropertyList() noexcept
Definition: H5PropertyList_misc.hpp:60
void _initializeIfNeeded()
Definition: H5PropertyList_misc.hpp:87
~PropertyList()
Definition: H5PropertyList_misc.hpp:79
hid_t getId() const
Definition: H5PropertyList.hpp:56
hid_t _hid
Definition: H5PropertyList.hpp:74
PropertyList(const PropertyList< T > &)=delete
constexpr PropertyType getType() const
Definition: H5PropertyList.hpp:54
PropertyList & operator=(const PropertyList< T > &)=delete
void add(const P &property)
Definition: H5PropertyList_misc.hpp:99
Definition: H5PropertyList.hpp:88
Definition: H5PropertyList.hpp:128
Definition: H5_definitions.hpp:15
PropertyType
Types of property lists.
Definition: H5PropertyList.hpp:24
PropertyList< PropertyType::DATASET_ACCESS > DataSetAccessProps
Definition: H5PropertyList.hpp:80
PropertyList< PropertyType::DATASET_CREATE > DataSetCreateProps
Definition: H5PropertyList.hpp:79