format_registry.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <set>
10 #include <vector>
11 #include <map>
12 #include <string>
15 
16 #ifdef _MSC_VER
17 #pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants
18 #endif
19 
20 namespace illumina{ namespace interop { namespace unittest
21 {
24  {
25  typedef std::set<int> version_set_t;
26  typedef std::vector<std::string> key_vector_t;
27  typedef std::map<std::string, version_set_t > format_map_t;
28  public:
30  typedef key_vector_t::const_iterator const_key_iterator;
31 
32  public:
39  template<class MetricType>
40  void operator()(const MetricType&, int version)
41  {
42  const std::string name = io::paths::interop_basename<MetricType>();
43  if(io::is_deprecated<MetricType>(version)) return;
44  if(m_format_map.find(name) == m_format_map.end())
45  {
46  m_format_map[name] = version_set_t();
47  m_keys.push_back(name);
48  }
49  m_format_map[name].insert(version);
50  }
55  template<class MetricSet>
56  void operator()(const MetricSet&)
57  {
58  typedef typename MetricSet::metric_type metric_t;
59  // Dyanmic phasing does not have a read or write format
60  // QByLane uses the same format as QMetrics
61  // Neither of these is tested
62  const constants::metric_group group = static_cast<constants::metric_group>(MetricSet::TYPE);
63  if(group == constants::DynamicPhasing || group == constants::QByLane)
64  return;
65  const std::string name = io::paths::interop_basename<metric_t>();
66  if(m_format_map.find(name) == m_format_map.end())
67  {
68  m_format_map[name] = version_set_t();
69  m_keys.push_back(name);
70  }
71  io::copy_versions<metric_t>(std::inserter(m_format_map[name], m_format_map[name].begin()));
72  }
74  format_map_t m_format_map;
76  key_vector_t m_keys;
77  };
78 
80  template<template<class>class T>
82  {
88  {
89  static format_registry _instance;
90  return _instance;
91  }
92  };
93 }}}
94 
95 
key_vector_t::const_iterator const_key_iterator
Definition: format_registry.h:30
metric_type
Definition: enums.h:284
Definition: enum_description.h:15
Definition: format_registry.h:81
metric_group
Definition: enums.h:289
key_vector_t m_keys
Definition: format_registry.h:76
static format_registry & instance()
Definition: format_registry.h:87
Definition: enums.h:301
void operator()(const MetricSet &)
Definition: format_registry.h:56
Definition: format_registry.h:23
format_map_t m_format_map
Definition: format_registry.h:74
void operator()(const MetricType &, int version)
Definition: format_registry.h:40