hops
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;
51  PropertyList& operator=(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
HighFive::PropertyList::operator=
PropertyList & operator=(const PropertyList< T > &)=delete
HighFive::PropertyList::_initializeIfNeeded
void _initializeIfNeeded()
Definition: H5PropertyList_misc.hpp:87
H5Object.hpp
HighFive::DataSetAccessProps
PropertyList< PropertyType::DATASET_ACCESS > DataSetAccessProps
Definition: H5PropertyList.hpp:80
HighFive::PropertyType
PropertyType
Types of property lists.
Definition: H5PropertyList.hpp:24
H5PropertyList_misc.hpp
HighFive::PropertyType::OBJECT_COPY
@ OBJECT_COPY
HighFive::PropertyType::STRING_CREATE
@ STRING_CREATE
HighFive::Chunking::Chunking
Chunking(hsize_t item, Args... args)
Definition: H5PropertyList.hpp:104
HighFive::PropertyType::FILE_CREATE
@ FILE_CREATE
HighFive::PropertyType::LINK_CREATE
@ LINK_CREATE
HighFive::PropertyType::DATATYPE_CREATE
@ DATATYPE_CREATE
HighFive::PropertyList
Base HDF5 property List.
Definition: H5_definitions.hpp:48
HighFive::DataSetCreateProps
PropertyList< PropertyType::DATASET_CREATE > DataSetCreateProps
Definition: H5PropertyList.hpp:79
HighFive::PropertyType::DATASET_CREATE
@ DATASET_CREATE
HighFive::PropertyType::ATTRIBUTE_CREATE
@ ATTRIBUTE_CREATE
HighFive::Chunking::Chunking
Chunking(const std::initializer_list< hsize_t > &items)
Definition: H5PropertyList.hpp:100
HighFive::PropertyList::add
void add(const P &property)
Definition: H5PropertyList_misc.hpp:99
HighFive::Deflate
Definition: H5PropertyList.hpp:117
HighFive::PropertyList::~PropertyList
~PropertyList()
Definition: H5PropertyList_misc.hpp:79
HighFive::Chunking
Definition: H5PropertyList.hpp:95
HighFive::PropertyList::getType
constexpr PropertyType getType() const
Definition: H5PropertyList.hpp:54
HighFive::PropertyType::DATASET_XFER
@ DATASET_XFER
HighFive::RawPropertyList
Definition: H5PropertyList.hpp:88
HighFive::PropertyList::getId
hid_t getId() const
Definition: H5PropertyList.hpp:56
HighFive::PropertyType::GROUP_CREATE
@ GROUP_CREATE
HighFive::PropertyType::OBJECT_CREATE
@ OBJECT_CREATE
HighFive::PropertyType::DATATYPE_ACCESS
@ DATATYPE_ACCESS
HighFive::PropertyType::DATASET_ACCESS
@ DATASET_ACCESS
H5Exception.hpp
HighFive::Shuffle
Definition: H5PropertyList.hpp:128
HighFive::Deflate::Deflate
Deflate(unsigned level)
Definition: H5PropertyList.hpp:119
HighFive::PropertyList::_hid
hid_t _hid
Definition: H5PropertyList.hpp:74
HighFive::PropertyList::PropertyList
PropertyList() noexcept
Definition: H5PropertyList_misc.hpp:60
HighFive::Chunking::getDimensions
const std::vector< hsize_t > & getDimensions() const noexcept
Definition: H5PropertyList.hpp:107
HighFive::Caching::Caching
Caching(const size_t numSlots, const size_t cacheSize, const double w0=static_cast< double >(H5D_CHUNK_CACHE_W0_DEFAULT))
Definition: H5PropertyList.hpp:143
HighFive::PropertyType::GROUP_ACCESS
@ GROUP_ACCESS
HighFive::PropertyType::FILE_ACCESS
@ FILE_ACCESS
HighFive
Definition: H5_definitions.hpp:15
HighFive::Chunking::Chunking
Chunking(const std::vector< hsize_t > &dims)
Definition: H5PropertyList.hpp:97
HighFive::Caching
Definition: H5PropertyList.hpp:139
HighFive::PropertyType::LINK_ACCESS
@ LINK_ACCESS