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
HighFive::Caching::_numSlots
const unsigned int _numSlots
Definition: H5PropertyList.hpp:133
HighFive::Caching::_w0
const double _w0
Definition: H5PropertyList.hpp:135
HighFive::Deflate::apply
void apply(hid_t hid) const
Definition: H5PropertyList_misc.hpp:94
HighFive::Properties::Type
Type
Definition: H5PropertyList.hpp:23
HighFive::Caching::apply
void apply(hid_t hid) const
Definition: H5PropertyList_misc.hpp:124
HighFive::Deflate::_level
const int _level
Definition: H5PropertyList.hpp:103
HighFive::Properties::operator=
Properties & operator=(Properties &&other)
Definition: H5PropertyList_misc.hpp:32
HighFive::Chunking::apply
void apply(hid_t hid) const
Definition: H5PropertyList_misc.hpp:85
HighFive::Properties::DATASET_ACCESS
@ DATASET_ACCESS
Definition: H5PropertyList.hpp:27
HighFive::Properties::_type
Type _type
Definition: H5PropertyList.hpp:63
HighFive::Properties::~Properties
~Properties()
Definition: H5PropertyList_misc.hpp:43
HighFive::Properties::_hid
hid_t _hid
Definition: H5PropertyList.hpp:64
HighFive::Chunking::_dims
const std::vector< hsize_t > _dims
Definition: H5PropertyList.hpp:92
HighFive::Caching::_cacheSize
const size_t _cacheSize
Definition: H5PropertyList.hpp:134
HighFive::Properties::add
void add(const Property &property)
Definition: H5PropertyList_misc.hpp:51
HighFive::Properties::DATASET_CREATE
@ DATASET_CREATE
Definition: H5PropertyList.hpp:26
HighFive::Properties::Properties
Properties(Properties &&other)
Definition: H5PropertyList_misc.hpp:25
HighFive::Properties
Generic HDF5 property List.
Definition: H5PropertyList.hpp:21
HighFive::Shuffle::apply
void apply(hid_t hid) const
Definition: H5PropertyList_misc.hpp:109
HighFive::Properties::FILE_ACCESS
@ FILE_ACCESS
Definition: H5PropertyList.hpp:25
HighFive
Definition: H5Annotate_traits.hpp:14


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