summaryrefslogtreecommitdiff
path: root/a4/octave.h
blob: 3c814c57c58726475e8f100f1ca2a1941954908a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// -*- c++ -*-
#pragma once

#include <string>
#include <utility>
#include <fstream>
#include <vector>
#include <deque>

class Plot
{
public:
	Plot(const std::string& title) : title(title) {}

	const std::string& getTitle() const;
	void add(const std::pair<double, double>& point);
	void add(double y);
	void setX(double x);

	friend const Plot& operator<<(std::ostream& out, const Plot& plot);

private:
	std::vector<std::pair<double, double>> data;
	std::string title;
	double x{};
};

class Octave
{
public:
	Octave(const std::string& file);
	~Octave();

	Plot& add(const std::string& title);
	void setAxis(const std::string& x_axis, const std::string& y_axis);

private:
	std::deque<Plot> plots;
	std::ofstream out;

	std::string x_axis;
	std::string y_axis;

	std::string file;
};