base_cycle_metric.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <algorithm>
15 
16 
17 namespace illumina { namespace interop { namespace model { namespace metric_base
18 {
21  {
22  public:
25  public:
27  base_cycle_metric_header() : m_max_cycle(0)
28  { }
29 
30  public:
36  {
37  return base_cycle_metric_header();
38  }
39 
40  public:
46  { return m_max_cycle; }
49  void clear()
50  {
51  m_max_cycle=0;
52  }
53 
54  protected:
59  template<class Metric>
60  inline void update_max_cycle(const Metric &metric)
61  {
62  m_max_cycle = std::max(m_max_cycle, metric.cycle());
63  }
64 
65  private:
67  base_metric::uint_t m_max_cycle;
68  };
74  {
75  public:
82  typedef uint16_t cycle_t;
83  public:
90  base_cycle_metric(const uint_t lane=0, const uint_t tile=0, const uint_t cycle=0) :
91  base_metric(lane, tile), m_cycle(static_cast<cycle_t>(cycle))
92  { }
93 
94  public:
101  void set_base(const uint_t lane, const uint_t tile)
102  {
103  base_metric::set_base(lane, tile);
104  }
111  void set_base(const uint_t lane, const uint_t tile, const uint_t cycle)
112  {
113  base_metric::set_base(lane, tile);
114  m_cycle = static_cast<cycle_t>(cycle);
115  }
120  template<class BaseCycleMetric>
121  void set_base(const BaseCycleMetric &base)
122  {
123  base_metric::set_base(base);
124  m_cycle = static_cast<cycle_t>(base.cycle);
125  }
126 
131  uint_t cycle() const
132  { return m_cycle; }
133 
138  id_t id() const
139  {
140  return create_id(lane(), tile(), m_cycle);
141  }
146  id_t cycle_hash() const
147  {
148  return create_id(lane(), tile(), m_cycle);
149  }
155  static id_t cycle_from_id(const id_t id)
156  {
157  // 1. Shift off lane and tile bits
158  // 2. Shift back, while shifting off reserved bits
160  }
166  static id_t reserved_from_id(const id_t id)
167  {
168  // 1. Shift off lane, tile and cycle bits
169  // 2. Shift back
171  }
172 
180  static id_t create_id(const id_t lane, const id_t tile, const id_t cycle)
181  {
182  return base_metric::create_id(lane, tile) | (cycle << CYCLE_BIT_SHIFT);
183  }
184 
190  bool operator< (const base_cycle_metric& metric2) const
191  {
192  return id() < metric2.id();
193  }
194 
195  private:
196  cycle_t m_cycle;
197  };
198 
199 
200 
202  template<>
203  struct metric_attributes<base_cycle_metric> : public metric_attributes<base_metric>{};
204 
205 }}}}
206 
207 
::uint32_t uint_t
Definition: base_metric.h:144
uint16_t cycle_t
Definition: base_cycle_metric.h:82
::uint32_t id_t
Definition: base_metric.h:74
Definition: enum_description.h:15
void update_max_cycle(const Metric &metric)
Definition: base_cycle_metric.h:60
uint_t tile() const
Definition: base_metric.h:284
static id_t reserved_from_id(const id_t id)
Definition: base_cycle_metric.h:166
void set_base(const uint_t lane, const uint_t tile)
Definition: base_metric.h:188
constants::base_cycle_t base_t
Definition: base_cycle_metric.h:80
base_cycle_metric(const uint_t lane=0, const uint_t tile=0, const uint_t cycle=0)
Definition: base_cycle_metric.h:90
uint_t cycle() const
Definition: base_cycle_metric.h:131
static id_t create_id(const id_t lane, const id_t tile, const id_t cycle)
Definition: base_cycle_metric.h:180
static id_t create_id(const id_t lane, const id_t tile, const id_t=0)
Definition: base_metric.h:229
static base_cycle_metric_header default_header()
Definition: base_cycle_metric.h:35
void set_base(const BaseCycleMetric &base)
Definition: base_cycle_metric.h:121
base_cycle_metric_header header_type
Definition: base_cycle_metric.h:78
Definition: type_traits.h:131
::uint32_t uint_t
Definition: base_metric.h:77
id_t cycle_hash() const
Definition: base_cycle_metric.h:146
base_metric::uint_t max_cycle() const
Definition: base_cycle_metric.h:45
uint_t lane() const
Definition: base_metric.h:269
constants::base_cycle_t base_t
Definition: base_cycle_metric.h:24
static id_t cycle_from_id(const id_t id)
Definition: base_cycle_metric.h:155
void set_base(const uint_t lane, const uint_t tile)
Definition: base_cycle_metric.h:101
id_t id() const
Definition: base_cycle_metric.h:138
bool operator<(const base_cycle_metric &metric2) const
Definition: base_cycle_metric.h:190
base_cycle_metric_header()
Definition: base_cycle_metric.h:27
void set_base(const uint_t lane, const uint_t tile, const uint_t cycle)
Definition: base_cycle_metric.h:111