Add logger and log reader classes.
These work on EventLoop so they will work both in simulation and in
reality.
There is still some design work to deal with the realtime clock, and
some work to deal with messages from before the official start of the
log file.
Change-Id: Ib83228bdf1282fed626c61fcb6ed6fd86d213afd
diff --git a/aos/flatbuffers.h b/aos/flatbuffers.h
index b48dc1f..b951564 100644
--- a/aos/flatbuffers.h
+++ b/aos/flatbuffers.h
@@ -155,6 +155,33 @@
std::string data_;
};
+// Vector backed flatbuffer.
+template <typename T>
+class FlatbufferVector : public Flatbuffer<T> {
+ public:
+ // Builds a Flatbuffer around a vector.
+ FlatbufferVector(std::vector<uint8_t> &&data) : data_(std::move(data)) {}
+
+ // Builds a Flatbuffer by copying the data from the other flatbuffer.
+ FlatbufferVector(const Flatbuffer<T> &other)
+ : data_(other.data(), other.data() + other.size()) {}
+
+ // Copies the data from the other flatbuffer.
+ FlatbufferVector &operator=(const Flatbuffer<T> &other) {
+ data_ = std::vector<uint8_t>(other.data(), other.data() + other.size());
+ return *this;
+ }
+
+ virtual ~FlatbufferVector() override {}
+
+ const uint8_t *data() const override { return data_.data(); }
+ uint8_t *data() override { return data_.data(); }
+ size_t size() const override { return data_.size(); }
+
+ private:
+ std::vector<uint8_t> data_;
+};
+
// This object associates the message type with the memory storing the
// flatbuffer. This only stores root tables.
//