H5PropertyList_misc.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_MISC_HPP
10 #define H5PROPERTY_LIST_MISC_HPP
11 
12 #include <H5Ppublic.h>
13 
14 #include "../H5PropertyList.hpp"
15 
16 namespace HighFive {
17 
19  : _type(type)
20  , _hid(H5P_DEFAULT)
21 {
22 }
23 
24 #ifdef H5_USE_CXX11
26  : _type(other._type)
27  , _hid(other._hid)
28 {
29  other._hid = H5P_DEFAULT;
30 }
31 
33 {
34  _type = other._type;
35  // This code handles self-assigment without ifs
36  const auto hid = other._hid;
37  other._hid = H5P_DEFAULT;
38  _hid = hid;
39  return *this;
40 }
41 #endif
42 
44 {
45  // H5P_DEFAULT and H5I_INVALID_HID are not the same Ensuring that ~Object
46  if (_hid != H5P_DEFAULT)
47  H5Pclose(_hid);
48 }
49 
50 template <typename Property>
51 inline void Properties::add(const Property& property)
52 {
53  if (_hid == H5P_DEFAULT)
54  {
55  hid_t type;
56  // The HP5_XXX are macros with function calls so we can't assign
57  // them as the enum values
58  switch (_type)
59  {
60  case FILE_ACCESS: {
61  type = H5P_FILE_ACCESS;
62  break;
63  }
64  case DATASET_CREATE: {
65  type = H5P_DATASET_CREATE;
66  break;
67  }
68  case DATASET_ACCESS: {
69  type = H5P_DATASET_ACCESS;
70  break;
71  }
72  default:
73  HDF5ErrMapper::ToException<PropertyException>(
74  std::string("Unsupported property list type"));
75  }
76  if ((_hid = H5Pcreate(type)) < 0) {
77  HDF5ErrMapper::ToException<PropertyException>(
78  std::string("Unable to create property list"));
79  }
80  }
81 
82  property.apply(_hid);
83 }
84 
85 inline void Chunking::apply(const hid_t hid) const
86 {
87  if (H5Pset_chunk(hid, _dims.size(), _dims.data()) < 0)
88  {
89  HDF5ErrMapper::ToException<PropertyException>(
90  "Error setting chunk property");
91  }
92 }
93 
94 inline void Deflate::apply(const hid_t hid) const
95 {
96  if (!H5Zfilter_avail(H5Z_FILTER_DEFLATE))
97  {
98  HDF5ErrMapper::ToException<PropertyException>(
99  "Error setting deflate property");
100  }
101 
102  if (H5Pset_deflate(hid, _level) < 0)
103  {
104  HDF5ErrMapper::ToException<PropertyException>(
105  "Error setting deflate property");
106  }
107 }
108 
109 inline void Shuffle::apply(const hid_t hid) const
110 {
111  if (!H5Zfilter_avail(H5Z_FILTER_SHUFFLE))
112  {
113  HDF5ErrMapper::ToException<PropertyException>(
114  "Error setting shuffle property");
115  }
116 
117  if (H5Pset_shuffle(hid) < 0)
118  {
119  HDF5ErrMapper::ToException<PropertyException>(
120  "Error setting shuffle property");
121  }
122 }
123 
124 inline void Caching::apply(const hid_t hid) const
125 {
126  if (H5Pset_chunk_cache(hid, _numSlots, _cacheSize, _w0) < 0)
127  {
128  HDF5ErrMapper::ToException<PropertyException>(
129  "Error setting dataset cache parameters");
130  }
131 }
132 }
133 #endif // H5PROPERTY_LIST_HPP
void apply(hid_t hid) const
void add(const Property &property)
void apply(hid_t hid) const
Generic HDF5 property List.
Properties(Properties &&other)
void apply(hid_t hid) const
void apply(hid_t hid) const
Properties & operator=(Properties &&other)


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