Sen API
Sen Libraries
Loading...
Searching...
No Matches
cursor.h
Go to the documentation of this file.
1// === cursor.h ========================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_DB_CURSOR_H
9#define SEN_DB_CURSOR_H
10
13
14#include <functional>
15#include <variant>
16
17namespace sen::db
18{
19
20class Input;
21
25template <typename End, typename... T>
26class Cursor
27{
28 SEN_MOVE_ONLY(Cursor)
29
30public:
32 using Payload = std::variant<std::monostate, T..., End>;
33
40
41public:
42 ~Cursor() = default;
43
44public:
46 [[nodiscard]] bool atEnd() const noexcept { return std::holds_alternative<End>(entry_.payload); }
47
49 [[nodiscard]] bool atBegining() const noexcept { return std::holds_alternative<std::monostate>(entry_.payload); }
50
52 [[nodiscard]] const Entry& get() const noexcept { return entry_; }
53
55 [[nodiscard]] const Entry& operator->() const noexcept { return entry_; }
56
58 Cursor& operator++()
59 {
60 frontProvider_(entry_);
61 return *this;
62 }
63
64private:
65 friend class Input;
66 using Provider = std::function<void(Entry&)>;
67
68private:
69 explicit Cursor(Provider frontProvider): frontProvider_(std::move(frontProvider)) {}
70
71private:
72 Entry entry_;
73 Provider frontProvider_;
74};
75
76} // namespace sen::db
77
78#endif // SEN_DB_CURSOR_H
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
A point in time.
Definition timestamp.h:26
~Cursor()=default
Payload payload
When.
Definition cursor.h:38
bool atEnd() const noexcept
True if the cursor is at the end of the recording.
Definition cursor.h:46
std::variant< std::monostate, T..., End > Payload
The content of the current entry.
Definition cursor.h:32
const Entry & get() const noexcept
The current entry.
Definition cursor.h:52
const Entry & operator->() const noexcept
The current entry.
Definition cursor.h:55
Cursor & operator++()
Advance the cursor one step.
Definition cursor.h:58
TimeStamp time
Definition cursor.h:37
bool atBegining() const noexcept
True if the cursor is at the start of the recording.
Definition cursor.h:49
The current entry.
Definition cursor.h:36
Allows you to access an existing recording in the file system.
Definition input.h:63
Represents the end of the recording. Used in cursors.
Definition input.h:52
Definition annotation.h:20
STL namespace.