data_point.h
Go to the documentation of this file.
1 
8 #pragma once
12 
13 
14 namespace illumina { namespace interop { namespace model { namespace plot {
15 
20  template<typename X, typename Y>
21  class data_point
22  {
23  public:
25  typedef X x_type;
27  typedef Y y_type;
28 
29  public:
35  data_point(const x_type x=0, const y_type y=0) : m_x(x), m_y(y){}
36 
37  public:
50  X x()const
51  {
52  return m_x;
53  }
58  Y y()const
59  {
60  return m_y;
61  }
66  X max_value()const
67  {
68  return m_y;
69  }
74  Y min_value()const
75  {
76  return m_y;
77  }
80  public:
86  void add(const x_type x, const y_type y)
87  {
88  m_x += x;
89  m_y += y;
90  }
96  void set(const x_type x, const y_type y)
97  {
98  m_y = y;
99  m_x = x;
100  }
101  friend std::ostream& operator<<(std::ostream& out, const data_point& data)
102  {
103  out << std::setprecision(10) << io::table::handle_nan(data.m_x) << ",";
104  out << std::setprecision(10) << io::table::handle_nan(data.m_y) << ",";
105  //out << "\n";
106  return out;
107  }
108  friend std::istream& operator>>(std::istream& in, data_point& data)
109  {
110  std::string tmp;
111  std::getline(in, tmp, ',');
112  data.m_x = util::lexical_cast<x_type>(tmp);
113  std::getline(in, tmp, ',');
114  data.m_y = util::lexical_cast<y_type>(tmp);
115  return in;
116  }
117 
118  private:
119  x_type m_x;
120  y_type m_y;
121  };
122 
123 
124 }}}}
125 
Y y_type
Definition: data_point.h:27
Y min_value() const
Definition: data_point.h:74
friend std::ostream & operator<<(std::ostream &out, const data_point &data)
Definition: data_point.h:101
Definition: enum_description.h:15
X max_value() const
Definition: data_point.h:66
X x_type
Definition: data_point.h:25
Y y() const
Definition: data_point.h:58
void set(const x_type x, const y_type y)
Definition: data_point.h:96
const T & handle_nan(const T &val)
Definition: csv_format.h:84
X x() const
Definition: data_point.h:50
data_point(const x_type x=0, const y_type y=0)
Definition: data_point.h:35
void add(const x_type x, const y_type y)
Definition: data_point.h:86
Destination lexical_cast(const Source &src)
Definition: lexical_cast.h:264
friend std::istream & operator>>(std::istream &in, data_point &data)
Definition: data_point.h:108