Add LogPartsSorter to sort messages from a log file
Based on https://docs.google.com/document/d/1RZ6ZlADRUHmwiFOOmXA87FHPLFuN-7mS7tbFCwguZDE/edit#
we need to start by sorting all the messages from a set of parts. Make
a class and test this. (The testing infrastructure looks a bit
over-kill, but will be re-used a lot for the following tests).
Change-Id: Ifa1ba880ddf7cf923f24826e504b902a4787ad03
diff --git a/aos/flatbuffers.h b/aos/flatbuffers.h
index 81a8cee..adb9769 100644
--- a/aos/flatbuffers.h
+++ b/aos/flatbuffers.h
@@ -477,6 +477,37 @@
ResizeableBuffer data_;
};
+// Non-owning Span backed flatbuffer.
+template <typename T>
+class SizePrefixedFlatbufferSpan : public SizePrefixedFlatbuffer<T> {
+ public:
+ // Builds a flatbuffer pointing to the contents of a span.
+ SizePrefixedFlatbufferSpan(const absl::Span<const uint8_t> data)
+ : data_(data) {}
+ // Builds a Flatbuffer pointing to the contents of another flatbuffer.
+ SizePrefixedFlatbufferSpan(const SizePrefixedFlatbuffer<T> &other) {
+ data_ = other.span();
+ }
+
+ // Points to the data in the other flatbuffer.
+ SizePrefixedFlatbufferSpan &operator=(
+ const SizePrefixedFlatbuffer<T> &other) {
+ data_ = other.span();
+ return *this;
+ }
+
+ ~SizePrefixedFlatbufferSpan() override {}
+
+ absl::Span<uint8_t> span() override {
+ LOG(FATAL) << "Unimplemented";
+ return absl::Span<uint8_t>(nullptr, 0);
+ }
+ absl::Span<const uint8_t> span() const override { return data_; }
+
+ private:
+ absl::Span<const uint8_t> data_;
+};
+
inline flatbuffers::DetachedBuffer CopySpanAsDetachedBuffer(
absl::Span<const uint8_t> span) {
// Copy the data from the span.