summaryrefslogtreecommitdiff
path: root/a4/octave.h
diff options
context:
space:
mode:
Diffstat (limited to 'a4/octave.h')
-rw-r--r--a4/octave.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/a4/octave.h b/a4/octave.h
new file mode 100644
index 0000000..3c814c5
--- /dev/null
+++ b/a4/octave.h
@@ -0,0 +1,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;
+};