hdf5serie 2.0.0 HDF5 Serie

simple.h
1
26 template<class T>
27 class HDF5SERIE_CLASS : public HDF5SERIE_BASECLASS {
28 friend class Container<HDF5SERIE_CONTAINERBASECLASS, HDF5SERIE_PARENTCLASS>;
29 private:
30 hid_t memDataTypeID; // no need to use ScopedHID since only a static hid_t is stored here
31 ScopedHID memDataSpaceID;
32 protected:
48 HDF5SERIE_CLASS(int dummy, HDF5SERIE_PARENTCLASS *parent_, const std::string& name_);
49 HDF5SERIE_CLASS(HDF5SERIE_PARENTCLASS *parent_, const std::string& name_);
50
51 ~HDF5SERIE_CLASS() override;
52
53 void close() override;
54
55 public:
60 void write(const T& data);
61
66 T read();
67
68 #ifdef HDF5SERIE_DATASETTYPE
69 void setDescription(const std::string &desc) {
70 SimpleAttribute<std::string> *a=createChildAttribute<SimpleAttribute<std::string> >("Description")();
71 a->write(desc);
72 }
73 std::string getDescription() {
74 auto *a=openChildAttribute<SimpleAttribute<std::string> >("Description");
75 return a->read();
76 }
77 #endif
78 };
79
80 template<class T>
81 class HDF5SERIE_CLASS<std::vector<T> > : public HDF5SERIE_BASECLASS {
82 friend class Container<HDF5SERIE_CONTAINERBASECLASS, HDF5SERIE_PARENTCLASS>;
83 private:
84 hid_t memDataTypeID; // no need to use SScopedHID since only a static hid_t is stored here
85 ScopedHID memDataSpaceID;
86 int size;
87 protected:
88 HDF5SERIE_CLASS(int dummy, HDF5SERIE_PARENTCLASS *parent_, const std::string& name_);
89 HDF5SERIE_CLASS(HDF5SERIE_PARENTCLASS *parent_, const std::string& name_, int size_);
90 ~HDF5SERIE_CLASS() override;
91 void close() override;
92 public:
93 void write(const std::vector<T>& data);
94 std::vector<T> read();
95 #ifdef HDF5SERIE_DATASETTYPE
96 void setDescription(const std::string &desc) {
97 SimpleAttribute<std::string> *a=createChildAttribute<SimpleAttribute<std::string> >("Description")();
98 a->write(desc);
99 }
100 std::string getDescription() {
101 auto *a=openChildAttribute<SimpleAttribute<std::string> >("Description");
102 return a->read();
103 }
104 #endif
105 };
106
107 template<class T>
108 class HDF5SERIE_CLASS<std::vector<std::vector<T> > > : public HDF5SERIE_BASECLASS {
109 friend class Container<HDF5SERIE_CONTAINERBASECLASS, HDF5SERIE_PARENTCLASS>;
110 private:
111 hid_t memDataTypeID; // no need to use SScopedHID since only a static hid_t is stored here
112 ScopedHID memDataSpaceID;
113 int rows;
114 int cols;
115 protected:
116 HDF5SERIE_CLASS(int dummy, HDF5SERIE_PARENTCLASS *parent_, const std::string& name_);
117 HDF5SERIE_CLASS(HDF5SERIE_PARENTCLASS *parent_, const std::string& name_, int rows_, int cols_);
118 ~HDF5SERIE_CLASS() override;
119 void close() override;
120 public:
121 void write(const std::vector<std::vector<T> >& data);
122 std::vector<std::vector<T> > read();
123 #ifdef HDF5SERIE_DATASETTYPE
124 void setDescription(const std::string &desc) {
125 SimpleAttribute<std::string> *a=createChildAttribute<SimpleAttribute<std::string> >("Description")();
126 a->write(desc);
127 }
128 std::string getDescription() {
129 auto *a=openChildAttribute<SimpleAttribute<std::string> >("Description");
130 return a->read();
131 }
132 #endif
133 };
HDF5SERIE_CLASS::read
T read()
Read data.
Definition: simple.cc:42
HDF5SERIE_CLASS::HDF5SERIE_CLASS
HDF5SERIE_CLASS(int dummy, HDF5SERIE_PARENTCLASS *parent_, const std::string &name_)
Constructor for opening or creating a attribute/dataset.
Definition: simple.cc:3
HDF5SERIE_CLASS::write
void write(const T &data)
Write data.
Definition: simple.cc:32
HDF5SERIE_CLASS
A scalar, vector or matrix attribute/dataset.
Definition: simple.h:27