summaryrefslogtreecommitdiffhomepage
path: root/opentrack-logic/tracklogger.hpp
diff options
context:
space:
mode:
authorDaMichel <mw.pub@welter-4d.de>2016-07-29 11:12:22 +0200
committerDaMichel <mw.pub@welter-4d.de>2016-07-29 11:38:21 +0200
commit7b3be452b6be528de753a1a633a3aacdb11be86c (patch)
tree63df2693909a92529610a055e2f670d5860cedf8 /opentrack-logic/tracklogger.hpp
parent2bae0bce582f05259f64fb13b364fe6dbd28817a (diff)
new track logging: record poses in various stages of processing into a file
Diffstat (limited to 'opentrack-logic/tracklogger.hpp')
-rw-r--r--opentrack-logic/tracklogger.hpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/opentrack-logic/tracklogger.hpp b/opentrack-logic/tracklogger.hpp
new file mode 100644
index 00000000..feed7fa2
--- /dev/null
+++ b/opentrack-logic/tracklogger.hpp
@@ -0,0 +1,57 @@
+#pragma once
+#include "main-settings.hpp"
+#include "opentrack-compat/options.hpp"
+
+#include <fstream>
+#include <QString>
+#include <QMessageBox>
+#include <QWidget>
+
+class OPENTRACK_LOGIC_EXPORT TrackLogger
+{
+public:
+ TrackLogger()
+ {
+ }
+
+ static mem<TrackLogger> make() { return std::make_shared<TrackLogger>(); }
+
+ virtual void write(const char *)
+ {
+ }
+
+ virtual void write(const double *, int n)
+ {
+ }
+
+ virtual void next_line()
+ {
+ }
+
+ void write_pose(const double *p)
+ {
+ write(p, 6);
+ }
+};
+
+
+class OPENTRACK_LOGIC_EXPORT TrackLoggerCSV : public TrackLogger
+{
+ std::ofstream out;
+ bool first_col;
+public:
+ TrackLoggerCSV(const QString &filename) : TrackLogger(),
+ first_col(true)
+ {
+ out.open(filename.toStdString());
+ if (!out.is_open())
+ throw std::ios_base::failure("unable to open file");
+ }
+
+ static mem<TrackLogger> make(const main_settings &s) { return std::static_pointer_cast<TrackLogger>(std::make_shared<TrackLoggerCSV>(s.tracklogging_filename)); }
+
+ virtual void write(const char *s);
+ virtual void write(const double *p, int n);
+ virtual void next_line();
+};
+