My Project
HdfProxy.h
1 /*-----------------------------------------------------------------------
2 Copyright F2I-CONSULTING, (2014-2017)
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 "common/AbstractHdfProxy.h"
37 
38 namespace common
39 {
40  class DLL_IMPORT_OR_EXPORT HdfProxy : public AbstractHdfProxy
41  {
42  protected:
43 
44  HdfProxy(gsoap_resqml2_0_1::_eml20__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
45  common::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
46 
47  HdfProxy(gsoap_eml2_1::_eml21__EpcExternalPartReference* fromGsoap, const std::string & packageDirAbsolutePath, const std::string & externalFilePath) :
48  common::AbstractHdfProxy(fromGsoap, packageDirAbsolutePath, externalFilePath), hdfFile(-1), compressionLevel(0) {}
49 
55  HdfProxy(const std::string & packageDirAbsolutePath, const std::string & externalFilePath);
56 
64  void readArrayNdOfValues(const std::string & datasetName, void* values, const int & datatype);
65 
76  void readArrayNdOfValues(
77  const std::string & datasetName,
78  void* values,
79  unsigned long long * numValuesInEachDimension,
80  unsigned long long * offsetInEachDimension,
81  const unsigned int & numDimensions,
82  const int & datatype);
83 
84  public:
85 
90  ~HdfProxy() {close();}
91 
96  void open();
97 
101  bool isOpened() const {return hdfFile != -1;}
102 
106  void close();
107 
108  /*
109  * Get the used (native) datatype in a dataset
110  * To compare with H5T_NATIVE_INT, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT, etc...
111  */
112  int getHdfDatatypeInDataset(const std::string & groupName) const;
113 
118  int getHdfDatatypeClassInDataset(const std::string & datasetName) const;
119 
132  void writeItemizedListOfList(const std::string & groupName,
133  const std::string & name,
134  const int & cumulativeLengthDatatype,
135  void * cumulativeLength,
136  const unsigned long long & cumulativeLengthSize,
137  const int & elementsDatatype,
138  void * elements,
139  const unsigned long long & elementsSize);
140 
145  unsigned int getDimensionCount(const std::string & datasetName);
146 
151  signed long long getElementCount(const std::string & datasetName);
152 
157  void setCompressionLevel(const unsigned int & newCompressionLevel) {if (newCompressionLevel > 9) compressionLevel = 9; else compressionLevel = newCompressionLevel;}
158 
159  void writeArrayNdOfFloatValues(const std::string & groupName,
160  const std::string & name,
161  float * floatValues,
162  unsigned long long * numValuesInEachDimension,
163  const unsigned int & numDimensions);
164 
174  void writeArrayNdOfDoubleValues(const std::string & groupName,
175  const std::string & name,
176  double * dblValues,
177  unsigned long long * numValuesInEachDimension,
178  const unsigned int & numDimensions);
179 
189  void writeArrayNdOfCharValues(const std::string & groupName,
190  const std::string & name,
191  char * intValues,
192  unsigned long long * numValuesInEachDimension,
193  const unsigned int & numDimensions);
194 
204  void writeArrayNdOfIntValues(const std::string & groupName,
205  const std::string & name,
206  int * intValues,
207  unsigned long long * numValuesInEachDimension,
208  const unsigned int & numDimensions);
209 
219  void writeArrayNdOfGSoapULong64Values(const std::string & groupName,
220  const std::string & name,
221  ULONG64 * ulong64Values,
222  unsigned long long * numValuesInEachDimension,
223  const unsigned int & numDimensions);
224 
235  void writeArrayNd(const std::string & groupName,
236  const std::string & name,
237  const int & datatype,
238  void * values,
239  unsigned long long * numValuesInEachDimension,
240  const unsigned int & numDimensions);
241 
251  void createArrayNd(
252  const std::string& groupName,
253  const std::string& name,
254  const int & datatype,
255  unsigned long long* numValuesInEachDimension,
256  const unsigned int& numDimensions
257  );
258 
269  void writeArrayNdSlab(
270  const std::string& groupName,
271  const std::string& name,
272  const int & datatype,
273  void* values,
274  unsigned long long* numValuesInEachDimension,
275  unsigned long long* offsetValuesInEachDimension,
276  const unsigned int& numDimensions
277  );
278 
282  void writeGroupAttributes(const std::string & groupName,
283  const std::vector<std::string> & attributeNames,
284  const std::vector<std::string> & values);
285 
289  void writeGroupAttribute(const std::string & groupName,
290  const std::string & attributeName,
291  const std::vector<std::string> & values);
292 
296  void writeGroupAttributes(const std::string & groupName,
297  const std::vector<std::string> & attributeNames,
298  const std::vector<double> & values);
299 
303  void writeGroupAttributes(const std::string & groupName,
304  const std::vector<std::string> & attributeNames,
305  const std::vector<int> & values);
306 
310  void writeDatasetAttributes(const std::string & datasetName,
311  const std::vector<std::string> & attributeNames,
312  const std::vector<std::string> & values);
313 
317  void writeDatasetAttribute(const std::string & datasetName,
318  const std::string & attributeName,
319  const std::vector<std::string> & values);
320 
324  void writeDatasetAttributes(const std::string & datasetName,
325  const std::vector<std::string> & attributeNames,
326  const std::vector<double> & values);
327 
331  void writeDatasetAttributes(const std::string & datasetName,
332  const std::vector<std::string> & attributeNames,
333  const std::vector<int> & values);
334 
335  std::string readStringAttribute(const std::string & obj_name,
336  const std::string & attr_name) const;
337 
338  std::vector<std::string> readStringArrayAttribute(const std::string & obj_name,
339  const std::string & attr_name) const;
340 
341  double readDoubleAttribute(const std::string & obj_name,
342  const std::string & attr_name) const;
343 
344  LONG64 readLongAttribute(const std::string & obj_name,
345  const std::string & attr_name) const;
346 
352  void readArrayNdOfDoubleValues(const std::string & datasetName, double* values);
353 
362  void readArrayNdOfDoubleValues(
363  const std::string & datasetName,
364  double* values,
365  unsigned long long * numValuesInEachDimension,
366  unsigned long long * offsetInEachDimension,
367  const unsigned int & numDimensions
368  );
369 
375  void readArrayNdOfFloatValues(const std::string & datasetName, float* values);
376 
385  void readArrayNdOfFloatValues(
386  const std::string & datasetName,
387  float* values,
388  unsigned long long * numValuesInEachDimension,
389  unsigned long long * offsetInEachDimension,
390  const unsigned int & numDimensions
391  );
392 
396  void readArrayNdOfGSoapLong64Values(const std::string & datasetName, LONG64* values);
397 
401  void readArrayNdOfGSoapULong64Values(const std::string & datasetName, ULONG64* values);
402 
408  void readArrayNdOfLongValues(const std::string & datasetName, long* values);
409 
418  void readArrayNdOfLongValues(
419  const std::string & datasetName,
420  long* values,
421  unsigned long long * numValuesInEachDimension,
422  unsigned long long * offsetInEachDimension,
423  const unsigned int & numDimensions
424  );
425 
431  void readArrayNdOfULongValues(const std::string & datasetName, unsigned long* values);
432 
438  void readArrayNdOfIntValues(const std::string & datasetName, int* values);
439 
448  void readArrayNdOfIntValues(
449  const std::string & datasetName,
450  int* values,
451  unsigned long long * numValuesInEachDimension,
452  unsigned long long * offsetInEachDimension,
453  const unsigned int & numDimensions
454  );
455 
461  void readArrayNdOfUIntValues(const std::string & datasetName, unsigned int* values);
462 
469  void readArrayNdOfShortValues(const std::string & datasetName, short* values);
470 
476  void readArrayNdOfUShortValues(const std::string & datasetName, unsigned short* values);
477 
483  void readArrayNdOfCharValues(const std::string & datasetName, char* values);
484 
489  void readArrayNdOfUCharValues(const std::string & datasetName, unsigned char* values);
490 
495  std::vector<unsigned long long> readArrayDimensions(const std::string & datasetName);
496 
500  bool exist(const std::string & absolutePathInHdfFile) const;
501 
502  protected:
503 
507  virtual int openOrCreateRootGroup();
508 
514  int openOrCreateGroupInRootGroup(const std::string & groupName);
515 
516  int hdfFile;
517 
518  unsigned int compressionLevel;
519  };
520 }
~HdfProxy()
Definition: HdfProxy.h:90
void setCompressionLevel(const unsigned int &newCompressionLevel)
Definition: HdfProxy.h:157
Definition: AbstractHdfProxy.h:43
bool isOpened() const
Definition: HdfProxy.h:101
Definition: HdfProxy.h:40
Definition: AbstractHdfProxy.h:45