Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
AbstractHdfProxy.h
1 /*-----------------------------------------------------------------------
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"; you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -----------------------------------------------------------------------*/
19 #pragma once
20 
21 #include "EpcExternalPartReference.h"
22 #include "../common/HidtType.h"
23 
25 #define CUMULATIVE_LENGTH_DS_NAME "cumulativeLength"
27 #define ELEMENTS_DS_NAME "elements"
28 
29 namespace EML2_NS
30 {
42  {
43  public:
45  DLL_IMPORT_OR_EXPORT virtual ~AbstractHdfProxy() = default;
46 
52  DLL_IMPORT_OR_EXPORT void setRootPath(const std::string& rootPath) { packageDirectoryAbsolutePath = rootPath; }
53 
60  DLL_IMPORT_OR_EXPORT void setRelativePath(const std::string& relPath) { relativeFilePath = relPath; }
61 
67  DLL_IMPORT_OR_EXPORT void setOpeningMode(COMMON_NS::DataObjectRepository::openingMode openingMode_) { openingMode = openingMode_; }
68 
75  DLL_IMPORT_OR_EXPORT const std::string& getRelativePath() const { return relativeFilePath; }
76 
81  virtual void open() = 0;
82 
88  DLL_IMPORT_OR_EXPORT virtual bool isOpened() const = 0;
89 
91  DLL_IMPORT_OR_EXPORT virtual void close() = 0;
92 
101  DLL_IMPORT_OR_EXPORT virtual COMMON_NS::AbstractObject::hdfDatatypeEnum getHdfDatatypeInDataset(const std::string & datasetName) = 0;
102 
110  DLL_IMPORT_OR_EXPORT virtual int getHdfDatatypeClassInDataset(const std::string & datasetName) = 0;
111 
130  DLL_IMPORT_OR_EXPORT virtual void writeItemizedListOfList(const std::string & groupName,
131  const std::string & name,
132  hdf5_hid_t cumulativeLengthDatatype,
133  const void * cumulativeLength,
134  unsigned long long cumulativeLengthSize,
135  hdf5_hid_t elementsDatatype,
136  const void * elements,
137  unsigned long long elementsSize) = 0;
138 
148  DLL_IMPORT_OR_EXPORT virtual unsigned int getDimensionCount(const std::string & datasetName) = 0;
149 
154  DLL_IMPORT_OR_EXPORT virtual std::vector<unsigned long long> getElementCountPerDimension(const std::string & datasetName) = 0;
155 
166  DLL_IMPORT_OR_EXPORT virtual signed long long getElementCount(const std::string & datasetName) = 0;
167 
174  DLL_IMPORT_OR_EXPORT virtual void setCompressionLevel(unsigned int newCompressionLevel) = 0;
175 
190  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfFloatValues(const std::string & groupName,
191  const std::string & name,
192  const float * floatValues,
193  const unsigned long long * numValuesInEachDimension,
194  unsigned int numDimensions) = 0;
195 
210  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfDoubleValues(const std::string & groupName,
211  const std::string & name,
212  const double * dblValues,
213  const unsigned long long * numValuesInEachDimension,
214  unsigned int numDimensions) = 0;
215 
230  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfCharValues(const std::string & groupName,
231  const std::string & name,
232  const char * intValues,
233  const unsigned long long * numValuesInEachDimension,
234  unsigned int numDimensions) = 0;
235 
250  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfIntValues(const std::string & groupName,
251  const std::string & name,
252  const int * intValues,
253  const unsigned long long * numValuesInEachDimension,
254  unsigned int numDimensions) = 0;
255 
271  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfInt64Values(const std::string & groupName,
272  const std::string & name,
273  const int64_t * values,
274  const unsigned long long * numValuesInEachDimension,
275  unsigned int numDimensions) = 0;
276 
292  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdOfUInt64Values(const std::string & groupName,
293  const std::string & name,
294  const uint64_t * values,
295  const unsigned long long * numValuesInEachDimension,
296  unsigned int numDimensions) = 0;
297 
313  DLL_IMPORT_OR_EXPORT virtual void writeArrayNd(const std::string & groupName,
314  const std::string & name,
315  hdf5_hid_t datatype,
316  const void * values,
317  const unsigned long long * numValuesInEachDimension,
318  unsigned int numDimensions) = 0;
319 
334  DLL_IMPORT_OR_EXPORT virtual void createArrayNd(
335  const std::string& groupName,
336  const std::string& name,
337  hdf5_hid_t datatype,
338  const unsigned long long* numValuesInEachDimension,
339  unsigned int numDimensions
340  ) = 0;
341 
357  DLL_IMPORT_OR_EXPORT virtual void writeArrayNdSlab(
358  const std::string& groupName,
359  const std::string& name,
360  hdf5_hid_t datatype,
361  const void* values,
362  const unsigned long long* numValuesInEachDimension,
363  const unsigned long long* offsetValuesInEachDimension,
364  unsigned int numDimensions
365  ) = 0;
366 
377  DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
378  const std::vector<std::string> & attributeNames,
379  const std::vector<std::string> & values) = 0;
380 
388  DLL_IMPORT_OR_EXPORT virtual void writeGroupAttribute(const std::string & groupName,
389  const std::string & attributeName,
390  const std::vector<std::string> & values) = 0;
391 
402  DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
403  const std::vector<std::string> & attributeNames,
404  const std::vector<double> & values) = 0;
405 
416  DLL_IMPORT_OR_EXPORT virtual void writeGroupAttributes(const std::string & groupName,
417  const std::vector<std::string> & attributeNames,
418  const std::vector<int> & values) = 0;
419 
430  DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
431  const std::vector<std::string> & attributeNames,
432  const std::vector<std::string> & values) = 0;
433 
441  DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttribute(const std::string & datasetName,
442  const std::string & attributeName,
443  const std::vector<std::string> & values) = 0;
444 
455  DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
456  const std::vector<std::string> & attributeNames,
457  const std::vector<double> & values) = 0;
458 
469  DLL_IMPORT_OR_EXPORT virtual void writeDatasetAttributes(const std::string & datasetName,
470  const std::vector<std::string> & attributeNames,
471  const std::vector<int> & values) = 0;
472 
485  DLL_IMPORT_OR_EXPORT virtual std::string readStringAttribute(const std::string & obj_name,
486  const std::string & attr_name) const = 0;
487 
500  DLL_IMPORT_OR_EXPORT virtual std::vector<std::string> readStringArrayAttribute(const std::string & obj_name,
501  const std::string & attr_name) const = 0;
502 
515  DLL_IMPORT_OR_EXPORT virtual double readDoubleAttribute(const std::string & obj_name,
516  const std::string & attr_name) const = 0;
517 
530  DLL_IMPORT_OR_EXPORT virtual int64_t readLongAttribute(const std::string & obj_name,
531  const std::string & attr_name) const = 0;
532 
542  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(const std::string & datasetName, double* values) = 0;
543 
562  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
563  const std::string & datasetName,
564  double* values,
565  unsigned long long const * numValuesInEachDimension,
566  unsigned long long const * offsetInEachDimension,
567  unsigned int numDimensions
568  ) = 0;
569 
593  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
594  const std::string & datasetName,
595  double* values,
596  unsigned long long const * blockCountPerDimension,
597  unsigned long long const * offsetInEachDimension,
598  unsigned long long const * strideInEachDimension,
599  unsigned long long const * blockSizeInEachDimension,
600  unsigned int numDimensions) = 0;
601 
632  DLL_IMPORT_OR_EXPORT virtual void selectArrayNdOfValues(
633  const std::string & datasetName,
634  unsigned long long const* blockCountPerDimension,
635  unsigned long long const* offsetInEachDimension,
636  unsigned long long const* strideInEachDimension,
637  unsigned long long const* blockSizeInEachDimension,
638  unsigned int numDimensions,
639  bool newSelection,
640  hdf5_hid_t & dataset,
641  hdf5_hid_t & filespace) = 0;
642 
655  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfDoubleValues(
656  hdf5_hid_t dataset,
657  hdf5_hid_t filespace,
658  void* values,
659  unsigned long long slabSize) = 0;
660 
670  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfFloatValues(const std::string & datasetName, float* values) = 0;
671 
690  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfFloatValues(
691  const std::string & datasetName,
692  float* values,
693  unsigned long long const * numValuesInEachDimension,
694  unsigned long long const * offsetInEachDimension,
695  unsigned int numDimensions
696  ) = 0;
697 
707  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfInt64Values(const std::string & datasetName, int64_t* values) = 0;
708 
727  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfInt64Values(
728  const std::string & datasetName,
729  int64_t* values,
730  unsigned long long const * numValuesInEachDimension,
731  unsigned long long const * offsetInEachDimension,
732  unsigned int numDimensions) = 0;
733 
744  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUInt64Values(const std::string & datasetName, uint64_t* values) = 0;
745 
755  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfIntValues(const std::string & datasetName, int* values) = 0;
756 
775  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfIntValues(
776  const std::string & datasetName,
777  int* values,
778  unsigned long long const * numValuesInEachDimension,
779  unsigned long long const * offsetInEachDimension,
780  unsigned int numDimensions
781  ) = 0;
782 
792  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUIntValues(const std::string & datasetName, unsigned int* values) = 0;
793 
803  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfShortValues(const std::string & datasetName, short* values) = 0;
804 
815  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUShortValues(const std::string & datasetName, unsigned short* values) = 0;
816 
826  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfCharValues(const std::string & datasetName, char* values) = 0;
827 
838  DLL_IMPORT_OR_EXPORT virtual void readArrayNdOfUCharValues(const std::string & datasetName, unsigned char* values) = 0;
839 
847  DLL_IMPORT_OR_EXPORT virtual std::vector<unsigned long long> readArrayDimensions(const std::string & datasetName) = 0;
848 
856  DLL_IMPORT_OR_EXPORT virtual bool exist(const std::string & absolutePathInHdfFile) const = 0;
857 
867  DLL_IMPORT_OR_EXPORT virtual bool isCompressed(const std::string & datasetName) = 0;
868 
879  DLL_IMPORT_OR_EXPORT void initGsoapProxy(COMMON_NS::DataObjectRepository* repo, const std::string& guid, const std::string& title, unsigned int emlVersion);
880 
881  protected:
882 
888  AbstractHdfProxy(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : EpcExternalPartReference(partialObject), openingMode(COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) {}
889  AbstractHdfProxy(const COMMON_NS::DataObjectReference& dor) : EpcExternalPartReference(dor), openingMode(COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) {}
890 
892  std::string packageDirectoryAbsolutePath;
894  std::string relativeFilePath;
896  COMMON_NS::DataObjectRepository::openingMode openingMode;
897 
908  DLL_IMPORT_OR_EXPORT AbstractHdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath, COMMON_NS::DataObjectRepository::openingMode hdfPermissionAccess = COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) :
909  packageDirectoryAbsolutePath(packageDirAbsolutePath), relativeFilePath(externalFilePath), openingMode(hdfPermissionAccess) {}
910 
911  AbstractHdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap) :
912  EpcExternalPartReference(fromGsoap), openingMode(COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) {}
913 
914  AbstractHdfProxy(gsoap_eml2_1::_eml21__EpcExternalPartReference* fromGsoap) :
915  EpcExternalPartReference(fromGsoap), openingMode(COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) {}
916 
917  AbstractHdfProxy(gsoap_eml2_3::_eml23__EpcExternalPartReference* fromGsoap) :
918  EpcExternalPartReference(fromGsoap), openingMode(COMMON_NS::DataObjectRepository::openingMode::READ_ONLY) {}
919  };
920 }
An abstract proxy for reading and writing values into an HDF5 file. It is possible to derive this cla...
Definition: AbstractHdfProxy.h:42
virtual signed long long getElementCount(const std::string &datasetName)=0
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 readArrayNdOfDoubleValues(hdf5_hid_t dataset, hdf5_hid_t filespace, void *values, unsigned long long slabSize)=0
virtual std::vector< unsigned long long > getElementCountPerDimension(const std::string &datasetName)=0
virtual void writeArrayNdOfInt64Values(const std::string &groupName, const std::string &name, const int64_t *values, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
virtual double readDoubleAttribute(const std::string &obj_name, const std::string &attr_name) const =0
const std::string & getRelativePath() const
Definition: AbstractHdfProxy.h:75
virtual 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)=0
virtual void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values)=0
virtual void close()=0
virtual void writeArrayNdOfFloatValues(const std::string &groupName, const std::string &name, const float *floatValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
virtual void writeArrayNdOfCharValues(const std::string &groupName, const std::string &name, const char *intValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
virtual common::AbstractObject::hdfDatatypeEnum getHdfDatatypeInDataset(const std::string &datasetName)=0
virtual void readArrayNdOfUShortValues(const std::string &datasetName, unsigned short *values)=0
virtual void readArrayNdOfDoubleValues(const std::string &datasetName, double *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions)=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
virtual void createArrayNd(const std::string &groupName, const std::string &name, hdf5_hid_t datatype, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
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 void writeDatasetAttribute(const std::string &datasetName, const std::string &attributeName, const std::vector< std::string > &values)=0
virtual void readArrayNdOfShortValues(const std::string &datasetName, short *values)=0
virtual ~AbstractHdfProxy()=default
virtual void writeGroupAttributes(const std::string &groupName, const std::vector< std::string > &attributeNames, const std::vector< int > &values)=0
virtual void readArrayNdOfInt64Values(const std::string &datasetName, int64_t *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions)=0
virtual bool exist(const std::string &absolutePathInHdfFile) const =0
virtual int getHdfDatatypeClassInDataset(const std::string &datasetName)=0
virtual void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< double > &values)=0
virtual 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)=0
virtual unsigned int getDimensionCount(const std::string &datasetName)=0
virtual bool isCompressed(const std::string &datasetName)=0
virtual void writeArrayNdOfDoubleValues(const std::string &groupName, const std::string &name, const double *dblValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
virtual 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)=0
virtual void readArrayNdOfFloatValues(const std::string &datasetName, float *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions)=0
virtual void setCompressionLevel(unsigned int newCompressionLevel)=0
void setOpeningMode(common::DataObjectRepository::openingMode openingMode_)
Definition: AbstractHdfProxy.h:67
virtual 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)=0
virtual void open()=0
virtual void readArrayNdOfIntValues(const std::string &datasetName, int *values, unsigned long long const *numValuesInEachDimension, unsigned long long const *offsetInEachDimension, unsigned int numDimensions)=0
virtual void writeDatasetAttributes(const std::string &datasetName, const std::vector< std::string > &attributeNames, const std::vector< int > &values)=0
virtual void writeArrayNdOfUInt64Values(const std::string &groupName, const std::string &name, const uint64_t *values, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
virtual void readArrayNdOfCharValues(const std::string &datasetName, char *values)=0
virtual int64_t readLongAttribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual std::vector< unsigned long long > readArrayDimensions(const std::string &datasetName)=0
virtual void writeArrayNdOfIntValues(const std::string &groupName, const std::string &name, const int *intValues, const unsigned long long *numValuesInEachDimension, unsigned int numDimensions)=0
void setRelativePath(const std::string &relPath)
Definition: AbstractHdfProxy.h:60
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 std::vector< std::string > readStringArrayAttribute(const std::string &obj_name, const std::string &attr_name) const =0
virtual void readArrayNdOfUCharValues(const std::string &datasetName, unsigned char *values)=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:52
virtual void writeItemizedListOfList(const std::string &groupName, const std::string &name, hdf5_hid_t cumulativeLengthDatatype, const void *cumulativeLength, unsigned long long cumulativeLengthSize, hdf5_hid_t elementsDatatype, const void *elements, unsigned long long elementsSize)=0
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