Fesapi 2.10.1.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Loading...
Searching...
No Matches
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) {}
38
44 HdfProxy(const COMMON_NS::DataObjectReference& dor) : AbstractHdfProxy(dor) {}
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::numericalDatatypeEnum getNumericalDatatype(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 COMMON_NS::AbstractObject::numericalDatatypeEnum cumulativeLengthDatatype,
62 const void* cumulativeLength,
63 uint64_t cumulativeLengthSize,
64 COMMON_NS::AbstractObject::numericalDatatypeEnum elementsDatatype,
65 const void* elements,
66 uint64_t elementsSize) final;
67
73 std::vector<uint32_t> getElementCountPerDimension(const std::string & datasetName) final;
74
75 DLL_IMPORT_OR_EXPORT void setCompressionLevel(unsigned int newCompressionLevel) final {
76 compressionLevel = newCompressionLevel > 9 ? 9 : newCompressionLevel;
77 }
78
79 void writeArrayNd(const std::string& groupName,
80 const std::string& name,
81 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
82 const void* values,
83 const uint64_t* numValuesInEachDimension,
84 unsigned int numDimensions) final;
85
87 const std::string& groupName,
88 const std::string& name,
89 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
90 const uint64_t* numValuesInEachDimension,
91 unsigned int numDimensions
92 ) final;
93
95 const std::string& groupName,
96 const std::string& name,
97 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
98 const void* values,
99 const uint64_t* numValuesInEachDimension,
100 const uint64_t* offsetValuesInEachDimension,
101 unsigned int numDimensions
102 ) final;
103
104 void writeGroupAttributes(const std::string& groupName,
105 const std::vector<std::string>& attributeNames,
106 const std::vector<std::string>& values) final;
107
108 void writeGroupAttribute(const std::string& groupName,
109 const std::string& attributeName,
110 const std::vector<std::string>& values) final;
111
112 void writeGroupAttributes(const std::string& groupName,
113 const std::vector<std::string>& attributeNames,
114 const std::vector<double>& values) final;
115
116 void writeGroupAttributes(const std::string& groupName,
117 const std::vector<std::string>& attributeNames,
118 const std::vector<int>& values) final;
119
120 void writeDatasetAttributes(const std::string& datasetName,
121 const std::vector<std::string>& attributeNames,
122 const std::vector<std::string>& values) final;
123
124 void writeDatasetAttribute(const std::string& datasetName,
125 const std::string& attributeName,
126 const std::vector<std::string>& values) final;
127
128 void writeDatasetAttributes(const std::string& datasetName,
129 const std::vector<std::string>& attributeNames,
130 const std::vector<double>& values) final;
131
132 void writeDatasetAttributes(const std::string& datasetName,
133 const std::vector<std::string>& attributeNames,
134 const std::vector<int>& values) final;
135
136 std::string readStringAttribute(const std::string& obj_name,
137 const std::string& attr_name) const final;
138
139 std::vector<std::string> readStringArrayAttribute(const std::string& obj_name,
140 const std::string& attr_name) const final;
141
142 double readDoubleAttribute(const std::string& obj_name,
143 const std::string& attr_name) const final;
144
145 int64_t readInt64Attribute(const std::string& obj_name,
146 const std::string& attr_name) const final;
147
148 void readArrayNdOfDoubleValues(const std::string& datasetName, double* values) final;
149
151 const std::string& datasetName,
152 double* values,
153 uint64_t const* numValuesInEachDimension,
154 uint64_t const* offsetInEachDimension,
155 unsigned int numDimensions
156 ) final;
157
159 const std::string& datasetName, double* values,
160 uint64_t const* blockCountPerDimension,
161 uint64_t const* offsetInEachDimension,
162 uint64_t const* strideInEachDimension,
163 uint64_t const* blockSizeInEachDimension,
164 unsigned int numDimensions) final;
165
167 const std::string& datasetName,
168 uint64_t const* blockCountPerDimension,
169 uint64_t const* offsetInEachDimension,
170 uint64_t const* strideInEachDimension,
171 uint64_t const* blockSizeInEachDimension,
172 unsigned int numDimensions,
173 bool newSelection,
174 hdf5_hid_t& dataset,
175 hdf5_hid_t& filespace) final;
176
178 hdf5_hid_t dataset,
179 hdf5_hid_t filespace,
180 void* values,
181 uint64_t slabSize) final;
182
183 void readArrayNdOfFloatValues(const std::string& datasetName, float* values) final;
184
186 const std::string& datasetName,
187 float* values,
188 uint64_t const* numValuesInEachDimension,
189 uint64_t const* offsetInEachDimension,
190 unsigned int numDimensions
191 ) final;
192
193 void readArrayNdOfInt64Values(const std::string& datasetName, int64_t* values) final;
194
196 const std::string& datasetName,
197 int64_t* values,
198 uint64_t const* numValuesInEachDimension,
199 uint64_t const* offsetInEachDimension,
200 unsigned int numDimensions) final;
201
202 void readArrayNdOfUInt64Values(const std::string& datasetName, uint64_t* values) final;
203
204 void readArrayNdOfIntValues(const std::string& datasetName, int* values) final;
205
207 const std::string& datasetName,
208 int* values,
209 uint64_t const* numValuesInEachDimension,
210 uint64_t const* offsetInEachDimension,
211 unsigned int numDimensions
212 ) final;
213
214 void readArrayNdOfUIntValues(const std::string& datasetName, unsigned int* values) final;
215
216 void readArrayNdOfShortValues(const std::string& datasetName, short* values) final;
217
218 void readArrayNdOfUShortValues(const std::string& datasetName, unsigned short* values) final;
219
220 void readArrayNdOfInt8Values(const std::string& datasetName, int8_t* values) final;
221
222 void readArrayNdOfUInt8Values(const std::string& datasetName, uint8_t* values) final;
223
224 bool exist(const std::string& absolutePathInHdfFile) const final;
225
226 bool isCompressed(const std::string& datasetName) final;
227
228 std::vector<uint32_t> getElementCountPerChunkDimension(const std::string & datasetName) final;
229
230 protected:
231
237 HdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap) :
238 AbstractHdfProxy(fromGsoap) {}
239
251 HdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath, COMMON_NS::DataObjectRepository::openingMode hdfPermissionAccess = COMMON_NS::DataObjectRepository::openingMode::READ_ONLY);
252
262 void readArrayNdOfValues(const std::string& datasetName, void* values, hdf5_hid_t datatype);
263
282 void readArrayNdOfValues(
283 const std::string& datasetName,
284 void* values,
285 uint64_t const* numValuesInEachDimension,
286 uint64_t const* offsetInEachDimension,
287 unsigned int numDimensions,
288 hdf5_hid_t datatype);
289
313 void readArrayNdOfValues(
314 const std::string& datasetName,
315 void* values,
316 uint64_t const* blockCountPerDimension,
317 uint64_t const* offsetInEachDimension,
318 uint64_t const* strideInEachDimension,
319 uint64_t const* blockSizeInEachDimension,
320 unsigned int numDimensions,
321 hdf5_hid_t datatype);
322
336 void readArrayNdOfValues(
337 hdf5_hid_t dataset,
338 hdf5_hid_t filespace,
339 void* values,
340 uint64_t slabSize,
341 hdf5_hid_t datatype);
342
346 void writeUuidAttribute();
347
357 hdf5_hid_t openOrCreateGroup(const std::string& groupName);
358
360 hdf5_hid_t hdfFile = -1;
361
363 unsigned int compressionLevel = 0;
364
366 std::unique_ptr<hdf5_hid_t> dsetPlistId;
367
369 std::unordered_map< std::string, hdf5_hid_t > openedGroups;
370 };
371}
An abstract proxy for reading and writing values into an HDF5 file. It is possible to derive this cla...
Definition AbstractHdfProxy.h:37
A proxy for reading and writing values into an HDF5 file.
Definition HdfProxy.h:29
void readArrayNdOfIntValues(const std::string &datasetName, int *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, 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 writeDatasetAttribute(const std::string &datasetName, const std::string &attributeName, const std::vector< std::string > &values) final
void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions) final
void readArrayNdOfUIntValues(const std::string &datasetName, unsigned int *values) final
void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values) final
void readArrayNdOfUInt8Values(const std::string &datasetName, uint8_t *values) 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 writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< double > &values) final
void readArrayNdOfInt8Values(const std::string &datasetName, int8_t *values) final
bool isOpened() const final
Definition HdfProxy.h:51
void readArrayNdOfDoubleValues(hdf5_hid_t dataset, hdf5_hid_t filespace, void *values, uint64_t slabSize) final
void close() final
void writeArrayNd(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum datatype, const void *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions) final
std::string readStringAttribute(const std::string &obj_name, const std::string &attr_name) const final
void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, uint64_t const *blockCountPerDimension, uint64_t const *offsetInEachDimension, uint64_t const *strideInEachDimension, uint64_t const *blockSizeInEachDimension, unsigned int numDimensions) final
void readArrayNdOfUInt64Values(const std::string &datasetName, uint64_t *values) final
int64_t readInt64Attribute(const std::string &obj_name, const std::string &attr_name) const final
void readArrayNdOfFloatValues(const std::string &datasetName, float *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions) final
virtual ~HdfProxy()
Definition HdfProxy.h:47
void writeArrayNdSlab(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum datatype, const void *values, const uint64_t *numValuesInEachDimension, const uint64_t *offsetValuesInEachDimension, unsigned int numDimensions) final
void readArrayNdOfFloatValues(const std::string &datasetName, float *values) final
void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions) final
void readArrayNdOfUShortValues(const std::string &datasetName, unsigned short *values) final
bool exist(const std::string &absolutePathInHdfFile) const final
void readArrayNdOfIntValues(const std::string &datasetName, int *values) final
void readArrayNdOfShortValues(const std::string &datasetName, short *values) final
HdfProxy(const common::DataObjectReference &dor)
Constructor.
Definition HdfProxy.h:44
std::vector< uint32_t > getElementCountPerChunkDimension(const std::string &datasetName) 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 selectArrayNdOfValues(const std::string &datasetName, uint64_t const *blockCountPerDimension, uint64_t const *offsetInEachDimension, uint64_t const *strideInEachDimension, uint64_t const *blockSizeInEachDimension, unsigned int numDimensions, bool newSelection, hdf5_hid_t &dataset, hdf5_hid_t &filespace) final
void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< std::string > &values) final
void open() override
void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< int > &values) final
void createArrayNd(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum datatype, const uint64_t *numValuesInEachDimension, unsigned int numDimensions) final