Fesapi 2.3.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
HdfProxy.h
1/*-----------------------------------------------------------------------
2Licensed to the Apache Software Foundation (ASF) under one
3or more contributor license agreements. See the NOTICE file
4distributed with this work for additional information
5regarding copyright ownership. The ASF licenses this file
6to you under the Apache License, Version 2.0 (the
7"License"; you may not use this file except in compliance
8with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing,
13software distributed under the License is distributed on an
14"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15KIND, either express or implied. See the License for the
16specific language governing permissions and limitations
17under the License.
18-----------------------------------------------------------------------*/
19#pragma once
20
21#include "AbstractHdfProxy.h"
22
23#include <unordered_map>
24
25namespace EML2_NS
26{
29 {
30 public:
31
37 HdfProxy(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : AbstractHdfProxy(partialObject), hdfFile(-1), compressionLevel(0) {}
38
44 HdfProxy(const COMMON_NS::DataObjectReference& dor) : AbstractHdfProxy(dor), hdfFile(-1), compressionLevel(0) {}
45
47 virtual ~HdfProxy() { close(); }
48
49 void open() override;
50
51 DLL_IMPORT_OR_EXPORT bool isOpened() const final { return hdfFile != -1; }
52
53 void close() final;
54
55 COMMON_NS::AbstractObject::hdfDatatypeEnum getHdfDatatypeInDataset(const std::string& groupName) final;
56
57 int getHdfDatatypeClassInDataset(const std::string& datasetName) final;
58
59 void writeItemizedListOfList(const std::string& groupName,
60 const std::string& name,
61 hdf5_hid_t cumulativeLengthDatatype,
62 const void* cumulativeLength,
63 unsigned long long cumulativeLengthSize,
64 hdf5_hid_t elementsDatatype,
65 const void* elements,
66 unsigned long long elementsSize) final;
67
68 unsigned int getDimensionCount(const std::string& datasetName) final;
69
74 std::vector<unsigned long long> getElementCountPerDimension(const std::string & datasetName) final;
75
76 signed long long getElementCount(const std::string& datasetName) final;
77
78 DLL_IMPORT_OR_EXPORT void setCompressionLevel(unsigned int newCompressionLevel) final {
79 compressionLevel = newCompressionLevel > 9 ? 9 : newCompressionLevel;
80 }
81
82 void writeArrayNdOfFloatValues(const std::string& groupName,
83 const std::string& name,
84 const float* floatValues,
85 const unsigned long long* numValuesInEachDimension,
86 unsigned int numDimensions) final;
87
88 void writeArrayNdOfDoubleValues(const std::string& groupName,
89 const std::string& name,
90 const double* dblValues,
91 const unsigned long long* numValuesInEachDimension,
92 unsigned int numDimensions) final;
93
94 void writeArrayNdOfCharValues(const std::string& groupName,
95 const std::string& name,
96 const char* intValues,
97 const unsigned long long* numValuesInEachDimension,
98 unsigned int numDimensions) final;
99
100 void writeArrayNdOfIntValues(const std::string& groupName,
101 const std::string& name,
102 const int* intValues,
103 const unsigned long long* numValuesInEachDimension,
104 unsigned int numDimensions) final;
105
106 void writeArrayNdOfInt64Values(const std::string & groupName,
107 const std::string & name,
108 const int64_t * values,
109 const unsigned long long * numValuesInEachDimension,
110 unsigned int numDimensions) final;
111
112 void writeArrayNdOfUInt64Values(const std::string& groupName,
113 const std::string& name,
114 const uint64_t * values,
115 const unsigned long long* numValuesInEachDimension,
116 unsigned int numDimensions) final;
117
118 void writeArrayNd(const std::string& groupName,
119 const std::string& name,
120 hdf5_hid_t datatype,
121 const void* values,
122 const unsigned long long* numValuesInEachDimension,
123 unsigned int numDimensions) final;
124
126 const std::string& groupName,
127 const std::string& name,
128 hdf5_hid_t datatype,
129 const unsigned long long* numValuesInEachDimension,
130 unsigned int numDimensions
131 ) final;
132
134 const std::string& groupName,
135 const std::string& name,
136 hdf5_hid_t datatype,
137 const void* values,
138 const unsigned long long* numValuesInEachDimension,
139 const unsigned long long* offsetValuesInEachDimension,
140 unsigned int numDimensions
141 ) final;
142
143 void writeGroupAttributes(const std::string& groupName,
144 const std::vector<std::string>& attributeNames,
145 const std::vector<std::string>& values) final;
146
147 void writeGroupAttribute(const std::string& groupName,
148 const std::string& attributeName,
149 const std::vector<std::string>& values) final;
150
151 void writeGroupAttributes(const std::string& groupName,
152 const std::vector<std::string>& attributeNames,
153 const std::vector<double>& values) final;
154
155 void writeGroupAttributes(const std::string& groupName,
156 const std::vector<std::string>& attributeNames,
157 const std::vector<int>& values) final;
158
159 void writeDatasetAttributes(const std::string& datasetName,
160 const std::vector<std::string>& attributeNames,
161 const std::vector<std::string>& values) final;
162
163 void writeDatasetAttribute(const std::string& datasetName,
164 const std::string& attributeName,
165 const std::vector<std::string>& values) final;
166
167 void writeDatasetAttributes(const std::string& datasetName,
168 const std::vector<std::string>& attributeNames,
169 const std::vector<double>& values) final;
170
171 void writeDatasetAttributes(const std::string& datasetName,
172 const std::vector<std::string>& attributeNames,
173 const std::vector<int>& values) final;
174
175 std::string readStringAttribute(const std::string& obj_name,
176 const std::string& attr_name) const final;
177
178 std::vector<std::string> readStringArrayAttribute(const std::string& obj_name,
179 const std::string& attr_name) const final;
180
181 double readDoubleAttribute(const std::string& obj_name,
182 const std::string& attr_name) const final;
183
184 int64_t readLongAttribute(const std::string& obj_name,
185 const std::string& attr_name) const final;
186
187 void readArrayNdOfDoubleValues(const std::string& datasetName, double* values) final;
188
190 const std::string& datasetName,
191 double* values,
192 unsigned long long const* numValuesInEachDimension,
193 unsigned long long const* offsetInEachDimension,
194 unsigned int numDimensions
195 ) final;
196
198 const std::string& datasetName, double* values,
199 unsigned long long const* blockCountPerDimension,
200 unsigned long long const* offsetInEachDimension,
201 unsigned long long const* strideInEachDimension,
202 unsigned long long const* blockSizeInEachDimension,
203 unsigned int numDimensions) final;
204
206 const std::string& datasetName,
207 unsigned long long const* blockCountPerDimension,
208 unsigned long long const* offsetInEachDimension,
209 unsigned long long const* strideInEachDimension,
210 unsigned long long const* blockSizeInEachDimension,
211 unsigned int numDimensions,
212 bool newSelection,
213 hdf5_hid_t& dataset,
214 hdf5_hid_t& filespace) final;
215
217 hdf5_hid_t dataset,
218 hdf5_hid_t filespace,
219 void* values,
220 unsigned long long slabSize) final;
221
222 void readArrayNdOfFloatValues(const std::string& datasetName, float* values) final;
223
225 const std::string& datasetName,
226 float* values,
227 unsigned long long const* numValuesInEachDimension,
228 unsigned long long const* offsetInEachDimension,
229 unsigned int numDimensions
230 ) final;
231
232 void readArrayNdOfInt64Values(const std::string& datasetName, int64_t* values) final;
233
235 const std::string& datasetName,
236 int64_t* values,
237 unsigned long long const* numValuesInEachDimension,
238 unsigned long long const* offsetInEachDimension,
239 unsigned int numDimensions) final;
240
241 void readArrayNdOfUInt64Values(const std::string& datasetName, uint64_t* values) final;
242
243 void readArrayNdOfIntValues(const std::string& datasetName, int* values) final;
244
246 const std::string& datasetName,
247 int* values,
248 unsigned long long const* numValuesInEachDimension,
249 unsigned long long const* offsetInEachDimension,
250 unsigned int numDimensions
251 ) final;
252
253 void readArrayNdOfUIntValues(const std::string& datasetName, unsigned int* values) final;
254
255 void readArrayNdOfShortValues(const std::string& datasetName, short* values) final;
256
257 void readArrayNdOfUShortValues(const std::string& datasetName, unsigned short* values) final;
258
259 void readArrayNdOfCharValues(const std::string& datasetName, char* values) final;
260
261 void readArrayNdOfUCharValues(const std::string& datasetName, unsigned char* values) final;
262
263 std::vector<unsigned long long> readArrayDimensions(const std::string& datasetName) final;
264
265 bool exist(const std::string& absolutePathInHdfFile) const final;
266
267 bool isCompressed(const std::string& datasetName) final;
268
269 std::vector<unsigned long long> getElementCountPerChunkDimension(const std::string & datasetName) final;
270
271 protected:
272
278 HdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap) :
279 AbstractHdfProxy(fromGsoap), hdfFile(-1), compressionLevel(0), openedGroups() {}
280
286 HdfProxy(gsoap_eml2_1::_eml21__EpcExternalPartReference* fromGsoap) :
287 AbstractHdfProxy(fromGsoap), hdfFile(-1), compressionLevel(0), openedGroups() {}
288
294 HdfProxy(gsoap_eml2_3::_eml23__EpcExternalPartReference* fromGsoap) :
295 AbstractHdfProxy(fromGsoap), hdfFile(-1), compressionLevel(0), openedGroups() {}
296
308 HdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath, COMMON_NS::DataObjectRepository::openingMode hdfPermissionAccess = COMMON_NS::DataObjectRepository::openingMode::READ_ONLY);
309
319 void readArrayNdOfValues(const std::string& datasetName, void* values, hdf5_hid_t datatype);
320
339 void readArrayNdOfValues(
340 const std::string& datasetName,
341 void* values,
342 unsigned long long const* numValuesInEachDimension,
343 unsigned long long const* offsetInEachDimension,
344 unsigned int numDimensions,
345 hdf5_hid_t datatype);
346
370 void readArrayNdOfValues(
371 const std::string& datasetName,
372 void* values,
373 unsigned long long const* blockCountPerDimension,
374 unsigned long long const* offsetInEachDimension,
375 unsigned long long const* strideInEachDimension,
376 unsigned long long const* blockSizeInEachDimension,
377 unsigned int numDimensions,
378 hdf5_hid_t datatype);
379
393 void readArrayNdOfValues(
394 hdf5_hid_t dataset,
395 hdf5_hid_t filespace,
396 void* values,
397 unsigned long long slabSize,
398 hdf5_hid_t datatype);
399
403 void writeUuidAttribute();
404
414 hdf5_hid_t openOrCreateGroup(const std::string& groupName);
415
417 hdf5_hid_t hdfFile;
418
420 unsigned int compressionLevel;
421
423 std::unordered_map< std::string, hdf5_hid_t > openedGroups;
424
425 private:
426
427 std::vector<unsigned long long> reduceForChunking(hdf5_hid_t datatype,
428 const unsigned long long * numValuesInEachDimension,
429 unsigned int numDimensions) const;
430 };
431}
An abstract proxy for reading and writing values into an HDF5 file. It is possible to derive this cla...
Definition: AbstractHdfProxy.h:42
A proxy for reading and writing values into an HDF5 file.
Definition: HdfProxy.h:29
void writeArrayNd(const std::string &groupName, const std::string &name, hdf5_hid_t datatype, const void *values, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
double readDoubleAttribute(const std::string &obj_name, const std::string &attr_name) const final
void readArrayNdOfDoubleValues(const std::string &datasetName, double *values) final
HdfProxy(gsoap_resqml2_0_1::eml20__DataObjectReference *partialObject)
Definition: HdfProxy.h:37
void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< int > &values) final
void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions) final
void writeDatasetAttribute(const std::string &datasetName, const std::string &attributeName, const std::vector< std::string > &values) final
void writeArrayNdOfIntValues(const std::string &groupName, const std::string &name, const int *intValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
void readArrayNdOfUIntValues(const std::string &datasetName, unsigned int *values) final
void writeArrayNdOfCharValues(const std::string &groupName, const std::string &name, const char *intValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values) final
void writeArrayNdOfFloatValues(const std::string &groupName, const std::string &name, const float *floatValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< double > &values) final
std::vector< std::string > readStringArrayAttribute(const std::string &obj_name, const std::string &attr_name) const final
void writeArrayNdSlab(const std::string &groupName, const std::string &name, hdf5_hid_t datatype, const void *values, const unsigned long long *numValuesInEachDimension, const unsigned long long *offsetValuesInEachDimension, unsigned int numDimensions) final
std::vector< unsigned long long > getElementCountPerChunkDimension(const std::string &datasetName) final
void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< double > &values) final
void createArrayNd(const std::string &groupName, const std::string &name, hdf5_hid_t datatype, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
void readArrayNdOfFloatValues(const std::string &datasetName, float *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions) final
bool isOpened() const final
Definition: HdfProxy.h:51
void close() final
std::string readStringAttribute(const std::string &obj_name, const std::string &attr_name) const final
void readArrayNdOfUInt64Values(const std::string &datasetName, uint64_t *values) final
int64_t readLongAttribute(const std::string &obj_name, const std::string &attr_name) const final
void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions) final
void writeArrayNdOfInt64Values(const std::string &groupName, const std::string &name, const int64_t *values, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
virtual ~HdfProxy()
Definition: HdfProxy.h:47
void readArrayNdOfCharValues(const std::string &datasetName, char *values) final
void readArrayNdOfFloatValues(const std::string &datasetName, float *values) final
void readArrayNdOfUShortValues(const std::string &datasetName, unsigned short *values) final
void selectArrayNdOfValues(const std::string &datasetName, unsigned long long const *blockCountPerDimension, unsigned long long const *offsetInEachDimension, unsigned long long const *strideInEachDimension, unsigned long long const *blockSizeInEachDimension, unsigned int numDimensions, bool newSelection, hdf5_hid_t &dataset, hdf5_hid_t &filespace) final
void writeArrayNdOfDoubleValues(const std::string &groupName, const std::string &name, const double *dblValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
void readArrayNdOfDoubleValues(hdf5_hid_t dataset, hdf5_hid_t filespace, void *values, unsigned long long slabSize) final
void writeArrayNdOfUInt64Values(const std::string &groupName, const std::string &name, const uint64_t *values, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions) final
bool exist(const std::string &absolutePathInHdfFile) const final
void readArrayNdOfIntValues(const std::string &datasetName, int *values) final
void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, unsigned long long const *blockCountPerDimension, unsigned long long const *offsetInEachDimension, unsigned long long const *strideInEachDimension, unsigned long long const *blockSizeInEachDimension, unsigned int numDimensions) final
void readArrayNdOfShortValues(const std::string &datasetName, short *values) final
HdfProxy(const common::DataObjectReference &dor)
Constructor.
Definition: HdfProxy.h:44
std::vector< unsigned long long > readArrayDimensions(const std::string &datasetName) final
void readArrayNdOfUCharValues(const std::string &datasetName, unsigned char *values) final
bool isCompressed(const std::string &datasetName) final
void writeGroupAttribute(const std::string &groupName, const std::string &attributeName, const std::vector< std::string > &values) final
void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< std::string > &values) final
void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< std::string > &values) final
void readArrayNdOfIntValues(const std::string &datasetName, int *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions) final
void open() override
void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< int > &values) final