imaging_table.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <iosfwd>
10 #include "interop/util/math.h"
12 
13 
14 namespace illumina { namespace interop { namespace model { namespace table
15 {
18  {
19  public:
21  typedef std::vector< imaging_column> column_vector_t;
23  typedef std::vector< float > data_vector_t;
24 
25  private:
27  typedef std::vector< size_t > offset_vector_t;
28 
29  public:
31  imaging_table() : m_row_count(0), m_col_count(0){}
32 
33  public:
40  void set_data(const size_t rows, column_vector_t& cols, data_vector_t& data)
41  {
42  if(cols.empty())
43  {
44  clear();
45  return;
46  }
47  m_columns.swap(cols);
48  m_data.swap(data);
49  m_row_count = rows;
50  m_col_count = m_columns.back().column_count();
51  m_enum_to_index.assign(ImagingColumnCount, static_cast<size_t>(ImagingColumnCount));
52  for(size_t i=0;i<m_columns.size();++i)
53  m_enum_to_index[m_columns[i].id()] = i;
54  }
62  float operator()(const size_t r, const column_id c, const size_t subcol=0)const INTEROP_THROW_SPEC((model::index_out_of_bounds_exception))
63  {
64  INTEROP_BOUNDS_CHECK(static_cast<size_t>(c), m_enum_to_index.size(), "Invalid enum id for column (" << constants::to_string(c) << ")");
65  const size_t col = m_enum_to_index[static_cast<size_t>(c)];
66  INTEROP_BOUNDS_CHECK(col, m_enum_to_index.size(), "Invalid enum id for column - column not filled: " << constants::to_string(c) << ")");
67  return operator()(r, col, subcol);
68  }
76  float operator()(const size_t row, const size_t col, const size_t subcol=0)const INTEROP_THROW_SPEC((model::index_out_of_bounds_exception))
77  {
78  INTEROP_BOUNDS_CHECK(row, m_row_count, "Row index out of bounds");
79  INTEROP_BOUNDS_CHECK(col, m_columns.size(), "Column index out of bounds");
80  const size_t col_index = m_columns[col].offset()+subcol;
81  INTEROP_BOUNDS_CHECK(col_index, m_col_count, "Column offset index out of bounds");
82  const size_t index = row*m_col_count+col_index;
83  INTEROP_ASSERT(index < m_data.size());
84  return m_data[index];
85  }
90  const column_vector_t& columns()const
91  {
92  return m_columns;
93  }
98  bool empty()const
99  {
100  return m_data.empty();
101  }
104  void clear()
105  {
106  m_data.clear();
107  m_columns.clear();
108  m_col_count = 0;
109  m_row_count = 0;
110  }
117  {
118  INTEROP_BOUNDS_CHECK(col_index, m_columns.size(), "Column index out of bounds");
119  return m_columns[col_index];
120  }
121 
122  public:
127  size_t column_count()const
128  {
129  return m_columns.size();
130  }
135  size_t total_column_count()const
136  {
137  return m_col_count;
138  }
143  size_t row_count()const
144  {
145  return m_row_count;
146  }
147 
148  private:
149  friend std::istream& operator>>(std::istream& in, imaging_table& table);
150  friend std::ostream& operator<<(std::ostream& out, const imaging_table& table);
151  private:
152  data_vector_t m_data;
153  column_vector_t m_columns;
154  offset_vector_t m_enum_to_index;
155  size_t m_row_count;
156  size_t m_col_count;
157  };
161  {
166  imaging_table_id_less(const imaging_table& table) : m_table(table){}
167 
174  bool operator()(const size_t lhs_row, const size_t rhs_row)const
175  {
176  const size_t lhs_lane = static_cast<size_t>(m_table(lhs_row, LaneColumn));
177  const size_t rhs_lane = static_cast<size_t>(m_table(rhs_row, LaneColumn));
178  if(lhs_lane == rhs_lane)
179  {
180  const size_t lhs_tile = static_cast<size_t>(m_table(lhs_row, TileColumn));
181  const size_t rhs_tile = static_cast<size_t>(m_table(rhs_row, TileColumn));
182  if(lhs_tile == rhs_tile)
183  {
184  const size_t lhs_cycle = static_cast<size_t>(m_table(lhs_row, CycleColumn));
185  const size_t rhs_cycle = static_cast<size_t>(m_table(rhs_row, CycleColumn));
186  return lhs_cycle < rhs_cycle;
187  }
188  return lhs_tile < rhs_tile;
189  }
190  return lhs_lane < rhs_lane;
191  }
192 
193  private:
194  const imaging_table& m_table;
195  };
196 
197 }}}}
198 
const column_vector_t & columns() const
Definition: imaging_table.h:90
void set_data(const size_t rows, column_vector_t &cols, data_vector_t &data)
Definition: imaging_table.h:40
Definition: enum_description.h:15
size_t row_count() const
Definition: imaging_table.h:143
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
imaging_table()
Definition: imaging_table.h:31
friend std::ostream & operator<<(std::ostream &out, const imaging_table &table)
Definition: imaging_table_csv.h:99
column_id
Definition: imaging_column.h:91
bool empty() const
Definition: imaging_table.h:98
size_t column_count() const
Definition: imaging_table.h:127
void clear()
Definition: imaging_table.h:104
Definition: imaging_column.h:91
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
friend std::istream & operator>>(std::istream &in, imaging_table &table)
Definition: imaging_table_csv.h:68
size_t total_column_count() const
Definition: imaging_table.h:135
bool operator()(const size_t lhs_row, const size_t rhs_row) const
Definition: imaging_table.h:174
std::vector< imaging_column > column_vector_t
Definition: imaging_table.h:21
std::vector< float > data_vector_t
Definition: imaging_table.h:23
Definition: imaging_column.h:91
const imaging_column & column_at(const size_t col_index) INTEROP_THROW_SPEC((model
Definition: imaging_table.h:116
float operator()(const size_t r, const column_id c, const size_t subcol=0) const INTEROP_THROW_SPEC((model
Definition: imaging_table.h:62
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
imaging_table_id_less(const imaging_table &table)
Definition: imaging_table.h:166
float operator()(const size_t row, const size_t col, const size_t subcol=0) const INTEROP_THROW_SPEC((model
Definition: imaging_table.h:76
std::string to_string(Enum value)
Definition: enums.h:43
Definition: imaging_column.h:91