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
AbstractHdfProxy.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 "EpcExternalPartReference.h"
22#include "../common/HidtType.h"
23
24namespace EML2_NS
25{
37 {
38 public:
39
41 static constexpr char const* CUMULATIVE_LENGTH_DS_NAME = "cumulativeLength";
43 static constexpr char const* ELEMENTS_DS_NAME = "elements";
44
46 DLL_IMPORT_OR_EXPORT virtual ~AbstractHdfProxy() = default;
47
53 DLL_IMPORT_OR_EXPORT void setRootPath(const std::string& rootPath) { packageDirectoryAbsolutePath = rootPath; }
54
61 DLL_IMPORT_OR_EXPORT void setRelativePath(const std::string& relPath) { relativeFilePath = relPath; }
62
68 DLL_IMPORT_OR_EXPORT void setOpeningMode(COMMON_NS::DataObjectRepository::openingMode openingMode_) { openingMode = openingMode_; }
69
76 DLL_IMPORT_OR_EXPORT const std::string& getRelativePath() const { return relativeFilePath; }
77
82 virtual void open() = 0;
83
89 DLL_IMPORT_OR_EXPORT virtual bool isOpened() const = 0;
90
92 DLL_IMPORT_OR_EXPORT virtual void close() = 0;
93
101 DLL_IMPORT_OR_EXPORT virtual COMMON_NS::AbstractObject::numericalDatatypeEnum getNumericalDatatype(const std::string & datasetName) = 0;
102
110 DLL_IMPORT_OR_EXPORT virtual int getHdfDatatypeClassInDataset(const std::string & datasetName) = 0;
111
131 DLL_IMPORT_OR_EXPORT virtual void writeItemizedListOfList(const std::string & groupName,
132 const std::string & name,
133 COMMON_NS::AbstractObject::numericalDatatypeEnum cumulativeLengthDatatype,
134 const void * cumulativeLength,
135 uint64_t cumulativeLengthSize,
136 COMMON_NS::AbstractObject::numericalDatatypeEnum elementsDatatype,
137 const void * elements,
138 uint64_t elementsSize) = 0;
139
149 DLL_IMPORT_OR_EXPORT uint64_t getDimensionCount(const std::string & datasetName) { return getElementCountPerDimension(datasetName).size(); }
150
156 DLL_IMPORT_OR_EXPORT virtual std::vector<uint32_t> getElementCountPerDimension(const std::string & datasetName) = 0;
157
167 DLL_IMPORT_OR_EXPORT uint64_t getElementCount(const std::string & datasetName);
168
175 DLL_IMPORT_OR_EXPORT virtual void setCompressionLevel(unsigned int newCompressionLevel) = 0;
176
191 DLL_IMPORT_OR_EXPORT void writeArrayNdOfFloatValues(const std::string & groupName,
192 const std::string & name,
193 const float * values,
194 const uint64_t * numValuesInEachDimension,
195 unsigned int numDimensions) {
196 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::FLOAT, values, numValuesInEachDimension, numDimensions);
197 }
198
213 DLL_IMPORT_OR_EXPORT void writeArrayNdOfDoubleValues(const std::string & groupName,
214 const std::string & name,
215 const double * values,
216 const uint64_t * numValuesInEachDimension,
217 unsigned int numDimensions) {
218 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::DOUBLE, values, numValuesInEachDimension, numDimensions);
219 }
220
235 DLL_IMPORT_OR_EXPORT void writeArrayNdOfInt8Values(const std::string & groupName,
236 const std::string & name,
237 const int8_t * values,
238 const uint64_t * numValuesInEachDimension,
239 unsigned int numDimensions) {
240 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::INT8, values, numValuesInEachDimension, numDimensions);
241 }
242
257 DLL_IMPORT_OR_EXPORT void writeArrayNdOfIntValues(const std::string & groupName,
258 const std::string & name,
259 const int * values,
260 const uint64_t * numValuesInEachDimension,
261 unsigned int numDimensions) {
262 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::INT32, values, numValuesInEachDimension, numDimensions);
263 }
264
280 DLL_IMPORT_OR_EXPORT void writeArrayNdOfInt64Values(const std::string & groupName,
281 const std::string & name,
282 const int64_t * values,
283 const uint64_t * numValuesInEachDimension,
284 unsigned int numDimensions) {
285 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::INT64, values, numValuesInEachDimension, numDimensions);
286 }
287
303 DLL_IMPORT_OR_EXPORT void writeArrayNdOfUInt64Values(const std::string & groupName,
304 const std::string & name,
305 const uint64_t * values,
306 const uint64_t * numValuesInEachDimension,
307 unsigned int numDimensions) {
308 writeArrayNd(groupName, name, COMMON_NS::AbstractObject::numericalDatatypeEnum::UINT64, values, numValuesInEachDimension, numDimensions);
309 }
310
326 DLL_IMPORT_OR_EXPORT virtual void writeArrayNd(const std::string & groupName,
327 const std::string & name,
328 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
329 const void * values,
330 const uint64_t * numValuesInEachDimension,
331 unsigned int numDimensions) = 0;
332
347 DLL_IMPORT_OR_EXPORT virtual void createArrayNd(
348 const std::string& groupName,
349 const std::string& name,
350 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
351 const uint64_t* numValuesInEachDimension,
352 unsigned int numDimensions
353 ) = 0;
354
370 DLL_IMPORT_OR_EXPORT virtual void writeArrayNdSlab(
371 const std::string& groupName,
372 const std::string& name,
373 COMMON_NS::AbstractObject::numericalDatatypeEnum datatype,
374 const void* values,
375 const uint64_t* numValuesInEachDimension,
376 const uint64_t* offsetValuesInEachDimension,
377 unsigned int numDimensions
378 ) = 0;
379
390 DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
391 const std::vector<std::string> & attributeNames,
392 const std::vector<std::string> & values) = 0;
393
401 DLL_IMPORT_OR_EXPORT virtual void writeGroupAttribute(const std::string & groupName,
402 const std::string & attributeName,
403 const std::vector<std::string> & values) = 0;
404
415 DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
416 const std::vector<std::string> & attributeNames,
417 const std::vector<double> & values) = 0;
418
429 DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
430 const std::vector<std::string> & attributeNames,
431 const std::vector<int> & values) = 0;
432
443 DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
444 const std::vector<std::string> & attributeNames,
445 const std::vector<std::string> & values) = 0;
446
454 DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttribute(const std::string & datasetName,
455 const std::string & attributeName,
456 const std::vector<std::string> & values) = 0;
457
468 DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
469 const std::vector<std::string> & attributeNames,
470 const std::vector<double> & values) = 0;
471
482 DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
483 const std::vector<std::string> & attributeNames,
484 const std::vector<int> & values) = 0;
485
498 DLL_IMPORT_OR_EXPORT virtual std::string readStringAttribute(const std::string & obj_name,
499 const std::string & attr_name) const = 0;
500
513 DLL_IMPORT_OR_EXPORT virtual std::vector<std::string> readStringArrayAttribute(const std::string & obj_name,
514 const std::string & attr_name) const = 0;
515
528 DLL_IMPORT_OR_EXPORT virtual double readDoubleAttribute(const std::string & obj_name,
529 const std::string & attr_name) const = 0;
530
543 DLL_IMPORT_OR_EXPORT virtual int64_t readInt64Attribute(const std::string & obj_name,
544 const std::string & attr_name) const = 0;
545
555 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(const std::string & datasetName, double* values) = 0;
556
575 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
576 const std::string & datasetName,
577 double* values,
578 uint64_t const * numValuesInEachDimension,
579 uint64_t const * offsetInEachDimension,
580 unsigned int numDimensions
581 ) = 0;
582
606 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
607 const std::string & datasetName,
608 double* values,
609 uint64_t const * blockCountPerDimension,
610 uint64_t const * offsetInEachDimension,
611 uint64_t const * strideInEachDimension,
612 uint64_t const * blockSizeInEachDimension,
613 unsigned int numDimensions) = 0;
614
645 DLL_IMPORT_OR_EXPORT virtual void selectArrayNdOfValues(
646 const std::string & datasetName,
647 uint64_t const* blockCountPerDimension,
648 uint64_t const* offsetInEachDimension,
649 uint64_t const* strideInEachDimension,
650 uint64_t const* blockSizeInEachDimension,
651 unsigned int numDimensions,
652 bool newSelection,
653 hdf5_hid_t & dataset,
654 hdf5_hid_t & filespace) = 0;
655
668 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
669 hdf5_hid_t dataset,
670 hdf5_hid_t filespace,
671 void* values,
672 uint64_t slabSize) = 0;
673
683 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfFloatValues(const std::string & datasetName, float* values) = 0;
684
703 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfFloatValues(
704 const std::string & datasetName,
705 float* values,
706 uint64_t const * numValuesInEachDimension,
707 uint64_t const * offsetInEachDimension,
708 unsigned int numDimensions
709 ) = 0;
710
720 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfInt64Values(const std::string & datasetName, int64_t* values) = 0;
721
740 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfInt64Values(
741 const std::string & datasetName,
742 int64_t* values,
743 uint64_t const * numValuesInEachDimension,
744 uint64_t const * offsetInEachDimension,
745 unsigned int numDimensions) = 0;
746
757 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUInt64Values(const std::string & datasetName, uint64_t* values) = 0;
758
768 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfIntValues(const std::string & datasetName, int* values) = 0;
769
788 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfIntValues(
789 const std::string & datasetName,
790 int* values,
791 uint64_t const * numValuesInEachDimension,
792 uint64_t const * offsetInEachDimension,
793 unsigned int numDimensions
794 ) = 0;
795
805 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUIntValues(const std::string & datasetName, unsigned int* values) = 0;
806
816 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfShortValues(const std::string & datasetName, short* values) = 0;
817
828 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUShortValues(const std::string & datasetName, unsigned short* values) = 0;
829
839 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfInt8Values(const std::string & datasetName, int8_t* values) = 0;
840
851 DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUInt8Values(const std::string & datasetName, uint8_t* values) = 0;
852
860 DLL_IMPORT_OR_EXPORT virtual bool exist(const std::string & absolutePathInHdfFile) const = 0;
861
871 DLL_IMPORT_OR_EXPORT virtual bool isCompressed(const std::string & datasetName) = 0;
872
885 DLL_IMPORT_OR_EXPORT void setMaxChunkSize(unsigned int newMaxChunkSize) { maxChunkSize = newMaxChunkSize; }
886
893 DLL_IMPORT_OR_EXPORT virtual std::vector<uint32_t> getElementCountPerChunkDimension(const std::string & datasetName) = 0;
894
905 DLL_IMPORT_OR_EXPORT void initGsoapProxy(COMMON_NS::DataObjectRepository* repo, const std::string& guid, const std::string& title, unsigned int emlVersion);
906
907 static constexpr char const* MIME_TYPE = "application/x-hdf5";
908
909 protected:
910
916 AbstractHdfProxy(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : EpcExternalPartReference(partialObject) {}
917 AbstractHdfProxy(const COMMON_NS::DataObjectReference& dor) : EpcExternalPartReference(dor) {}
918
927 DLL_IMPORT_OR_EXPORT AbstractHdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath, COMMON_NS::DataObjectRepository::openingMode hdfPermissionAccess = COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) :
928 packageDirectoryAbsolutePath(packageDirAbsolutePath), relativeFilePath(externalFilePath), openingMode(hdfPermissionAccess) {}
929
935 AbstractHdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap) :
936 EpcExternalPartReference(fromGsoap) {}
937
939 std::string packageDirectoryAbsolutePath;
941 std::string relativeFilePath;
943 COMMON_NS::DataObjectRepository::openingMode openingMode = COMMON_NS::DataObjectRepository::openingMode::READ_ONLY;
947 unsigned int maxChunkSize = 1000000;
948 };
949}
An abstract proxy for reading and writing values into an HDF5 file. It is possible to derive this cla...
Definition AbstractHdfProxy.h:37
virtual void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< std::string > &values)=0
virtual void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< double > &values)=0
virtual bool isOpened() const =0
virtual void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions)=0
virtual void readArrayNdOfIntValues(const std::string &datasetName, int *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions)=0
virtual void writeItemizedListOfList(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum cumulativeLengthDatatype, const void *cumulativeLength, uint64_t cumulativeLengthSize, common::AbstractObject::numericalDatatypeEnum elementsDatatype, const void *elements, uint64_t elementsSize)=0
virtual int64_t readInt64Attribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual double readDoubleAttribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual 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)=0
virtual std::vector< uint32_t > getElementCountPerDimension(const std::string &datasetName)=0
virtual void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values)=0
virtual void close()=0
uint64_t getDimensionCount(const std::string &datasetName)
Definition AbstractHdfProxy.h:149
virtual common::AbstractObject::numericalDatatypeEnum getNumericalDatatype(const std::string &datasetName)=0
virtual 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)=0
virtual void readArrayNdOfUShortValues(const std::string &datasetName, unsigned short *values)=0
virtual void readArrayNdOfFloatValues(const std::string &datasetName, float *values)=0
virtual void readArrayNdOfDoubleValues(const std::string &datasetName, double *values)=0
virtual void readArrayNdOfUInt64Values(const std::string &datasetName, uint64_t *values)=0
void writeArrayNdOfInt8Values(const std::string &groupName, const std::string &name, const int8_t *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:235
virtual void writeGroupAttribute(const std::string &groupName, const std::string &attributeName, const std::vector< std::string > &values)=0
virtual void readArrayNdOfIntValues(const std::string &datasetName, int *values)=0
virtual std::vector< std::string > readStringArrayAttribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual 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)=0
virtual void writeDatasetAttribute(const std::string &datasetName, const std::string &attributeName, const std::vector< std::string > &values)=0
virtual void readArrayNdOfUInt8Values(const std::string &datasetName, uint8_t *values)=0
virtual void readArrayNdOfShortValues(const std::string &datasetName, short *values)=0
virtual ~AbstractHdfProxy()=default
virtual void readArrayNdOfDoubleValues(hdf5_hid_t dataset, hdf5_hid_t filespace, void *values, uint64_t slabSize)=0
virtual std::vector< uint32_t > getElementCountPerChunkDimension(const std::string &datasetName)=0
virtual void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< int > &values)=0
virtual bool exist(const std::string &absolutePathInHdfFile) const =0
void writeArrayNdOfInt64Values(const std::string &groupName, const std::string &name, const int64_t *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:280
virtual int getHdfDatatypeClassInDataset(const std::string &datasetName)=0
virtual void readArrayNdOfFloatValues(const std::string &datasetName, float *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions)=0
virtual void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< double > &values)=0
virtual bool isCompressed(const std::string &datasetName)=0
virtual void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, uint64_t const *numValuesInEachDimension, uint64_t const *offsetInEachDimension, unsigned int numDimensions)=0
void writeArrayNdOfUInt64Values(const std::string &groupName, const std::string &name, const uint64_t *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:303
virtual void setCompressionLevel(unsigned int newCompressionLevel)=0
void setOpeningMode(common::DataObjectRepository::openingMode openingMode_)
Definition AbstractHdfProxy.h:68
virtual void createArrayNd(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum datatype, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)=0
virtual void open()=0
void writeArrayNdOfFloatValues(const std::string &groupName, const std::string &name, const float *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:191
uint64_t getElementCount(const std::string &datasetName)
virtual void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< int > &values)=0
void writeArrayNdOfDoubleValues(const std::string &groupName, const std::string &name, const double *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:213
virtual void writeArrayNd(const std::string &groupName, const std::string &name, common::AbstractObject::numericalDatatypeEnum datatype, const void *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)=0
const std::string & getRelativePath() const
Definition AbstractHdfProxy.h:76
void setRelativePath(const std::string &relPath)
Definition AbstractHdfProxy.h:61
virtual void readArrayNdOfInt8Values(const std::string &datasetName, int8_t *values)=0
void writeArrayNdOfIntValues(const std::string &groupName, const std::string &name, const int *values, const uint64_t *numValuesInEachDimension, unsigned int numDimensions)
Definition AbstractHdfProxy.h:257
virtual void readArrayNdOfUIntValues(const std::string &datasetName, unsigned int *values)=0
virtual std::string readStringAttribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< std::string > &values)=0
void setRootPath(const std::string &rootPath)
Definition AbstractHdfProxy.h:53
void setMaxChunkSize(unsigned int newMaxChunkSize)
Definition AbstractHdfProxy.h:885
void initGsoapProxy(common::DataObjectRepository *repo, const std::string &guid, const std::string &title, unsigned int emlVersion)
Proxy class for handling external parts of an EPC package. It must be used at least for external HDF5...
Definition EpcExternalPartReference.h:30