ICP  1
item_struct.h
Go to the documentation of this file.
1 #ifndef ITEM_STRUCT_H
2 #define ITEM_STRUCT_H
3 
4 class DAEstatus;
5 
6 template<typename T>
8 {
9 public:
10  struct item_t
11  {
12  const T* value;
13  bool det_average; // can be averaged over detectors via m_spec_array
14  const int* dim0;
15  const int* dim1;
16  item_t(const T* v, bool da, const int* d0, const int* d1) : value(v), det_average(da), dim0(d0), dim1(d1) {}
17  };
18 
19 private:
20  typedef std::map<std::string, item_t> items_map_t;
22  unsigned long* m_spec_array; // length m_ndet; used for averaging values with det_average
23  long m_ndet;
24 public:
25 
26  int addItem(const std::string& name, const T* value, bool det_average = false, const int* dim0 = NULL, const int* dim1 = NULL)
27  {
28  std::pair<items_map_t::iterator, bool> insert_ret;
29  insert_ret = m_items.insert(items_map_t::value_type(name, item_t(value, det_average, dim0, dim1)));
30  if (!insert_ret.second)
31  {
32  return -1; // duplicate
33  }
34  else
35  {
36  return 0;
37  }
38  }
39 
40  const item_t* findItem(const std::string& item_name, bool det_average)
41  {
42  items_map_t::const_iterator iter;
43  iter = m_items.find(item_name);
44  if ( (iter != m_items.end()) && (iter->second.det_average == det_average) )
45  {
46  return &(iter->second);
47  }
48  else
49  {
50  return NULL
51  }
52  }
53 
54  int getItem(const std::string& item_name, T& value, DAEstatus& status);
55  int getItem(const std::string& item_name, long* spec_array, int nspec, T* lVal, DAEstatus& status);
56  int getArrayItemSize(const std::string& item_name, int* dims_array, int& ndims, DAEstatus& status);
57  int getArrayItem(const std::string& item_name, long* spec_array, int nspec, T* larray, DAEstatus& status);
58  int getArrayItem(const std::string& item_name, T* larray, DAEstatus& status);
59 };
60 
61 #endif /* ITEM_STRUCT_H */
int getArrayItemSize(const std::string &item_name, int *dims_array, int &ndims, DAEstatus &status)
Definition: item_struct.cpp:87
std::map< std::string, item_t > items_map_t
Definition: item_struct.h:20
const int * dim0
Definition: item_struct.h:14
item_t(const T *v, bool da, const int *d0, const int *d1)
Definition: item_struct.h:16
const int * dim1
Definition: item_struct.h:15
int getArrayItem(const std::string &item_name, long *spec_array, int nspec, T *larray, DAEstatus &status)
const item_t * findItem(const std::string &item_name, bool det_average)
Definition: item_struct.h:40
int getItem(const std::string &item_name, T &value, DAEstatus &status)
Definition: item_struct.cpp:5
items_map_t m_items
Definition: item_struct.h:21
unsigned long * m_spec_array
Definition: item_struct.h:22
int addItem(const std::string &name, const T *value, bool det_average=false, const int *dim0=NULL, const int *dim1=NULL)
Definition: item_struct.h:26