Fesapi  0.13.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
HdfProxy.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 "common/AbstractHdfProxy.h"
22 
23 namespace COMMON_NS
24 {
25  class DLL_IMPORT_OR_EXPORT HdfProxy : public AbstractHdfProxy
26  {
27  protected:
28 
29  HdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
30  COMMON_NS::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
31 
32  HdfProxy(gsoap_eml2_1::_eml21__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
33  COMMON_NS::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
34 
40  HdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath);
41 
49  void readArrayNdOfValues(const std::string & datasetName, void* values, const int & datatype);
50 
61  void readArrayNdOfValues(
62  const std::string & datasetName,
63  void* values,
64  unsigned long long * numValuesInEachDimension,
65  unsigned long long * offsetInEachDimension,
66  const unsigned int & numDimensions,
67  const int & datatype);
68 
81  void readArrayNdOfValues(
82  const std::string & datasetName,
83  void* values,
84  unsigned long long * blockCountPerDimension,
85  unsigned long long * offsetInEachDimension,
86  unsigned long long * strideInEachDimension,
87  unsigned long long * blockSizeInEachDimension,
88  const unsigned int & numDimensions,
89  const int & datatype);
90 
104  void selectArrayNdOfValues(
105  const std::string & datasetName,
106  unsigned long long * blockCountPerDimension,
107  unsigned long long * offsetInEachDimension,
108  unsigned long long * strideInEachDimension,
109  unsigned long long * blockSizeInEachDimension,
110  const unsigned int & numDimensions,
111  bool newSelection,
112  int & dataset,
113  int & filespace);
114 
124  void readArrayNdOfValues(
125  int dataset,
126  int filespace,
127  void* values,
128  unsigned long long slabSize,
129  const int & datatype);
130 
131  public:
132 
137  ~HdfProxy() {close();}
138 
143  void open();
144 
148  bool isOpened() const {return hdfFile != -1;}
149 
153  void close();
154 
155  /*
156  * Get the used (native) datatype in a dataset
157  * To compare with H5T_NATIVE_INT, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT, etc...
158  */
159  int getHdfDatatypeInDataset(const std::string & groupName) const;
160 
165  int getHdfDatatypeClassInDataset(const std::string & datasetName) const;
166 
179  void writeItemizedListOfList(const std::string & groupName,
180  const std::string & name,
181  const int & cumulativeLengthDatatype,
182  void * cumulativeLength,
183  const unsigned long long & cumulativeLengthSize,
184  const int & elementsDatatype,
185  void * elements,
186  const unsigned long long & elementsSize);
187 
192  unsigned int getDimensionCount(const std::string & datasetName);
193 
198  signed long long getElementCount(const std::string & datasetName);
199 
204  void setCompressionLevel(const unsigned int & newCompressionLevel) {if (newCompressionLevel > 9) compressionLevel = 9; else compressionLevel = newCompressionLevel;}
205 
206  void writeArrayNdOfFloatValues(const std::string & groupName,
207  const std::string & name,
208  float * floatValues,
209  unsigned long long * numValuesInEachDimension,
210  const unsigned int & numDimensions);
211 
221  void writeArrayNdOfDoubleValues(const std::string & groupName,
222  const std::string & name,
223  double * dblValues,
224  unsigned long long * numValuesInEachDimension,
225  const unsigned int & numDimensions);
226 
236  void writeArrayNdOfCharValues(const std::string & groupName,
237  const std::string & name,
238  char * intValues,
239  unsigned long long * numValuesInEachDimension,
240  const unsigned int & numDimensions);
241 
251  void writeArrayNdOfIntValues(const std::string & groupName,
252  const std::string & name,
253  int * intValues,
254  unsigned long long * numValuesInEachDimension,
255  const unsigned int & numDimensions);
256 
266  void writeArrayNdOfGSoapULong64Values(const std::string & groupName,
267  const std::string & name,
268  ULONG64 * ulong64Values,
269  unsigned long long * numValuesInEachDimension,
270  const unsigned int & numDimensions);
271 
282  void writeArrayNd(const std::string & groupName,
283  const std::string & name,
284  const int & datatype,
285  void * values,
286  unsigned long long * numValuesInEachDimension,
287  const unsigned int & numDimensions);
288 
298  void createArrayNd(
299  const std::string& groupName,
300  const std::string& name,
301  const int & datatype,
302  unsigned long long* numValuesInEachDimension,
303  const unsigned int& numDimensions
304  );
305 
316  void writeArrayNdSlab(
317  const std::string& groupName,
318  const std::string& name,
319  const int & datatype,
320  void* values,
321  unsigned long long* numValuesInEachDimension,
322  unsigned long long* offsetValuesInEachDimension,
323  const unsigned int& numDimensions
324  );
325 
329  void writeGroupAttributes(const std::string & groupName,
330  const std::vector<std::string> & attributeNames,
331  const std::vector<std::string> & values);
332 
336  void writeGroupAttribute(const std::string & groupName,
337  const std::string & attributeName,
338  const std::vector<std::string> & values);
339 
343  void writeGroupAttributes(const std::string & groupName,
344  const std::vector<std::string> & attributeNames,
345  const std::vector<double> & values);
346 
350  void writeGroupAttributes(const std::string & groupName,
351  const std::vector<std::string> & attributeNames,
352  const std::vector<int> & values);
353 
357  void writeDatasetAttributes(const std::string & datasetName,
358  const std::vector<std::string> & attributeNames,
359  const std::vector<std::string> & values);
360 
364  void writeDatasetAttribute(const std::string & datasetName,
365  const std::string & attributeName,
366  const std::vector<std::string> & values);
367 
371  void writeDatasetAttributes(const std::string & datasetName,
372  const std::vector<std::string> & attributeNames,
373  const std::vector<double> & values);
374 
378  void writeDatasetAttributes(const std::string & datasetName,
379  const std::vector<std::string> & attributeNames,
380  const std::vector<int> & values);
381 
382  std::string readStringAttribute(const std::string & obj_name,
383  const std::string & attr_name) const;
384 
385  std::vector<std::string> readStringArrayAttribute(const std::string & obj_name,
386  const std::string & attr_name) const;
387 
388  double readDoubleAttribute(const std::string & obj_name,
389  const std::string & attr_name) const;
390 
391  LONG64 readLongAttribute(const std::string & obj_name,
392  const std::string & attr_name) const;
393 
399  void readArrayNdOfDoubleValues(const std::string & datasetName, double* values);
400 
409  void readArrayNdOfDoubleValues(
410  const std::string & datasetName,
411  double* values,
412  unsigned long long * numValuesInEachDimension,
413  unsigned long long * offsetInEachDimension,
414  const unsigned int & numDimensions
415  );
416 
427  void readArrayNdOfDoubleValues(
428  const std::string & datasetName, double* values,
429  unsigned long long * blockCountPerDimension,
430  unsigned long long * offsetInEachDimension,
431  unsigned long long * strideInEachDimension,
432  unsigned long long * blockSizeInEachDimension,
433  const unsigned int & numDimensions);
434 
442  void readArrayNdOfDoubleValues(
443  int dataset,
444  int filespace,
445  void* values,
446  unsigned long long slabSize);
447 
453  void readArrayNdOfFloatValues(const std::string & datasetName, float* values);
454 
463  void readArrayNdOfFloatValues(
464  const std::string & datasetName,
465  float* values,
466  unsigned long long * numValuesInEachDimension,
467  unsigned long long * offsetInEachDimension,
468  const unsigned int & numDimensions
469  );
470 
474  void readArrayNdOfGSoapLong64Values(const std::string & datasetName, LONG64* values);
475 
479  void readArrayNdOfGSoapULong64Values(const std::string & datasetName, ULONG64* values);
480 
486  void readArrayNdOfLongValues(const std::string & datasetName, long* values);
487 
496  void readArrayNdOfLongValues(
497  const std::string & datasetName,
498  long* values,
499  unsigned long long * numValuesInEachDimension,
500  unsigned long long * offsetInEachDimension,
501  const unsigned int & numDimensions
502  );
503 
509  void readArrayNdOfULongValues(const std::string & datasetName, unsigned long* values);
510 
516  void readArrayNdOfIntValues(const std::string & datasetName, int* values);
517 
526  void readArrayNdOfIntValues(
527  const std::string & datasetName,
528  int* values,
529  unsigned long long * numValuesInEachDimension,
530  unsigned long long * offsetInEachDimension,
531  const unsigned int & numDimensions
532  );
533 
539  void readArrayNdOfUIntValues(const std::string & datasetName, unsigned int* values);
540 
547  void readArrayNdOfShortValues(const std::string & datasetName, short* values);
548 
554  void readArrayNdOfUShortValues(const std::string & datasetName, unsigned short* values);
555 
561  void readArrayNdOfCharValues(const std::string & datasetName, char* values);
562 
567  void readArrayNdOfUCharValues(const std::string & datasetName, unsigned char* values);
568 
573  std::vector<unsigned long long> readArrayDimensions(const std::string & datasetName);
574 
578  bool exist(const std::string & absolutePathInHdfFile) const;
579 
580  protected:
581 
585  virtual int openOrCreateRootGroup();
586 
592  int openOrCreateGroupInRootGroup(const std::string & groupName);
593 
594  int hdfFile;
595 
596  unsigned int compressionLevel;
597  };
598 }
599 
bool isOpened() const
Definition: HdfProxy.h:148
void setCompressionLevel(const unsigned int &newCompressionLevel)
Definition: HdfProxy.h:204
~HdfProxy()
Definition: HdfProxy.h:137
Definition: HdfProxy.h:25
Definition: AbstractHdfProxy.h:30
Definition: AbstractHdfProxy.h:28