Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
H5.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File H5.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Simple OO wrapper around HDF5
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_H5_H
37 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_H5_H
38 
39 #include <boost/enable_shared_from_this.hpp>
40 #include <boost/functional/hash.hpp>
41 #include <boost/shared_ptr.hpp>
42 #include <exception>
43 #include <hdf5.h>
44 #include <string>
45 #include <vector>
46 
49 
50 namespace Nektar
51 {
52 namespace LibUtilities
53 {
54 namespace H5
55 {
56 
57 #define H5_CONSTRUCT(ans, func, args) \
58  { \
59  hid_t ret = func args; \
60  if (ret < 0) \
61  ErrorUtil::Error(ErrorUtil::efatal, \
62  __FILE__, \
63  __LINE__, \
64  "HDF5 error in API function " #func, \
65  0); \
66  ans = ret; \
67  }
68 #define H5_CALL(func, args) \
69  { \
70  herr_t ret = func args; \
71  if (ret < 0) \
72  ErrorUtil::Error(ErrorUtil::efatal, \
73  __FILE__, \
74  __LINE__, \
75  "HDF5 error in API function " #func, \
76  0); \
77  }
78 
79 class Error : public std::exception
80 {
81 };
82 
83 // Forward declare
84 class Object;
85 typedef boost::shared_ptr<Object> ObjectSharedPtr;
86 class DataType;
87 typedef boost::shared_ptr<DataType> DataTypeSharedPtr;
88 class DataSpace;
89 typedef boost::shared_ptr<DataSpace> DataSpaceSharedPtr;
91 typedef boost::shared_ptr<CanHaveAttributes> CanHaveAttributesSharedPtr;
92 class Attribute;
93 typedef boost::shared_ptr<Attribute> AttributeSharedPtr;
95 typedef boost::shared_ptr<CanHaveGroupsDataSets> CanHaveGroupsDataSetsSharedPtr;
96 class Group;
97 typedef boost::shared_ptr<Group> GroupSharedPtr;
98 class File;
99 typedef boost::shared_ptr<File> FileSharedPtr;
100 class DataSet;
101 typedef boost::shared_ptr<DataSet> DataSetSharedPtr;
102 class PList;
103 typedef boost::shared_ptr<PList> PListSharedPtr;
104 
105 /// HDF5 base class
106 class Object : public boost::enable_shared_from_this<Object>
107 {
108 public:
109  virtual void Close() = 0;
110  inline hid_t GetId() const
111  {
112  return m_Id;
113  }
114  // Overload cast to the HDF5 ID type to make objects
115  // transparently usable in the HDF5 API.
116  inline operator hid_t() const
117  {
118  return GetId();
119  }
120 
121 protected:
122  Object();
123  Object(hid_t id);
124  virtual ~Object();
125  hid_t m_Id;
126 };
127 
128 // PropertyList objects
129 class PList : public Object
130 {
131 public:
132  /// Default options
133  static PListSharedPtr Default();
134  /// Properties for object creation
135  static PListSharedPtr ObjectCreate();
136  /// Properties for file creation
137  static PListSharedPtr FileCreate();
138  /// Properties for file access
139  static PListSharedPtr FileAccess();
140  /// Properties for dataset creation
141  static PListSharedPtr DatasetCreate();
142  /// Properties for dataset access
143  static PListSharedPtr DatasetAccess();
144  /// Properties for raw data transfer
145  static PListSharedPtr DatasetXfer();
146  /// Properties for file mounting
147  static PListSharedPtr FileMount();
148  /// Properties for group creation
149  static PListSharedPtr GroupCreate();
150  /// Properties for group access
151  static PListSharedPtr GroupAccess();
152  /// Properties for datatype creation
153  static PListSharedPtr DatatypeCreate();
154  /// Properties for datatype access
155  static PListSharedPtr DatatypeAccess();
156  /// Properties for character encoding when encoding strings or object names
157  static PListSharedPtr StringCreate();
158  /// Properties for attribute creation
159  static PListSharedPtr AttributeCreate();
160  /// Properties governing the object copying process
161  static PListSharedPtr ObjectCopy();
162  /// Properties governing link creation
163  static PListSharedPtr LinkCreate();
164  /// Properties governing link traversal when accessing objects
165  static PListSharedPtr LinkAccess();
166 
167  PList();
168  ~PList();
169  void Close();
170  void SetChunk(const std::vector<hsize_t> &dims);
171  void SetDeflate(const unsigned level = 1);
172  void SetMpio(CommSharedPtr comm);
173  void SetDxMpioCollective();
174  void SetDxMpioIndependent();
175 
176 private:
177  PList(hid_t cls);
178 };
179 
180 /// Mixin for objects that contain groups and datasets (Group and File)
181 class CanHaveGroupsDataSets : public virtual Object
182 {
183 public:
185  {
186  public:
187  LinkIterator(CanHaveGroupsDataSetsSharedPtr grp, hsize_t idx = 0);
188  const std::string &operator*();
190  bool operator==(const LinkIterator &other) const;
191  inline bool operator!=(const LinkIterator &other) const
192  {
193  return !(*this == other);
194  }
195  inline hsize_t GetPos() const
196  {
197  return m_idx;
198  }
199 
200  private:
201  static herr_t helper(hid_t g_id,
202  const char *name,
203  const H5L_info_t *info,
204  void *op_data);
205  CanHaveGroupsDataSetsSharedPtr m_grp;
206  hsize_t m_idx;
207  hsize_t m_next;
208  hsize_t m_size;
209  std::string m_currentName;
210  };
211 
212  // Create a group with the given name. The createPL can be
213  // omitted to use the default properties.
214  GroupSharedPtr CreateGroup(const std::string &name,
215  PListSharedPtr createPL = PList::Default(),
216  PListSharedPtr accessPL = PList::Default());
217 
218  // Create a dataset with the name, type and space.
219  // The createPL can be omitted to use the defaults.
220  DataSetSharedPtr CreateDataSet(const std::string &name,
221  DataTypeSharedPtr type,
222  DataSpaceSharedPtr space,
223  PListSharedPtr createPL = PList::Default(),
224  PListSharedPtr accessPL = PList::Default());
225 
226  // Create a dataset containing the data supplied
227  // The createPL can be omitted to use the defaults
228  template <class T>
229  DataSetSharedPtr CreateWriteDataSet(
230  const std::string &name,
231  const std::vector<T> &data,
232  PListSharedPtr createPL = PList::Default(),
233  PListSharedPtr accessPL = PList::Default());
234 
235  // Open an existing group.
236  // The accessPL can be omitted to use the defaults
237  GroupSharedPtr OpenGroup(const std::string &name,
238  PListSharedPtr accessPL = PList::Default()) const;
239 
240  // Open an existing dataset
241  // The accessPL can be omitted to use the defaults
242  DataSetSharedPtr OpenDataSet(
243  const std::string &name,
244  PListSharedPtr accessPL = PList::Default()) const;
245  virtual hsize_t GetNumElements() = 0;
247  LinkIterator end();
248 
249  friend class key_iterator;
250 };
251 
252 /// Mixin for objects that can have attributes (Group, DataSet, DataType)
253 class CanHaveAttributes : public virtual Object
254 {
255 public:
257  {
258  public:
259  AttrIterator(CanHaveAttributesSharedPtr obj, hsize_t idx = 0);
260  const std::string &operator*();
262  bool operator==(const AttrIterator &other) const;
263  inline bool operator!=(const AttrIterator &other) const
264  {
265  return !(*this == other);
266  }
267  inline hsize_t GetPos() const
268  {
269  return m_idx;
270  }
271 
272  private:
273  static herr_t helper(hid_t g_id,
274  const char *name,
275  const H5A_info_t *info,
276  void *op_data);
277  CanHaveAttributesSharedPtr m_obj;
278  hsize_t m_idx;
279  hsize_t m_next;
280  hsize_t m_size;
281  std::string m_currentName;
282  };
283 
284  AttributeSharedPtr CreateAttribute(const std::string &name,
285  DataTypeSharedPtr type,
286  DataSpaceSharedPtr space);
287  AttributeSharedPtr OpenAttribute(const std::string &name);
288 
289  template <class T>
290  void SetAttribute(const std::string &name, const T &value);
291  template <class T>
292  void SetAttribute(const std::string &name, const std::vector<T> &value);
293 
294  template <class T> void GetAttribute(const std::string &name, T &value);
295  template <class T>
296  void GetAttribute(const std::string &name, std::vector<T> &value);
297 
298  int GetNumAttr() const;
301 };
302 
303 /// HDF5 DataSpace wrapper
304 class DataSpace : public Object
305 {
306 public:
307  static DataSpaceSharedPtr Null();
308  static DataSpaceSharedPtr Scalar();
309  static DataSpaceSharedPtr OneD(hsize_t size);
310 
311  DataSpace();
312  DataSpace(hsize_t size, hsize_t max = H5S_UNLIMITED - 1);
313  DataSpace(const std::vector<hsize_t> &dims);
314  DataSpace(const std::vector<hsize_t> &dims,
315  const std::vector<hsize_t> &max_dims);
316  ~DataSpace();
317 
318  void Close();
319  void SelectRange(const hsize_t start, const hsize_t count);
320 
321  hsize_t GetSize();
322 
323 private:
324  DataSpace(hid_t id);
325  friend class Attribute;
326  friend class DataSet;
327 };
328 
329 // Policy class for the DataTypesTraits controlling whether data
330 // has to be converted in anyway before writing. (It could perhaps
331 // be DataTypeTraitsTraits but that's too horrible a name.)
332 //
333 // Default policy is to not convert at all.
334 template <class T> struct DataTypeConversionPolicy
335 {
336  static const bool MustConvert = false;
337  typedef T ConvertedType;
339  static ConvertedType Convert(const T &obj);
340  static T Deconvert(const ConvertedType &obj);
341 };
342 
343 /// Traits class for HDF5 data types.
344 template <class T> struct DataTypeTraits
345 {
347 
348  /***
349  * Define this for a specialision for any HDF5 NATIVE type you want to use.
350  * See http://hdfgroup.org/HDF5/doc/UG/UG_frame11Datatypes.html
351  */
352  static const hid_t NativeType;
353 
355 
356  static ConvertedType Convert(const T &obj);
357  static T Deconvert(const ConvertedType &obj);
358  /**
359  * Get the address of the start of the data.
360  * Default implementation just uses "&"
361  */
362  static const void *GetAddress(const ConvertedType &obj);
363  static void *GetAddress(ConvertedType &obj);
364  /**
365  * Return a DataType object representing T.
366  * Default implementation just calls PredefinedDataType::Native<T>()
367  */
368  static DataTypeSharedPtr GetType();
369  static DataTypeSharedPtr GetType(const T &obj);
370 };
371 
372 /// Wrap and HDF5 data type object. Technically this can have attributes, but
373 /// not really bothered.
374 class DataType : public Object
375 {
376 public:
377  static DataTypeSharedPtr String(size_t len = 0);
378  template <class T> static DataTypeSharedPtr OfObject(const T &obj)
379  {
381  }
382  virtual void Close();
383  DataTypeSharedPtr Copy() const;
384 
385 protected:
386  DataType(hid_t id);
387 };
388 
389 /// Predefined HDF data types that must not be closed when done with.
391 {
392 public:
393  template <class T> static DataTypeSharedPtr Native();
394  static DataTypeSharedPtr CS1();
395  void Close();
396 
397 private:
398  PredefinedDataType(hid_t);
399 };
400 
401 /// HDF5 Attribute Wrapper
402 class Attribute : public Object
403 {
404 public:
405  ~Attribute();
406  void Close();
407  DataSpaceSharedPtr GetSpace() const;
408 
409 private:
410  Attribute(hid_t id) : Object(id)
411  {
412  }
413  static AttributeSharedPtr Create(hid_t parent,
414  const std::string &name,
415  DataTypeSharedPtr type,
416  DataSpaceSharedPtr space);
417  static AttributeSharedPtr Open(hid_t parent, const std::string &name);
418  friend class CanHaveAttributes;
419 };
420 
421 /// HDF5 file wrapper
423 {
424 public:
425  static FileSharedPtr Create(const std::string &filename,
426  unsigned mode,
427  PListSharedPtr createPL = PList::Default(),
428  PListSharedPtr accessPL = PList::Default());
429  static FileSharedPtr Open(const std::string &filename,
430  unsigned mode,
431  PListSharedPtr accessPL = PList::Default());
432  ~File();
433  void Close();
434  virtual hsize_t GetNumElements();
435 
436 private:
437  File(hid_t id);
438 };
439 
440 /// HDF5 Group wrapper
442 {
443 public:
444  ~Group();
445  void Close();
446  virtual hsize_t GetNumElements();
447  CanHaveAttributesSharedPtr operator[](hsize_t idx);
448  CanHaveAttributesSharedPtr operator[](const std::string &key);
449 
450 private:
451  Group(hid_t id);
452  friend class CanHaveGroupsDataSets;
453 };
454 
456 {
457 public:
458  ~DataSet();
459  void Close();
460  DataSpaceSharedPtr GetSpace() const;
461 
462  template <class T> void Write(const std::vector<T> &data)
463  {
464  DataTypeSharedPtr mem_t = DataTypeTraits<T>::GetType();
465  H5_CALL(
466  H5Dwrite,
467  (m_Id, mem_t->GetId(), H5S_ALL, H5S_ALL, H5P_DEFAULT, &data[0]));
468  }
469  template <class T>
470  void Write(const std::vector<T> &data,
471  DataSpaceSharedPtr filespace,
472  PListSharedPtr dxpl = PList::Default())
473  {
474  DataTypeSharedPtr mem_t = DataTypeTraits<T>::GetType();
475  DataSpaceSharedPtr memspace = DataSpace::OneD(data.size());
476 
477  H5Dwrite(m_Id,
478  mem_t->GetId(),
479  memspace->GetId(),
480  filespace->GetId(),
481  dxpl->GetId(),
482  &data[0]);
483  }
484  template <class T> void Read(std::vector<T> &data)
485  {
486  DataTypeSharedPtr mem_t = DataTypeTraits<T>::GetType();
487  DataSpaceSharedPtr space = GetSpace();
488  ASSERTL0(H5Sget_simple_extent_ndims(space->GetId()) == 1,
489  "vector data not 1D");
490  hsize_t len, maxdim;
491  H5Sget_simple_extent_dims(space->GetId(), &len, &maxdim);
492 
493  data.resize(len);
494 
495  H5_CALL(
496  H5Dread,
497  (m_Id, mem_t->GetId(), H5S_ALL, H5S_ALL, H5P_DEFAULT, &data[0]));
498  }
499  template <class T>
500  void Read(std::vector<T> &data,
501  DataSpaceSharedPtr filespace,
502  PListSharedPtr dxpl = PList::Default())
503  {
504  DataTypeSharedPtr mem_t = DataTypeTraits<T>::GetType();
505  hsize_t len;
506  len = H5Sget_select_npoints(filespace->GetId());
507 
508  data.resize(len);
509 
510  DataSpaceSharedPtr memspace = DataSpace::OneD(len);
511  H5Dread(m_Id,
512  mem_t->GetId(),
513  memspace->GetId(),
514  filespace->GetId(),
515  dxpl->GetId(),
516  &data[0]);
517  }
518 
519 private:
520  DataSet(hid_t id);
521  friend class CanHaveGroupsDataSets;
522 };
523 
524 template <class T>
526  T>::Convert(const T &obj)
527 {
528  return obj;
529 }
530 
531 template <class T>
533  const typename DataTypeConversionPolicy<T>::ConvertedType &obj)
534 {
535  return obj;
536 }
537 
538 template <class T> DataTypeSharedPtr DataTypeTraits<T>::GetType()
539 {
540  return PredefinedDataType::Native<T>();
541 }
542 
543 template <class T>
546 {
547  return &obj;
548 }
549 
550 template <class T>
551 void *DataTypeTraits<T>::GetAddress(DataTypeTraits<T>::ConvertedType &obj)
552 {
553  return &obj;
554 }
555 
556 template <class T>
558  const T &obj)
559 {
560  return Converter::Convert(obj);
561 }
562 
563 template <class T>
565  const typename DataTypeTraits<T>::ConvertedType &obj)
566 {
567  return Converter::Deconvert(obj);
568 }
569 template <> struct DataTypeConversionPolicy<std::string>
570 {
571  static const bool MustConvert = true;
572  typedef const char *ConvertedType;
573  typedef const char *ConvertedVectorElemType;
574  inline static ConvertedType Convert(const std::string &obj)
575  {
576  return obj.c_str();
577  }
578  inline static std::string Deconvert(const ConvertedType &obj)
579  {
580  return std::string(obj);
581  }
582 };
583 
584 template <> inline DataTypeSharedPtr DataTypeTraits<std::string>::GetType()
585 {
586  return DataType::String();
587 }
588 
589 template <class T> DataTypeSharedPtr PredefinedDataType::Native()
590 {
591  return DataTypeSharedPtr(
593 }
594 
595 template <typename T>
596 void CanHaveAttributes::SetAttribute(const std::string &name, const T &value)
597 {
598  DataTypeSharedPtr type = DataTypeTraits<T>::GetType();
599  DataSpaceSharedPtr space = DataSpace::Scalar();
600  AttributeSharedPtr attr = CreateAttribute(name, type, space);
601 
602  typename DataTypeTraits<T>::ConvertedType conv =
604  H5_CALL(
605  H5Awrite,
606  (attr->GetId(), type->GetId(), DataTypeTraits<T>::GetAddress(conv)));
607 }
608 
609 template <typename T>
610 void CanHaveAttributes::SetAttribute(const std::string &name,
611  const std::vector<T> &value)
612 {
613  typedef std::vector<
615  Vec;
616  Vec converted_vals;
617  DataTypeSharedPtr type = DataTypeTraits<T>::GetType();
618  DataSpaceSharedPtr space = DataSpace::OneD(value.size());
619  AttributeSharedPtr attr = CreateAttribute(name, type, space);
620 
621  const void *converted_buf = NULL;
623  {
624  converted_vals.resize(value.size());
625  for (size_t i = 0; i < value.size(); ++i)
626  {
627  converted_vals[i] = DataTypeConversionPolicy<T>::Convert(value[i]);
628  }
629  converted_buf = &converted_vals[0];
630  }
631  else
632  {
633  converted_buf = &value[0];
634  }
635 
636  H5_CALL(H5Awrite, (attr->GetId(), type->GetId(), converted_buf));
637 }
638 
639 template <typename T>
640 void CanHaveAttributes::GetAttribute(const std::string &name, T &value)
641 {
642  DataTypeSharedPtr type = DataTypeTraits<T>::GetType();
643  DataSpaceSharedPtr space = DataSpace::Scalar();
644  AttributeSharedPtr attr = OpenAttribute(name);
645 
646  typename DataTypeTraits<T>::ConvertedType conv;
647 
648  H5_CALL(
649  H5Aread,
650  (attr->GetId(), type->GetId(), DataTypeTraits<T>::GetAddress(conv)));
651  value = DataTypeTraits<T>::Deconvert(conv);
652 }
653 
654 template <typename T>
655 void CanHaveAttributes::GetAttribute(const std::string &name,
656  std::vector<T> &value)
657 {
658  typedef std::vector<
660  Vec;
661  Vec converted_vals;
662  DataTypeSharedPtr type = DataTypeTraits<T>::GetType();
663  AttributeSharedPtr attr = OpenAttribute(name);
664  DataSpaceSharedPtr space = attr->GetSpace();
665  ASSERTL0(H5Sget_simple_extent_ndims(space->GetId()) == 1,
666  "vector data not 1D");
667  hsize_t len, maxdim;
668  H5Sget_simple_extent_dims(space->GetId(), &len, &maxdim);
669 
670  value.resize(len);
671  void *converted_buf = NULL;
673  {
674  converted_vals.resize(len);
675  converted_buf = &converted_vals[0];
676  }
677  else
678  {
679  converted_buf = &value[0];
680  }
681 
682  H5_CALL(H5Aread, (attr->GetId(), type->GetId(), converted_buf));
683 
685  {
686  typename Vec::iterator src = converted_vals.begin(),
687  end = converted_vals.end();
688  typename std::vector<T>::iterator dest = value.begin();
689  for (; src != end; ++src, ++dest)
690  {
691  *dest = DataTypeTraits<T>::Deconvert(*src);
692  }
693  }
694 }
695 
696 template <class T>
698  const std::string &name,
699  const std::vector<T> &data,
700  PListSharedPtr createPL,
701  PListSharedPtr accessPL)
702 {
703  DataTypeSharedPtr type = DataTypeTraits<T>::GetType();
704  DataSpaceSharedPtr space = DataSpace::OneD(data.size());
705  DataSetSharedPtr dataset =
706  CreateDataSet(name, type, space, createPL, accessPL);
707  dataset->Write(data);
708  return dataset;
709 }
710 }
711 }
712 }
713 
714 #endif
#define H5_CALL(func, args)
Definition: H5.h:68
static ConvertedType Convert(const T &obj)
Definition: H5.h:526
static PListSharedPtr DatatypeCreate()
Properties for datatype creation.
Definition: H5.cpp:138
void Write(const std::vector< T > &data)
Definition: H5.h:462
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
boost::shared_ptr< Group > GroupSharedPtr
Definition: FieldIOHdf5.h:50
static DataTypeSharedPtr CS1()
Definition: H5.cpp:490
static FileSharedPtr Create(const std::string &filename, unsigned mode, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
Definition: H5.cpp:555
static const void * GetAddress(const ConvertedType &obj)
void SelectRange(const hsize_t start, const hsize_t count)
Definition: H5.cpp:450
static AttributeSharedPtr Create(hid_t parent, const std::string &name, DataTypeSharedPtr type, DataSpaceSharedPtr space)
Definition: H5.cpp:520
HDF5 DataSpace wrapper.
Definition: H5.h:304
static DataTypeSharedPtr OfObject(const T &obj)
Definition: H5.h:378
boost::shared_ptr< DataSet > DataSetSharedPtr
Definition: H5.h:100
STL namespace.
static T Deconvert(const ConvertedType &obj)
Definition: H5.h:532
static DataTypeSharedPtr GetType()
Definition: H5.h:538
AttrIterator(CanHaveAttributesSharedPtr obj, hsize_t idx=0)
Definition: H5.cpp:353
DataSetSharedPtr CreateDataSet(const std::string &name, DataTypeSharedPtr type, DataSpaceSharedPtr space, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
Definition: H5.cpp:229
static DataTypeSharedPtr String(size_t len=0)
Definition: H5.cpp:464
Converter::ConvertedType ConvertedType
Definition: H5.h:354
static PListSharedPtr GroupAccess()
Properties for group access.
Definition: H5.cpp:132
boost::shared_ptr< File > FileSharedPtr
Definition: H5.h:98
DataSetSharedPtr OpenDataSet(const std::string &name, PListSharedPtr accessPL=PList::Default()) const
Definition: H5.cpp:257
Mixin for objects that can have attributes (Group, DataSet, DataType)
Definition: H5.h:253
boost::shared_ptr< DataType > DataTypeSharedPtr
Definition: H5.h:86
HDF5 Attribute Wrapper.
Definition: H5.h:402
boost::shared_ptr< PList > PListSharedPtr
Definition: H5.h:102
static PListSharedPtr DatasetCreate()
Properties for dataset creation.
Definition: H5.cpp:102
DataSetSharedPtr CreateWriteDataSet(const std::string &name, const std::vector< T > &data, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
Definition: H5.h:697
bool operator!=(const AttrIterator &other) const
Definition: H5.h:263
DataTypeConversionPolicy< T > Converter
Definition: H5.h:346
static PListSharedPtr GroupCreate()
Properties for group creation.
Definition: H5.cpp:126
Wrap and HDF5 data type object. Technically this can have attributes, but not really bothered...
Definition: H5.h:374
HDF5 file wrapper.
Definition: H5.h:422
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
boost::shared_ptr< DataSpace > DataSpaceSharedPtr
Definition: H5.h:88
static ConvertedType Convert(const T &obj)
Definition: H5.h:557
static DataSpaceSharedPtr OneD(hsize_t size)
Definition: H5.cpp:403
static FileSharedPtr Open(const std::string &filename, unsigned mode, PListSharedPtr accessPL=PList::Default())
Definition: H5.cpp:563
boost::shared_ptr< Attribute > AttributeSharedPtr
Definition: H5.h:92
void SetChunk(const std::vector< hsize_t > &dims)
Definition: H5.cpp:178
static PListSharedPtr ObjectCreate()
Properties for object creation.
Definition: H5.cpp:84
static const hid_t NativeType
Definition: H5.h:352
DataSpaceSharedPtr GetSpace() const
Definition: H5.cpp:547
Traits class for HDF5 data types.
Definition: H5.h:344
static DataSpaceSharedPtr Null()
Definition: H5.cpp:390
static PListSharedPtr DatasetXfer()
Properties for raw data transfer.
Definition: H5.cpp:114
static PListSharedPtr FileCreate()
Properties for file creation.
Definition: H5.cpp:90
static ConvertedType Convert(const std::string &obj)
Definition: H5.h:574
GroupSharedPtr CreateGroup(const std::string &name, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
Definition: H5.cpp:218
void SetAttribute(const std::string &name, const T &value)
Definition: H5.h:596
static PListSharedPtr DatatypeAccess()
Properties for datatype access.
Definition: H5.cpp:144
static DataSpaceSharedPtr Scalar()
Definition: H5.cpp:397
Mixin for objects that contain groups and datasets (Group and File)
Definition: H5.h:181
CanHaveAttributesSharedPtr operator[](hsize_t idx)
static herr_t helper(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data)
Definition: H5.cpp:380
void SetMpio(CommSharedPtr comm)
Definition: H5.cpp:212
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
static T Deconvert(const ConvertedType &obj)
Definition: H5.h:564
AttributeSharedPtr CreateAttribute(const std::string &name, DataTypeSharedPtr type, DataSpaceSharedPtr space)
Definition: H5.cpp:319
virtual hsize_t GetNumElements()
Definition: H5.cpp:601
void Read(std::vector< T > &data)
Definition: H5.h:484
HDF5 base class.
Definition: H5.h:106
DataSpaceSharedPtr GetSpace() const
Definition: H5.cpp:623
#define dest(otri, vertexptr)
boost::shared_ptr< Object > ObjectSharedPtr
Definition: H5.h:84
virtual hsize_t GetNumElements()
Definition: H5.cpp:581
static PListSharedPtr StringCreate()
Properties for character encoding when encoding strings or object names.
Definition: H5.cpp:150
DataTypeSharedPtr Copy() const
Definition: H5.cpp:482
static DataTypeSharedPtr Native()
Definition: H5.h:589
static PListSharedPtr LinkCreate()
Properties governing link creation.
Definition: H5.cpp:168
boost::shared_ptr< CanHaveAttributes > CanHaveAttributesSharedPtr
Definition: H5.h:90
static PListSharedPtr DatasetAccess()
Properties for dataset access.
Definition: H5.cpp:108
static PListSharedPtr FileAccess()
Properties for file access.
Definition: H5.cpp:96
void Read(std::vector< T > &data, DataSpaceSharedPtr filespace, PListSharedPtr dxpl=PList::Default())
Definition: H5.h:500
bool operator==(const AttrIterator &other) const
Definition: H5.cpp:374
static PListSharedPtr AttributeCreate()
Properties for attribute creation.
Definition: H5.cpp:156
static PListSharedPtr LinkAccess()
Properties governing link traversal when accessing objects.
Definition: H5.cpp:174
AttributeSharedPtr OpenAttribute(const std::string &name)
Definition: H5.cpp:326
void SetDeflate(const unsigned level=1)
Definition: H5.cpp:182
static PListSharedPtr ObjectCopy()
Properties governing the object copying process.
Definition: H5.cpp:162
void GetAttribute(const std::string &name, T &value)
Definition: H5.h:640
static std::string Deconvert(const ConvertedType &obj)
Definition: H5.h:578
hid_t GetId() const
Definition: H5.h:110
Predefined HDF data types that must not be closed when done with.
Definition: H5.h:390
HDF5 Group wrapper.
Definition: H5.h:441
static PListSharedPtr Default()
Default options.
Definition: H5.cpp:78
static PListSharedPtr FileMount()
Properties for file mounting.
Definition: H5.cpp:120
void Write(const std::vector< T > &data, DataSpaceSharedPtr filespace, PListSharedPtr dxpl=PList::Default())
Definition: H5.h:470
GroupSharedPtr OpenGroup(const std::string &name, PListSharedPtr accessPL=PList::Default()) const
Definition: H5.cpp:246
boost::shared_ptr< CanHaveGroupsDataSets > CanHaveGroupsDataSetsSharedPtr
Definition: H5.h:94
static AttributeSharedPtr Open(hid_t parent, const std::string &name)
Definition: H5.cpp:530