Particle Identification and Tracking
md_store.h
Go to the documentation of this file.
1 //Copyright 2010,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 //If you modify this Program, or any covered work, by linking or
27 //combining it with IPP (or a modified version of that library),
28 //containing parts covered by the terms of End User License Agreement
29 //for the Intel(R) Software Development Products, the licensors of
30 //this Program grant you additional permission to convey the resulting
31 //work.
32 //
33 //If you modify this Program, or any covered work, by linking or
34 //combining it with FreeImage (or a modified version of that library),
35 //containing parts covered by the terms of End User License Agreement
36 //for FreeImage Public License, the licensors of
37 //this Program grant you additional permission to convey the resulting
38 //work.
39 
40 #ifndef MD_STORE
41 #define MD_STORE
42 
43 #include <string>
44 #include <vector>
45 #include "enum_utils.h"
46 namespace utilities
47 {
48 class Attr_list_hdf;
49 
53 class Md_store
54 {
55 public:
56 
65  template <class T>
66  T get_value(const std::string & attr_name,T & val)const;
67 
68 
75  template <class T>
76  void set_value(const std::string & attr_name,const T & val,bool over_write = true);
77 
78 
83  float get_value(int j,float & val)const;
88  int get_value(int j,int & val)const;
93  unsigned int get_value(int j,unsigned int & val)const;
94 
99  std::string get_value(int j,std::string & val)const;
100 
105  bool get_value(int j,bool & val)const;
106 
107 
108 
114  bool remove_key(const std::string & key);
115 
119  bool contains_key(const std::string& key)const;
120 
121 
130  bool contains_key(const std::string& key,unsigned int & indx)const;
131 
135  int get_key_index(const std::string& key)const;
136 
140  unsigned int size() const
141  {
142  return entries_.size();
143  }
144 
148  std::string get_key(int j) const
149  {
150  return entries_.at(j).key;
151  }
156  {
157  return entries_.at(j).type;
158  }
159 
163  void * get_val(int j)const
164  {
165  return entries_.at(j).value;
166  }
167 
168 
170 
175  void add_element(const std::string & key,const std::string & type,const std::string & value);
176  void add_element(const char * key,const char * type, const char * value);
177  void add_element(const char * key,float val);
178  void add_element(const char * key,int val);
179  void add_element(const char * key,unsigned int val);
180  void add_element(const char * key,bool val);
181  void add_element(const char * key,const char * val);
182  void add_element(const char * key,const std::string &val);
184 
187  void add_elements(const Md_store * md_in);
188 
189 
193  void print()const;
194 
198  ~Md_store();
199 
203  Md_store();
204 
209 
210 private:
215  struct Md_element
216  {
220  Md_element(std::string key_i,utilities::V_TYPE type_i,void * value_i)
221  :key(key_i),type(type_i),value(value_i){}
225  Md_element(const char * key_i,utilities::V_TYPE type_i,void * value_i)
226  :key(key_i),type(type_i),value(value_i){}
227 
231  Md_element(const Md_element &);
235  Md_element & operator =(const Md_element &);
239  Md_element();
243  ~Md_element();
244 
248  std::string key;
256  void * value;
257 
258 
259  };
260 
261 
262 
266  std::vector<Md_element> entries_;
267  };
268 
269 
270 }
271 
272 
273 
274 
275 
276 
277 #endif