Improve the event loop architecture by making it set the divecomputer in
the constructor - using the same loop for multiple dive computers is not
intended to work.
Also change `next()` in `divemode_loop` to `at()` to make the name more
aligned with its function.
Signed-off-by: Michael Keller <github@ike.ch>
Fixes gcc complaining about
/build/subsurface-beta-202408190452/core/event.cpp: In member function 'bool event::operator==(const event&) const':
/build/subsurface-beta-202408190452/core/event.cpp:64:21: error: 'tie' is not a member of 'std'
64 | return std::tie(time.seconds, type, flags, value, name) ==
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:6:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
5 | #include "subsurface-string.h"
+++ |+#include <tuple>
6 |
/build/subsurface-beta-202408190452/core/event.cpp:65:21: error: 'tie' is not a member of 'std'
65 | std::tie(b.time.seconds, b.type, b.flags, b.value, b.name);
| ^~~
/build/subsurface-beta-202408190452/core/event.cpp:65:21: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
Signed-off-by: Richard Fuchs <dfx@dfx.at>
Not strictly necessary, but more idiomatic C++ and less
polution of the global namespace. This one is so trivial
that there seems to be no reason not to do it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a rather long commit, because it refactors lots of the event
code from pointer to value semantics: pointers to entries in an
std::vector<> are not stable, so better use indexes.
To step through the event-list at diven time stamps, add *_loop classes,
which encapsulate state that had to be manually handled before by
the caller. I'm not happy about the interface, but it tries to
mirror the one we had before.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Makes the code much nicer to read.
Default initialize cylinder_t to the empty cylinder.
This produces lots of warnings, because most structure are now
not PODs anymore and shouldn't be erased using memset().
These memset()s will be removed one-by-one and replaced by
proper constructors.
The whole ordeal made it necessary to add a constructor to
struct event. To simplify things the whole optimization of
the variable-size event names was removed. In upcoming commits
this will be replaced by std::string anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>