metric_test.h
Go to the documentation of this file.
1 
9 #pragma once
10 #include <string>
11 #include <vector>
13 #include "interop/model/run/info.h"
15 #include "interop/util/length_of.h"
16 
17 namespace illumina{ namespace interop { namespace unittest {
18 
21  template<class T, size_t Size>
22  struct sparse_value
23  {
29  sparse_value(size_t o, T v) : offset(o), value(v)
30  { }
31 
33  size_t offset;
36  };
37 
40  template<class Metric, int Version, char Variant=0>
42  {
43  public:
44  enum Checks
45  {
47  VERSION=Version,
54  };
55  public:
57  typedef Metric metric_t;
61  typedef typename metric_t::header_type header_t;
64 
65  public:
70  static std::string name()
71  {
72  return std::string() +
73  Metric::prefix()+
74  Metric::suffix()+
75  util::lexical_cast<std::string>(VERSION) + ((Variant>0) ? Variant : ' ');
76  }
84  template<typename T, size_t N>
85  static std::vector<T> to_vector(const T (&vals)[N])
86  {
87  return std::vector<T>(vals, vals + N);
88  }
96  template<typename T, size_t N, size_t Size>
97  static std::vector<T> to_vector(const sparse_value<T, Size> (&vals)[N])
98  {
99  std::vector<T> vec(Size, 0);
100  for (size_t i = 0; i < N; i++)
101  vec[vals[i].offset] = vals[i].value;
102  return vec;
103  }
104  };
105 
106 }}}
107 
Definition: enum_description.h:15
static std::vector< T > to_vector(const T(&vals)[N])
Definition: metric_test.h:85
metric_set_t::const_iterator const_iterator
Definition: metric_test.h:63
static std::string name()
Definition: metric_test.h:70
Metric metric_t
Definition: metric_test.h:57
size_t offset
Definition: metric_test.h:33
Definition: metric_test.h:41
model::metric_base::metric_set< Metric > metric_set_t
Definition: metric_test.h:59
sparse_value(size_t o, T v)
Definition: metric_test.h:29
Definition: metric_test.h:22
Definition: enums.h:301
metric_t::header_type header_t
Definition: metric_test.h:61
T value
Definition: metric_test.h:35
Destination lexical_cast(const Source &src)
Definition: lexical_cast.h:264
static std::vector< T > to_vector(const sparse_value< T, Size >(&vals)[N])
Definition: metric_test.h:97
metric_array_t::const_iterator const_iterator
Definition: metric_set.h:77