enums.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <map>
12 #include "interop/util/length_of.h"
13 
15 #define INTEROP_TUPLE1(X) name_type_pair_t(#X,X)
16 
17 #define INTEROP_TUPLE_ASSIGN(X, IGNORED_1) name_type_pair_t(#X,X)
18 
19 #define INTEROP_TUPLE2(X, IGNORED_1) name_type_pair_t(#X,X)
20 
21 #define INTEROP_TUPLE3(X, IGNORED_1, IGNORED_2) name_type_pair_t(#X,X)
22 
23 #define INTEROP_TUPLE4(X, IGNORED_1, IGNORED_2, IGNORED_3) name_type_pair_t(#X,X),
24 
25 #define INTEROP_TUPLE7(X, IGNORED_1, IGNORED_2, IGNORED_3, IGNORED_4, IGNORED_5, IGNORED_6) name_type_pair_t(#X,X),
26 
27 
28 namespace illumina { namespace interop { namespace constants
29 {
34  template<typename Enum>
36 
42  template<typename Enum>
43  std::string to_string(Enum value)
44  {
46  typedef enumeration_string_mapping<Enum> enum_map_t;
47  return enum_map_t::template setup<const mapping_t&>(mapping_t::rmapping).get(value, std::string("Unknown"));
48  }
49 
55  template<typename Enum>
56  Enum parse(const std::string& name)
57  {
59  typedef enumeration_string_mapping<Enum> enum_map_t;
60  return enum_map_t::template setup<const mapping_t&>(mapping_t::fmapping).get(name, static_cast<Enum>(Unknown));
61  }
62  namespace detail
63  {
65  template<typename Enum>
67  {
73  fill_enum_vector(std::vector<Enum> &vec1, const size_t start=0) : m_vec(vec1), m_start(start) { }
79  void operator()(const std::pair<std::string, Enum> *vals, const size_t n) const
80  {
81  m_vec.resize(n-m_start);
82  for (size_t i = m_start; i < n; ++i)
83  m_vec[i-m_start] = vals[i].second;
84  }
85  private:
86  std::vector<Enum> &m_vec;
87  const size_t m_start;
88  };
90  template<typename Enum>
92  {
98  fill_enum_name_vector(std::vector<std::string> &vec1, const size_t start=0) : m_vec(vec1), m_start(start) { }
104  void operator()(const std::pair<std::string, Enum> *vals, const size_t n) const
105  {
106  m_vec.resize(n-m_start);
107  for (size_t i = m_start; i < n; ++i)
108  m_vec[i-m_start] = vals[i].first;
109  }
110  private:
111  std::vector<std::string> &m_vec;
112  const size_t m_start;
113  };
114  }
120  template<typename Enum>
121  void list_enums(std::vector<Enum>& vec, const size_t skip=0)
122  {
123  typedef enumeration_string_mapping<Enum> enum_map_t;
124  enum_map_t::template setup<void>(detail::fill_enum_vector<Enum>(vec, skip));
125  }
131  template<typename Enum>
132  void list_enum_names(std::vector<std::string>& vec, const size_t skip=0)
133  {
134  typedef enumeration_string_mapping<Enum> enum_map_t;
135  enum_map_t::template setup<void>(detail::fill_enum_name_vector<Enum>(vec, skip));
136  }
137 
139  template<>
141  {
142  typedef std::pair<std::string, metric_type> name_type_pair_t;
143  public:
149  template<typename R, typename F>
150  static R setup(F func)
151  {
152  static const name_type_pair_t name_types[] = {INTEROP_ENUM_METRIC_TYPES};
153  return func(name_types, util::length_of(name_types));
154  }
155  };
156 
158  template<>
160  {
161  typedef std::pair<std::string, tile_naming_method> name_type_pair_t;
162  public:
168  template<typename R, typename F>
169  static R setup(F func)
170  {
171  static const name_type_pair_t name_types[] = {INTEROP_ENUM_TILE_NAMING_METHODS};
172  return func(name_types, util::length_of(name_types));
173  }
174  };
176  template<>
178  {
179  typedef std::pair<std::string, surface_type> name_type_pair_t;
180  public:
186  template<typename R, typename F>
187  static R setup(F func)
188  {
189  static const name_type_pair_t name_types[] = {INTEROP_ENUM_SURFACE_TYPES};
190  return func(name_types, util::length_of(name_types));
191  }
192  };
194  template<>
196  {
197  typedef std::pair<std::string, dna_bases> name_type_pair_t;
198  public:
204  template<typename R, typename F>
205  static R setup(F func)
206  {
207  static const name_type_pair_t name_types[] = {INTEROP_ENUM_DNA_BASE_TYPES};
208  return func(name_types, util::length_of(name_types));
209  }
210  };
212  template<>
214  {
215  typedef std::pair<std::string, instrument_type> name_type_pair_t;
216  public:
222  template<typename R, typename F>
223  static R setup(F func)
224  {
225  static const name_type_pair_t name_types[] = {INTEROP_ENUM_INSTRUMENT_TYPES};
226  return func(name_types, util::length_of(name_types));
227  }
228  };
230  template<>
232  {
233  typedef std::pair<std::string, plot_colors> name_type_pair_t;
234  public:
240  template<typename R, typename F>
241  static R setup(F func)
242  {
243  static const name_type_pair_t name_types[] = {INTEROP_ENUM_PLOT_COLORS};
244  return func(name_types, util::length_of(name_types));
245  }
246  };
248  template<>
250  {
251  typedef std::pair<std::string, metric_group> name_type_pair_t;
252  public:
258  template<typename R, typename F>
259  static R setup(F func)
260  {
261  static const name_type_pair_t name_types[] = {INTEROP_ENUM_METRIC_GROUPS};
262  return func(name_types, util::length_of(name_types));
263  }
264  };
266  template<>
268  {
269  typedef std::pair<std::string, metric_data> name_type_pair_t;
270  public:
276  template<typename R, typename F>
277  static R setup(F func)
278  {
279  static const name_type_pair_t name_types[] = {INTEROP_ENUM_METRIC_DATA_TYPES};
280  return func(name_types, util::length_of(name_types));
281  }
282  };
284  template<>
286  {
287  typedef std::pair<std::string, bar_plot_options> name_type_pair_t;
288  public:
294  template<typename R, typename F>
295  static R setup(F func)
296  {
297  static const name_type_pair_t name_types[] = {INTEROP_ENUM_BAR_PLOT_OPTIONS};
298  return func(name_types, util::length_of(name_types));
299  }
300  };
302  template<>
304  {
305  typedef std::pair<std::string, metric_feature_type> name_type_pair_t;
306  public:
312  template<typename R, typename F>
313  static R setup(F func)
314  {
315  static const name_type_pair_t name_types[] = {INTEROP_ENUM_METRIC_FEATURE_TYPE};
316  return func(name_types, util::length_of(name_types));
317  }
318  };
319 
322  template<>
324  {
325  typedef std::pair<std::string, plot_types > name_type_pair_t;
326  public:
332  template<typename R, typename F>
333  static R setup(F func)
334  {
335  static const name_type_pair_t name_types[] = {INTEROP_ENUM_PLOT_TYPES};
336  return func(name_types, util::length_of(name_types));
337  }
338  };
339 
342  template<>
344  {
345  typedef std::pair<std::string, metric_base_type > name_type_pair_t;
346  public:
352  template<typename R, typename F>
353  static R setup(F func)
354  {
355  static const name_type_pair_t name_types[] = {INTEROP_ENUM_METRIC_BASE_TYPES};
356  return func(name_types, util::length_of(name_types));
357  }
358  };
359 
360 }}}
361 
362 #undef INTEROP_TUPLE1
363 #undef INTEROP_TUPLE2
364 #undef INTEROP_TUPLE3
365 #undef INTEROP_TUPLE4
366 #undef INTEROP_TUPLE7
367 
metric_base_type
Definition: enums.h:314
#define INTEROP_ENUM_METRIC_DATA_TYPES
Definition: enums.h:100
#define INTEROP_ENUM_BAR_PLOT_OPTIONS
Definition: enums.h:241
metric_type
Definition: enums.h:284
Definition: enum_description.h:15
#define INTEROP_ENUM_METRIC_FEATURE_TYPE
Definition: enums.h:26
void operator()(const std::pair< std::string, Enum > *vals, const size_t n) const
Definition: enums.h:79
#define INTEROP_ENUM_PLOT_COLORS
Definition: enums.h:203
bar_plot_options
Definition: enums.h:324
plot_types
Definition: enums.h:339
#define INTEROP_ENUM_INSTRUMENT_TYPES
Definition: enums.h:166
#define INTEROP_ENUM_SURFACE_TYPES
Definition: enums.h:154
metric_group
Definition: enums.h:289
Definition: constant_mapping.h:54
#define INTEROP_ENUM_METRIC_BASE_TYPES
Definition: enums.h:183
metric_feature_type
Definition: enums.h:334
#define INTEROP_ENUM_METRIC_GROUPS
Definition: enums.h:77
void list_enum_names(std::vector< std::string > &vec, const size_t skip=0)
Definition: enums.h:132
void operator()(const std::pair< std::string, Enum > *vals, const size_t n) const
Definition: enums.h:104
#define INTEROP_ENUM_PLOT_TYPES
Definition: enums.h:220
metric_data
Definition: enums.h:329
fill_enum_name_vector(std::vector< std::string > &vec1, const size_t start=0)
Definition: enums.h:98
#define INTEROP_ENUM_DNA_BASE_TYPES
Definition: enums.h:131
#define INTEROP_ENUM_TILE_NAMING_METHODS
Definition: enums.h:114
fill_enum_vector(std::vector< Enum > &vec1, const size_t start=0)
Definition: enums.h:73
size_t length_of(const T &val)
Definition: length_of.h:55
#define INTEROP_ENUM_METRIC_TYPES
Definition: enums.h:42
instrument_type
Definition: enums.h:309
tile_naming_method
Definition: enums.h:294
dna_bases
Definition: enums.h:299
void list_enums(std::vector< Enum > &vec, const size_t skip=0)
Definition: enums.h:121
Enum parse(const std::string &name)
Definition: enums.h:56
std::string to_string(Enum value)
Definition: enums.h:43
plot_colors
Definition: enums.h:319
surface_type
Definition: enums.h:304