plot_data.h
Go to the documentation of this file.
1 
8 #pragma once
13 
14 namespace illumina { namespace interop { namespace model { namespace plot
15 {
16 
27  template<class Point>
28  class plot_data : public chart_data
29  {
30  typedef series<Point> series_t;
31  typedef std::vector<series_t> series_collection_t;
32  public:
34  typedef typename series_collection_t::const_reference const_reference;
36  typedef typename series_collection_t::reference reference;
38  typedef typename series_collection_t::size_type size_type;
40  typedef typename series_collection_t::iterator iterator;
42  typedef typename series_collection_t::const_iterator const_iterator;
43 
44  public:
60  {
61  INTEROP_BOUNDS_CHECK(index, m_series.size(), "Index out of bounds");
62  return m_series[index];
63  }
70  {
71  INTEROP_BOUNDS_CHECK(index, m_series.size(), "Index out of bounds");
72  return m_series[index];
73  }
80  {
81  INTEROP_BOUNDS_CHECK(index, m_series.size(), "Index out of bounds");
82  return m_series[index];
83  }
88  size_t size()const
89  {
90  return m_series.size();
91  }
96  bool empty()const
97  {
98  return size()==0;
99  }
102  public:
105  void clear()
106  {
107  m_series.clear();
109  }
114  void resize(const size_t n)
115  {
116  m_series.resize(n);
117  }
123  void assign(const size_t n, const series<Point>& val)
124  {
125  m_series.assign(n, val);
126  }
131  void push_back(const series<Point>& val)
132  {
133  m_series.push_back(val);
134  }
139  const_iterator begin()const
140  {
141  return m_series.begin();
142  }
147  const_iterator end()const
148  {
149  return m_series.end();
150  }
151  friend std::ostream& operator<<(std::ostream& out, const plot_data& data)
152  {
153  out << static_cast<const chart_data&>(data);
154  out << data.m_series.size() << ",";
155  for(size_t i=0;i<data.m_series.size();++i)
156  out << data.m_series[i];
157  return out;
158  }
159  friend std::istream& operator>>(std::istream& in, plot_data& data)
160  {
161  std::string tmp;
162  in >> static_cast<chart_data&>(data);
163  std::getline(in, tmp, ',');
164  size_t n = util::lexical_cast<size_t>(tmp);
165  data.m_series.resize(n);
166  for(size_t i=0;i<data.m_series.size();++i)
167  in >> data.m_series[i];
168  return in;
169  }
170 
171  private:
172  series_collection_t m_series;
173  };
174 
175 
176 }}}}
177 
series_collection_t::const_iterator const_iterator
Definition: plot_data.h:42
Definition: enum_description.h:15
const_iterator end() const
Definition: plot_data.h:147
const_iterator begin() const
Definition: plot_data.h:139
void clear()
Definition: chart_data.h:110
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
bool empty() const
Definition: plot_data.h:96
series< Point > & operator[](const size_t index) INTEROP_THROW_SPEC((model
Definition: plot_data.h:69
void resize(const size_t n)
Definition: plot_data.h:114
series_collection_t::size_type size_type
Definition: plot_data.h:38
series_collection_t::iterator iterator
Definition: plot_data.h:40
void clear()
Definition: plot_data.h:105
void push_back(const series< Point > &val)
Definition: plot_data.h:131
series_collection_t::const_reference const_reference
Definition: plot_data.h:34
const series< Point > & at(const size_t index) const INTEROP_THROW_SPEC((model
Definition: plot_data.h:59
friend std::ostream & operator<<(std::ostream &out, const plot_data &data)
Definition: plot_data.h:151
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
void assign(const size_t n, const series< Point > &val)
Definition: plot_data.h:123
friend std::istream & operator>>(std::istream &in, plot_data &data)
Definition: plot_data.h:159
size_t size() const
Definition: plot_data.h:88
Destination lexical_cast(const Source &src)
Definition: lexical_cast.h:264
series_collection_t::reference reference
Definition: plot_data.h:36
const series< Point > & operator[](const size_t index) const INTEROP_THROW_SPEC((model
Definition: plot_data.h:79