cycle_range.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <limits>
11 #include "interop/util/assert.h"
13 
14 namespace illumina { namespace interop { namespace model { namespace run
15 {
16 
21  {
22  public:
24  typedef size_t cycle_t;
25  public:
31  cycle_range(const cycle_t first_cycle = std::numeric_limits<cycle_t>::max(), const cycle_t last_cycle = 0) :
34  {
35  }
36 
37  public:
50  cycle_t first_cycle() const
51  {
52  if (empty()) return 0;
53  return m_first_cycle;
54  }
55 
60  cycle_t last_cycle() const
61  {
62  return m_last_cycle;
63  }
64 
69  void first_cycle(const cycle_t val)
70  {
71  m_first_cycle = val;
72  }
73 
78  void last_cycle(const cycle_t val)
79  {
80  m_last_cycle = val;
81  }
86  bool empty()const
87  {
88  return m_first_cycle == std::numeric_limits<cycle_t>::max();
89  }
92  public:
100  void update(const cycle_t cycle)
101  {
102  if (cycle > m_last_cycle) m_last_cycle = cycle;
103  if (cycle < m_first_cycle) m_first_cycle = cycle;
104  }
105 
110  void update(const cycle_range &rng)
111  {
114  }
115 
125  friend cycle_range operator-(const cycle_range &lhs, const cycle_t &first_cycle_of_read)
126  {
127  if (lhs.m_last_cycle < first_cycle_of_read) return lhs;
128  return cycle_range(lhs.m_first_cycle - first_cycle_of_read, lhs.m_last_cycle - first_cycle_of_read);
129  }
130 
131  protected:
133  cycle_t m_first_cycle;
135  cycle_t m_last_cycle;
136 
137  friend class info;
138  template<class MetricType, int Version>
139  friend struct io::generic_layout;
140  };
141 
142 }}}}
143 
cycle_range(const cycle_t first_cycle=std::numeric_limits< cycle_t >::max(), const cycle_t last_cycle=0)
Definition: cycle_range.h:31
void last_cycle(const cycle_t val)
Definition: cycle_range.h:78
Definition: enum_description.h:15
bool empty() const
Definition: cycle_range.h:86
Definition: cycle_range.h:20
size_t cycle_t
Definition: cycle_range.h:24
Definition: generic_layout.h:24
friend cycle_range operator-(const cycle_range &lhs, const cycle_t &first_cycle_of_read)
Definition: cycle_range.h:125
void update(const cycle_t cycle)
Definition: cycle_range.h:100
void first_cycle(const cycle_t val)
Definition: cycle_range.h:69
void update(const cycle_range &rng)
Definition: cycle_range.h:110
cycle_t last_cycle() const
Definition: cycle_range.h:60
cycle_t m_first_cycle
Definition: cycle_range.h:133
cycle_t m_last_cycle
Definition: cycle_range.h:135
cycle_t first_cycle() const
Definition: cycle_range.h:50