series.h
Go to the documentation of this file.
1 
8 #pragma once
10 
11 namespace illumina { namespace interop { namespace model { namespace plot {
12 
15  template<class Point>
16  class series : public data_point_collection<Point>
17  {
18  public:
20  typedef std::vector<std::string> options_t;
23  public:
32 
33  public:
36  {
43  };
44 
45  public:
52  series(const std::string& title="",
53  const std::string color="Blue",
55  m_title(title),
56  m_color(color),
57  m_series_type(series_type){}
58 
59  public:
72  const std::string& title()const
73  {
74  return m_title;
75  }
80  const std::string& color()const
81  {
82  return m_color;
83  }
89  {
90  return m_series_type;
91  }
96  const options_t& options()const
97  {
98  return m_options;
99  }
102  public:
107  void add_option(const std::string& option)
108  {
109  m_options.push_back(option);
110  }
115  void color(const std::string& color_name)
116  {
117  m_color = color_name;
118  }
119 
120  friend std::ostream& operator<<(std::ostream& out, const series& data)
121  {
122  out << data.m_title << ",";
123  out << data.m_color << ",";
124  out << data.m_series_type << ",";
125  out << data.m_options.size() << ",";
126  for(size_t i=0;i<data.m_options.size();++i)
127  out << data.m_options[i] << ",";
128  out << data.size() << ",";
129  for(size_t i=0;i<data.size();++i)
130  {
131  out << data[i];
132  }
133  return out;
134  }
135  friend std::istream& operator>>(std::istream& in, series& data)
136  {
137  std::string tmp;
138  std::getline(in, data.m_title, ',');
139  std::getline(in, data.m_color, ',');
140  std::getline(in, tmp, ',');
141  int series_type = util::lexical_cast<int>(tmp);
142  data.m_series_type = static_cast<series_types>(series_type);
143 
144  std::getline(in, tmp, ',');
145  size_t num_options = util::lexical_cast<size_t>(tmp);
146  data.m_options.resize(num_options);
147  for(size_t i=0;i<data.m_options.size();++i)
148  {
149  std::getline(in, data.m_options[i], ',');
150  }
151 
152  std::getline(in, tmp, ',');
153  size_t num_points = util::lexical_cast<size_t>(tmp);
154  data.resize(num_points);
155  for(size_t i=0;i<data.size();++i)
156  {
157  in >> data[i];
158  }
159  return in;
160  }
161 
162  private:
163  std::string m_title;
164  std::string m_color;
165  series_types m_series_type;
166  options_t m_options;
167  };
168 
169 
170 }}}}
171 
point_collection_t::size_type size_type
Definition: series.h:31
const std::string & title() const
Definition: series.h:72
point_vector_t::reference reference
Definition: data_point_collection.h:28
Definition: enum_description.h:15
data_point_collection< Point > point_collection_t
Definition: series.h:22
series_types series_type() const
Definition: series.h:88
point_collection_t::reference reference
Definition: series.h:29
size_t size() const
Definition: data_point_collection.h:81
friend std::istream & operator>>(std::istream &in, series &data)
Definition: series.h:135
point_vector_t::const_iterator const_iterator
Definition: data_point_collection.h:32
std::vector< std::string > options_t
Definition: series.h:20
point_vector_t::const_reference const_reference
Definition: data_point_collection.h:26
const std::string & color() const
Definition: series.h:80
series(const std::string &title="", const std::string color="Blue", const series_types series_type=Candlestick)
Definition: series.h:52
series_types
Definition: series.h:35
point_collection_t::const_reference const_reference
Definition: series.h:27
friend std::ostream & operator<<(std::ostream &out, const series &data)
Definition: series.h:120
void color(const std::string &color_name)
Definition: series.h:115
void resize(const size_t n)
Definition: data_point_collection.h:101
point_vector_t::size_type size_type
Definition: data_point_collection.h:30
Destination lexical_cast(const Source &src)
Definition: lexical_cast.h:264
Definition: data_point_collection.h:21
const options_t & options() const
Definition: series.h:96
void add_option(const std::string &option)
Definition: series.h:107
point_collection_t::const_iterator const_iterator
Definition: series.h:25