Particle Identification and Tracking
generic_wrapper_hdf.h
Go to the documentation of this file.
1 //Copyright 2009-2012 Thomas A Caswell
2 //tcaswell@uchicago.edu
3 //http://jfi.uchicago.edu/~tcaswell
4 //
5 //This program is free software; you can redistribute it and/or modify
6 //it under the terms of the GNU General Public License as published by
7 //the Free Software Foundation; either version 3 of the License, or (at
8 //your option) any later version.
9 //
10 //This program is distributed in the hope that it will be useful, but
11 //WITHOUT ANY WARRANTY; without even the implied warranty of
12 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 //General Public License for more details.
14 //
15 //You should have received a copy of the GNU General Public License
16 //along with this program; if not, see <http://www.gnu.org/licenses>.
17 //
18 //Additional permission under GNU GPL version 3 section 7
19 //
20 //If you modify this Program, or any covered work, by linking or
21 //combining it with MATLAB (or a modified version of that library),
22 //containing parts covered by the terms of MATLAB User License, the
23 //licensors of this Program grant you additional permission to convey
24 //the resulting work.
25 
26 
27 #ifndef GWRAPPER_HDF
28 #define GWRAPPER_HDF
29 
30 #include "generic_wrapper.h"
31 namespace H5
32 {
33 class H5File;
34 class Group;
35 class DataType;
36 }
37 
38 
39 namespace utilities{
40 
41 class Attr_list_hdf;
42 
48 public:
52  typedef enum F_TYPE{
61  } F_TYPE;
62 
69  void open_wrapper();
70 
71  void close_wrapper();
72  bool is_open()const
73  {
74  return wrapper_open_;
75  }
77 
84  void open_group(const std::string & name = "none");
85  void close_group();
87 
93 
94  void add_dset(int rank, const unsigned int * dims, V_TYPE , const void *,const std::string & name );
95 
96  void get_dset(std::vector<int> & data,std::vector<unsigned int> & dims, const std::string & dset_name) const;
97  void get_dset(std::vector<unsigned int> & data, std::vector<unsigned int> & dims,const std::string & dset_name) const;
98  void get_dset(std::vector<float> & data, std::vector<unsigned int> & dims, const std::string & dset_name) const;
99 
100  void get_dset_info(std::vector<int> & dims,V_TYPE& vt ,const std::string & dset_name) const;
101 
102 
104 
112  void add_meta_data(const std::string & key, float val);
113  void add_meta_data(const std::string & key, const Tuple<float,3> & val);
114  void add_meta_data(const std::string & key, const Tuple<float,2>& val);
115  void add_meta_data(const std::string & key, const std::string & val);
116  void add_meta_data(const std::string & key, int val);
117  void add_meta_data(const std::string & key, unsigned int val);
118  void add_meta_data(const Md_store * md_store);
119 
120  float get_meta_data(const std::string & key, float & val);
121  Tuple<float,3> get_meta_data(const std::string & key, Tuple<float,3> & val);
122  Tuple<float,2> get_meta_data(const std::string & key, Tuple<float,2>& val);
123  std::string get_meta_data(const std::string & key, std::string & val);
124  int get_meta_data(const std::string & key, int & val);
125  unsigned int get_meta_data(const std::string & key, unsigned int& val);
126  Md_store& get_meta_data(Md_store & md_store);
128 
135 
136  void add_meta_data(const std::string & key, float val,const std::string & dset_name);
137  void add_meta_data(const std::string & key, const Tuple<float,3> & val,const std::string & dset_name);
138  void add_meta_data(const std::string & key, const Tuple<float,2>& val,const std::string & dset_name);
139  void add_meta_data(const std::string & key, const std::string & val,const std::string & dset_name);
140  void add_meta_data(const std::string & key, int val,const std::string & dset_name);
141  void add_meta_data(const std::string & key, unsigned int val,const std::string & dset_name);
142  void add_meta_data(const Md_store * md_store,const std::string & dset_name);
143 
144  float get_meta_data(const std::string & key, float& val,const std::string & dset_name);
145  Tuple<float,3> get_meta_data(const std::string & key, Tuple<float,3> & val,const std::string & dset_name);
146  Tuple<float,2> get_meta_data(const std::string & key, Tuple<float,2>& val,const std::string & dset_name);
147  std::string get_meta_data(const std::string & key, std::string & val,const std::string & dset_name);
148  int get_meta_data(const std::string & key, int &val,const std::string & dset_name);
149  Md_store & get_meta_data(Md_store & md_store,const std::string & dset_name);
151 
153 
162  Generic_wrapper_hdf(std::string fname, F_TYPE f_type = F_DISK_RDWR);
163 
164 private:
168  template<class T>
169  void add_meta_data_priv(const std::string & key, const T & val,const std::string & dset_name);
173  template<class T>
174  void add_meta_data_priv(const std::string & key, const T& val);
178  template<class T>
179  T get_meta_data_priv(const std::string & key, T & val,const std::string & dset_name);
183  template<class T>
184  T get_meta_data_priv(const std::string & key, T& val);
185 
186 
190  template <class T>
191  void get_dset_priv(std::vector<T> & data,std::vector<unsigned int> & dims, const std::string & dset_name,const H5::DataType & mtype) const;
192 
193 
194 
195  std::string file_name_;
196 
197 
198 
202 
204 
205 
206  H5::H5File *file_;
207  H5::Group * group_;
208 
210 
211 
212 
213 
214 };
215 }
216 #endif