/workspaces/astro/sol3-sdk/cpp/sol3/core/any_message_log_reader.h Source File

Space-ng SDK: /workspaces/astro/sol3-sdk/cpp/sol3/core/any_message_log_reader.h Source File
Space-ng SDK
any_message_log_reader.h
Go to the documentation of this file.
1 // Copyright (c) Space-ng, inc. All rights reserved.
2 
3 #pragma once
4 
7 #include "sol3/cpp/filesystem.h"
8 
9 #include <flatbuffers/flatbuffers.h>
10 
11 #include <cstddef>
12 #include <memory>
13 #include <optional>
14 #include <string>
15 #include <string_view>
16 #include <vector>
17 
18 namespace sol3::core {
25  public:
27  explicit AnyMessageLogReader(cpp::fs::path const& log_path);
28 
29  class Item {
30  public:
31  explicit Item(
34 
36  tl::expected<
39  headerView() const;
41  tl::expected<
44  payloadView() const;
45 
46  private:
49  };
50 
51  class Iterator {
52  public:
53  using value_type = Item;
54  using reference = Item;
55 
56  Iterator() = default;
57  explicit Iterator(
60  Iterator(Iterator const&) = default;
61  Iterator& operator=(Iterator const& other) = default;
62  Iterator(Iterator&&) = default;
63  Iterator& operator=(Iterator&& other) = default;
64  ~Iterator() = default;
65 
68  bool operator==(Iterator const& other) const;
69  bool operator!=(Iterator const& other) const;
70 
71  private:
74  };
75 
79 
81 
83  tl::expected<flatbuffers::span<uint8_t const>, ReadError> logHeaderSpan()
84  const;
85 
87  Iterator begin() const;
88  Iterator end() const;
89 
90  private:
92  void open(cpp::fs::path const& log_path);
93 
94  std::shared_ptr<SizeDelimitedLogReader> reader_;
95  MessageSchema log_header_schema_;
96  MessageSchema message_header_schema_;
97  MessageSchema payload_schema_;
98  SizeDelimitedLogReader::Iterator log_header_it_;
99 };
100 } // namespace sol3::core
Definition: any_message_log_reader.h:29
tl::expected< SizeDelimitedLogReader::FrameView, SizeDelimitedLogReader::ReadError > payloadView() const
Payload frame for the current message.
tl::expected< SizeDelimitedLogReader::FrameView, SizeDelimitedLogReader::ReadError > headerView() const
Header frame for the current message.
Item(SizeDelimitedLogReader::Iterator header_it, SizeDelimitedLogReader::Iterator payload_it)
Definition: any_message_log_reader.h:51
bool operator!=(Iterator const &other) const
Iterator(SizeDelimitedLogReader::Iterator header_it, SizeDelimitedLogReader::Iterator payload_it)
Iterator(Iterator const &)=default
Iterator & operator=(Iterator &&other)=default
bool operator==(Iterator const &other) const
Iterator & operator=(Iterator const &other)=default
Definition: any_message_log_reader.h:24
tl::expected< flatbuffers::span< uint8_t const >, ReadError > logHeaderSpan() const
Size-prefixed message log header bytes.
Iterator begin() const
Iterator over header/payload message pairs.
MessageSchema schemaForMessageLogHeader() const
MessageSchema schemaForMessageHeader() const
MessageSchema schemaForPayload() const
AnyMessageLogReader(cpp::fs::path const &log_path)
Construct a reader for a single log file path.
Definition: message_schema.h:12
Definition: size_delimited_log_reader.h:65
Definition: size_delimited_log_reader.h:100
Definition: any_message_input.h:15
Read error details returned from readAtOffset() and iteration.
Definition: size_delimited_log_reader.h:26