mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Refactoring: Improve event_loop
.
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>
This commit is contained in:
parent
33bb39f1ca
commit
ee25e8a1db
11 changed files with 28 additions and 33 deletions
10
core/event.h
10
core/event.h
|
@ -58,10 +58,10 @@ class event_loop
|
|||
{
|
||||
std::string name;
|
||||
size_t idx;
|
||||
const struct divecomputer &dc;
|
||||
public:
|
||||
event_loop(const char *name);
|
||||
struct event *next(struct divecomputer &dc); // nullptr -> end
|
||||
const struct event *next(const struct divecomputer &dc); // nullptr -> end
|
||||
event_loop(const char *name, const struct divecomputer &dc);
|
||||
const struct event *next(); // nullptr -> end
|
||||
};
|
||||
|
||||
/* Get gasmixes at increasing timestamps. */
|
||||
|
@ -92,13 +92,13 @@ public:
|
|||
|
||||
/* Get divemodes at increasing timestamps. */
|
||||
class divemode_loop {
|
||||
const struct divecomputer &dc;
|
||||
divemode_t last;
|
||||
event_loop loop;
|
||||
const struct event *ev;
|
||||
public:
|
||||
divemode_loop(const struct divecomputer &dc);
|
||||
divemode_t next(int time);
|
||||
// Return the divemode at a given time during the dive
|
||||
divemode_t at(int time);
|
||||
};
|
||||
|
||||
extern const struct event *get_first_event(const struct divecomputer &dc, const std::string &name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue