plot_metric_proxy.h
Go to the documentation of this file.
1 
10 #pragma once
14 
15 namespace illumina { namespace interop { namespace logic { namespace plot
16 {
17 
22  {
25  public:
34  template<typename Plot>
35  static void select(const model::metrics::run_metrics& metrics,
36  const model::plot::filter_options& options,
37  const constants::metric_type type,
38  Plot& plot)
39  {
40  switch(type)
41  {
42 # define INTEROP_TUPLE7(Enum, Unused1, Unused2, Unused3, Metric, Method, Param) \
43  case constants:: Enum:\
44  select_metric_##Method##Param(metrics.get< model::metrics:: Metric >(),\
45  options, options.channel(),\
46  options.dna_base(),\
47  options.read(), plot);\
48  break;//
49 # define INTEROP_TUPLE4(Unused1, Unused2, Unused3, Unused4)
50 # define INTEROP_TUPLE1(Unused1)
52 # undef INTEROP_TUPLE4 // Reuse this for another conversion
53 # undef INTEROP_TUPLE7 // Reuse this for another conversion
54 # undef INTEROP_TUPLE1
55  default:
56  INTEROP_THROW(model::invalid_metric_type, "Invalid metric group: " << constants::to_string(type));
57  };
58  }
65  static bool is_present(const model::metrics::run_metrics& metrics,
66  const constants::metric_type type)
67  {
68  switch(type)
69  {
70 # define INTEROP_TUPLE7(Enum, Unused1, Unused2, Unused3, Metric, Method, Param) \
71  case constants:: Enum:\
72  return is_metric_present_##Method##Param(metrics.get< model::metrics:: Metric >(), 0u, \
73  constants::A, 1u);//
74 # define INTEROP_TUPLE4(Unused1, Unused2, Unused3, Unused4)
75 # define INTEROP_TUPLE1(Unused1)
77 # undef INTEROP_TUPLE4 // Reuse this for another conversion
78 # undef INTEROP_TUPLE7 // Reuse this for another conversion
79 # undef INTEROP_TUPLE1
80  default:
81  return false;
82  };
83  }
84 
85  private:
86 # define INTEROP_TUPLE7(Enum, Unused1, Unused2, Unused3, Metric, Method, Param) \
87  template<typename Plot>\
88  static void select_metric_##Method##Param(const model::metric_base::metric_set< model::metrics:: Metric >& metrics,\
89  const model::plot::filter_options& options,\
90  const size_t channel, \
91  const constants::dna_bases base,\
92  const id_t read,\
93  Plot& plot)\
94  {\
95  const util::op::dummy_arg Void;\
96  (void)channel;(void)base;(void)read;(void)Void;\
97  plot(metrics, options, util::op::const_member_function(Param, &model::metrics:: Metric::Method));\
98  }
99 # define INTEROP_TUPLE4(Unused1, Unused2, Unused3, Unused4)
100 # define INTEROP_TUPLE1(Unused1)
102 # undef INTEROP_TUPLE7 // Reuse this for another conversion
103 # undef INTEROP_TUPLE4 // Reuse this for another conversion
104 # undef INTEROP_TUPLE1
105 
106  private:
107 # define INTEROP_TUPLE7(Enum, Unused1, Unused2, Unused3, Metric, Method, Param) \
108  static bool is_metric_present_##Method##Param(const model::metric_base::metric_set< model::metrics:: Metric >& metrics,\
109  const size_t channel, \
110  const constants::dna_bases base,\
111  const id_t read)\
112  {\
113  const util::op::dummy_arg Void;\
114  (void)channel;(void)base;(void)read;(void)Void;\
115  return is_metric_present_in(metrics, util::op::const_member_function(Param, &model::metrics:: Metric::Method));\
116  }
117 # define INTEROP_TUPLE4(Unused1, Unused2, Unused3, Unused4)
118 # define INTEROP_TUPLE1(Unused1)
120 # undef INTEROP_TUPLE7 // Reuse this for another conversion
121 # undef INTEROP_TUPLE4 // Reuse this for another conversion
122 # undef INTEROP_TUPLE1
123  template<class MetricSet, typename Func>
124  static bool is_metric_present_in(const MetricSet& metricset, Func proxy)
125  {
126  for(typename MetricSet::const_iterator it = metricset.begin(); it != metricset.end();++it)
127  {
128  if(is_valid(proxy(*it))) return true;
129  }
130  return false;
131  }
132 
138  static bool is_valid(const float val)
139  {
140  return !std::isnan(val);
141  }
142 
148  template<typename T>
149  static bool is_valid(const T val)
150  {
151  return val < std::numeric_limits<T>::max();
152  }
153  };
154 
155 }}}}
::uint32_t uint_t
Definition: base_metric.h:144
Definition: filter_options.h:28
metric_type
Definition: enums.h:284
Definition: enum_description.h:15
Definition: plot_metric_proxy.h:21
#define INTEROP_THROW(EXCEPTION, MESSAGE)
Definition: exception.h:18
Definition: model_exceptions.h:38
static bool is_present(const model::metrics::run_metrics &metrics, const constants::metric_type type)
Definition: plot_metric_proxy.h:65
Definition: enums.h:301
static void select(const model::metrics::run_metrics &metrics, const model::plot::filter_options &options, const constants::metric_type type, Plot &plot)
Definition: plot_metric_proxy.h:35
#define INTEROP_ENUM_METRIC_TYPES
Definition: enums.h:42
std::string to_string(Enum value)
Definition: enums.h:43