FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
H++with_cache_image/H5Object.hpp
1#ifndef __H5_OBJECT_HPP
2#define __H5_OBJECT_HPP
3
4#include <memcore/RefPtr.hpp>
5#include <hdf5.h>
6#include <vector>
7
8class H5Object : public MemCore::ReferenceBase<H5Object>
9{
10static bool H5LibraryIsActive;
11
12protected:
13 hid_t hid;
14
15protected:
16 H5Object();
17 H5Object(const H5Object&) = delete;
18
19 H5Object&operator=(const H5Object&) = delete;
20
21 virtual ~H5Object();
22
23 H5Object(hid_t ID);
24
25public:
26 struct Silence
27 {
28 H5E_auto2_t func;
29 void *client_data;
30
31 Silence(const Silence&) = delete;
32 void operator=(const Silence&) = delete;
33
34 Silence()
35 {
36 H5Eget_auto2( H5E_DEFAULT, &func, &client_data );
37 H5Eset_auto2( H5E_DEFAULT, 0,0);
38 }
39
40 ~Silence()
41 {
42 H5Eset_auto2( H5E_DEFAULT, func, client_data);
43 }
44 };
45
46 template <class Lambda>
47static auto Silentio(const Lambda&L) -> decltype( L() )
48 {
49 Silence BeSilent;
50 return L();
51 }
52
53
54 struct CaptureErrors : std::string, Silence
55 {
57 };
58
59 hid_t getHid() const
60 {
61 return hid;
62 }
63
64 hid_t getHidClone() const
65 {
66 H5Iinc_ref( hid );
67 return hid;
68 }
69
70 bool isValid() const
71 {
72 return hid>0;
73 }
74
75static bool isActive()
76 {
77 return H5LibraryIsActive;
78 }
79
80static void CloseLibrary();
81
82 bool Awrite(const char*AttributeName, hid_t file_type_id,
83 hid_t mem_type_id,
84 const void*data,
85 size_t Elements) const;
86
87 bool Awrite(const std::string&AttributeName, hid_t file_type_id,
88 hid_t mem_type_id,
89 const void*data,
90 size_t Elements) const
91 {
92 return Awrite(AttributeName.c_str(), file_type_id,
93 mem_type_id, data, Elements);
94 }
95
96 template <class name_t>
97 bool Awrite(const name_t&AttributeName, hid_t type_id, const void*data, size_t Elements) const
98 {
99 return Awrite(AttributeName, type_id, type_id, data, Elements);
100 }
101
102#if 0
103 template <class name_t>
104 bool Awrite(const name_t&AttributeName, const int*data, size_t Elements) const
105 {
106 return Awrite( AttributeName, H5T_NATIVE_INT, data, Elements);
107 }
108
109 template <class name_t>
110 bool Awrite(const name_t&AttributeName, const unsigned int*data, size_t Elements) const
111 {
112 return Awrite( AttributeName, H5T_NATIVE_UINT, data, Elements);
113 }
114
115 template <class name_t>
116 bool Awrite(const name_t&AttributeName, const long*data, size_t Elements) const
117 {
118 return Awrite( AttributeName, H5T_NATIVE_LONG, data, Elements);
119 }
120
121 template <class name_t>
122 bool Awrite(const name_t&AttributeName, const unsigned long*data, size_t Elements) const
123 {
124 return Awrite( AttributeName, H5T_NATIVE_ULONG, data, Elements);
125 }
126#endif
127
128 template <class name_t>
129 bool Awrite(const name_t&AttributeName, const int16_t*data, size_t Elements) const
130 {
131 return Awrite( AttributeName, H5T_NATIVE_INT16, data, Elements);
132 }
133
134 template <class name_t>
135 bool Awrite(const name_t&AttributeName, const int32_t*data, size_t Elements) const
136 {
137 return Awrite( AttributeName, H5T_NATIVE_INT32, data, Elements);
138 }
139
140 template <class name_t>
141 bool Awrite(const name_t&AttributeName, const int64_t*data, size_t Elements) const
142 {
143 return Awrite( AttributeName, H5T_NATIVE_INT64, data, Elements);
144 }
145
146
147 template <class name_t>
148 bool Awrite(const name_t&AttributeName, const uint16_t*data, size_t Elements) const
149 {
150 return Awrite( AttributeName, H5T_NATIVE_UINT16, data, Elements);
151 }
152
153 template <class name_t>
154 bool Awrite(const name_t&AttributeName, const uint32_t*data, size_t Elements) const
155 {
156 return Awrite( AttributeName, H5T_NATIVE_UINT32, data, Elements);
157 }
158
159 template <class name_t>
160 bool Awrite(const name_t&AttributeName, const uint64_t*data, size_t Elements) const
161 {
162 return Awrite( AttributeName, H5T_NATIVE_UINT64, data, Elements);
163 }
164
165 template <class name_t>
166 bool Awrite(const name_t&AttributeName, const double*data, size_t Elements = 1) const
167 {
168 return Awrite( AttributeName, H5T_NATIVE_DOUBLE, data, Elements);
169 }
170
171 template <class name_t, class value_type>
172 bool Awrite(const name_t&AttributeName, const value_type&value) const
173 {
174 return Awrite( AttributeName, &value, 1);
175 }
176
177
178 template <class T>
179 bool Awrite(const std::string&AttributeName, const std::vector<T>&data) const
180 {
181 return Awrite( AttributeName, &*data.begin(), data.size());
182 }
183
184 bool Awrite(const char*AttributeName, const std::string&data) const;
185 bool Awrite(const std::string&AttributeName, const std::string&data) const
186 {
187 return Awrite(AttributeName.c_str(), data);
188 }
189};
190
191
192
193
194
195#endif // __H5_OBJECT_HPP
196
Base class for groups, datasets and named datatypes.
Definition H++/H5Object.hpp:122
Definition H++with_cache_image/H5Object.hpp:55
Definition H++with_cache_image/H5Object.hpp:27