libSplash
basetypes_atomic.hpp
1 
23 #ifndef BASETYPES_ATOMIC_HPP
24 #define BASETYPES_ATOMIC_HPP
25 
26 #include <stdint.h>
27 #include <iostream>
28 #include <string>
29 
30 #include "splash/CollectionType.hpp"
31 
32 namespace splash
33 {
34 
35 #define TYPE_ATOMIC(_name, _h5_type, _real_type) \
36  class ColType##_name : public CollectionType \
37  { \
38  public: \
39  \
40  ColType##_name() \
41  { type = _h5_type; } \
42  \
43  size_t getSize() const \
44  { return sizeof (_real_type); } \
45  \
46  static CollectionType* genType(hid_t datatype_id) \
47  { \
48  bool found = false; \
49  H5T_class_t h5_class = H5Tget_class(datatype_id); \
50  if(h5_class == H5T_INTEGER || h5_class == H5T_FLOAT) \
51  { \
52  hid_t native = H5Tget_native_type(datatype_id,H5T_DIR_DEFAULT);\
53  if(H5Tequal(native, _h5_type) == 1) \
54  found = true; \
55  H5Tclose(native); \
56  } \
57  if(found) \
58  return new ColType##_name; \
59  else \
60  return NULL; \
61  } \
62  \
63  std::string toString() const \
64  { \
65  return #_name; \
66  } \
67  \
68  }; \
69 
70 
71 TYPE_ATOMIC(Float, H5T_NATIVE_FLOAT, float);
72 TYPE_ATOMIC(Double, H5T_NATIVE_DOUBLE, double);
73 
74 TYPE_ATOMIC(Int, H5T_NATIVE_INT, int);
75 TYPE_ATOMIC(Char, H5T_NATIVE_CHAR, char);
76 
77 TYPE_ATOMIC(UInt8, H5T_INTEL_U8, uint8_t);
78 TYPE_ATOMIC(UInt16, H5T_INTEL_U16, uint16_t);
79 TYPE_ATOMIC(UInt32, H5T_INTEL_U32, uint32_t);
80 TYPE_ATOMIC(UInt64, H5T_INTEL_U64, uint64_t);
81 
82 TYPE_ATOMIC(Int8, H5T_INTEL_I8, int8_t);
83 TYPE_ATOMIC(Int16, H5T_INTEL_I16, int16_t);
84 TYPE_ATOMIC(Int32, H5T_INTEL_I32, int32_t);
85 TYPE_ATOMIC(Int64, H5T_INTEL_I64, int64_t);
86 
87 }
88 
89 #endif /* BASETYPES_ATOMIC_HPP */