My Project
HdfProxy.h
1 /*-----------------------------------------------------------------------
2 Copyright F2I-CONSULTING, (2014-2016)
3 
4 philippe.verney@f2i-consulting.com
5 
6 This software is a computer program whose purpose is to access to data formatted using Energistics standards.
7 
8 This software is governed by the CeCILL-B license under French law and
9 abiding by the rules of distribution of free software. You can use,
10 modify and/ or redistribute the software under the terms of the CeCILL-B
11 license as circulated by CEA, CNRS and INRIA at the following URL
12 "http://www.cecill.info".
13 
14 As a counterpart to the access to the source code and rights to copy,
15 modify and redistribute granted by the license, users are provided only
16 with a limited warranty and the software's author, the holder of the
17 economic rights, and the successive licensors have only limited
18 liability.
19 
20 In this respect, the user's attention is drawn to the risks associated
21 with loading, using, modifying and/or developing or reproducing the
22 software by the user in light of its specific status of free software,
23 that may mean that it is complicated to manipulate, and that also
24 therefore means that it is reserved for developers and experienced
25 professionals having in-depth computer knowledge. Users are therefore
26 encouraged to load and test the software's suitability as regards their
27 requirements in conditions enabling the security of their systems and/or
28 data to be ensured and, more generally, to use and operate it in the
29 same conditions as regards security.
30 
31 The fact that you are presently reading this means that you have had
32 knowledge of the CeCILL-B license and that you accept its terms.
33 -----------------------------------------------------------------------*/
34 #pragma once
35 
36 #include "resqml2/AbstractHdfProxy.h"
37 
38 namespace resqml2
39 {
40  class DLL_IMPORT_OR_EXPORT HdfProxy : public AbstractHdfProxy
41  {
42  protected:
48  HdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath);
49 
57  void readArrayNdOfValues(const std::string & datasetName, void* values, const int & datatype);
58 
69  void readArrayNdOfValues(
70  const std::string & datasetName,
71  void* values,
72  unsigned long long * numValuesInEachDimension,
73  unsigned long long * offsetInEachDimension,
74  const unsigned int & numDimensions,
75  const int & datatype);
76 
77  public:
78 
79  HdfProxy(gsoap_resqml2_0_1::_eml__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
80  resqml2::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
81 
82 #ifdef WITH_RESQML2_1
83  HdfProxy(gsoap_resqml2_1::_eml__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
84  resqml2::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
85 #endif
86 
91  ~HdfProxy() {close();}
92 
97  void open();
98 
102  bool isOpened() {return hdfFile != -1;}
103 
107  void close();
108 
109  /*
110  * Get the used (native) datatype in a dataset
111  * To compare with H5T_NATIVE_INT, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT, etc...
112  */
113  int getHdfDatatypeInDataset(const std::string & groupName);
114 
127  void writeItemizedListOfList(const std::string & groupName,
128  const std::string & name,
129  const int & cumulativeLengthDatatype,
130  void * cumulativeLength,
131  const unsigned long long & cumulativeLengthSize,
132  const int & elementsDatatype,
133  void * elements,
134  const unsigned long long & elementsSize);
135 
140  unsigned int getDimensionCount(const std::string & datasetName);
141 
146  signed long long getElementCount(const std::string & datasetName);
147 
152  void setCompressionLevel(const unsigned int & newCompressionLevel) {if (newCompressionLevel > 9) compressionLevel = 9; else compressionLevel = newCompressionLevel;}
153 
154  void writeArrayNdOfFloatValues(const std::string & groupName,
155  const std::string & name,
156  float * floatValues,
157  unsigned long long * numValuesInEachDimension,
158  const unsigned int & numDimensions);
159 
169  void writeArrayNdOfDoubleValues(const std::string & groupName,
170  const std::string & name,
171  double * dblValues,
172  unsigned long long * numValuesInEachDimension,
173  const unsigned int & numDimensions);
174 
184  void writeArrayNdOfCharValues(const std::string & groupName,
185  const std::string & name,
186  char * intValues,
187  unsigned long long * numValuesInEachDimension,
188  const unsigned int & numDimensions);
189 
199  void writeArrayNdOfIntValues(const std::string & groupName,
200  const std::string & name,
201  int * intValues,
202  unsigned long long * numValuesInEachDimension,
203  const unsigned int & numDimensions);
204 
214  void writeArrayNdOfGSoapULong64Values(const std::string & groupName,
215  const std::string & name,
216  ULONG64 * ulong64Values,
217  unsigned long long * numValuesInEachDimension,
218  const unsigned int & numDimensions);
219 
230  void writeArrayNd(const std::string & groupName,
231  const std::string & name,
232  const int & datatype,
233  void * values,
234  unsigned long long * numValuesInEachDimension,
235  const unsigned int & numDimensions);
236 
246  void createArrayNd(
247  const std::string& groupName,
248  const std::string& name,
249  const int & datatype,
250  unsigned long long* numValuesInEachDimension,
251  const unsigned int& numDimensions
252  );
253 
264  void writeArrayNdSlab(
265  const std::string& groupName,
266  const std::string& name,
267  const int & datatype,
268  void* values,
269  unsigned long long* numValuesInEachDimension,
270  unsigned long long* offsetValuesInEachDimension,
271  const unsigned int& numDimensions
272  );
273 
279  void readArrayNdOfDoubleValues(const std::string & datasetName, double* values);
280 
289  void readArrayNdOfDoubleValues(
290  const std::string & datasetName,
291  double* values,
292  unsigned long long * numValuesInEachDimension,
293  unsigned long long * offsetInEachDimension,
294  const unsigned int & numDimensions
295  );
296 
302  void readArrayNdOfFloatValues(const std::string & datasetName, float* values);
303 
312  void readArrayNdOfFloatValues(
313  const std::string & datasetName,
314  float* values,
315  unsigned long long * numValuesInEachDimension,
316  unsigned long long * offsetInEachDimension,
317  const unsigned int & numDimensions
318  );
319 
323  void readArrayNdOfGSoapLong64Values(const std::string & datasetName, LONG64* values);
324 
328  void readArrayNdOfGSoapULong64Values(const std::string & datasetName, ULONG64* values);
329 
335  void readArrayNdOfLongValues(const std::string & datasetName, long* values);
336 
345  void readArrayNdOfLongValues(
346  const std::string & datasetName,
347  long* values,
348  unsigned long long * numValuesInEachDimension,
349  unsigned long long * offsetInEachDimension,
350  const unsigned int & numDimensions
351  );
352 
358  void readArrayNdOfULongValues(const std::string & datasetName, unsigned long* values);
359 
365  void readArrayNdOfIntValues(const std::string & datasetName, int* values);
366 
372  void readArrayNdOfUIntValues(const std::string & datasetName, unsigned int* values);
373 
380  void readArrayNdOfShortValues(const std::string & datasetName, short* values);
381 
387  void readArrayNdOfUShortValues(const std::string & datasetName, unsigned short* values);
388 
394  void readArrayNdOfCharValues(const std::string & datasetName, char* values);
395 
400  void readArrayNdOfUCharValues(const std::string & datasetName, unsigned char* values);
401 
406  std::vector<unsigned long long> readArrayDimensions(const std::string & datasetName);
407 
408  private:
414  int openOrCreateHdfResqmlGroup();
415 
421  int openOrCreateGroupInResqmlGroup(const std::string & groupName);
422 
423  int hdfFile;
424 
425  unsigned int compressionLevel;
426  };
427 }
~HdfProxy()
Definition: HdfProxy.h:91
Definition: AbstractHdfProxy.h:44
Definition: HdfProxy.h:40
void setCompressionLevel(const unsigned int &newCompressionLevel)
Definition: HdfProxy.h:152
bool isOpened()
Definition: HdfProxy.h:102
Definition: EpcDocument.h:61