core: move fixup_dive() to struct dive_table

This accesses the global dive_table, so make this explicit.

Since force_fixup_dive() and default_dive() use fixup_dive(),
also move them to struct dive_table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-23 14:20:59 +02:00 committed by bstoeger
parent d81ca005ab
commit a2903b31a7
12 changed files with 233 additions and 228 deletions

View file

@ -21,14 +21,20 @@ struct dive_table : public sorted_owning_table<dive, &comp_dives> {
void record_dive(std::unique_ptr<dive> d); // call fixup_dive() before adding dive to table.
struct dive *register_dive(std::unique_ptr<dive> d);
std::unique_ptr<dive> unregister_dive(int idx);
std::unique_ptr<dive> default_dive(); // generate a sensible looking defaultdive 1h from now.
// Some of these functions act on dives, but need data from adjacent dives,
// notably to calculate CNS, surface interval, etc. Therefore, they are called
// on the dive_table and not on the dive.
void fixup_dive(struct dive &dive) const;
void force_fixup_dive(struct dive &d) const;
int init_decompression(struct deco_state *ds, const struct dive *dive, bool in_planner) const;
void update_cylinder_related_info(struct dive *) const;
void update_cylinder_related_info(struct dive &dive) const;
int get_dive_nr_at_idx(int idx) const;
timestamp_t get_surface_interval(timestamp_t when) const;
struct dive *find_next_visible_dive(timestamp_t when);
private:
int calculate_cns(struct dive *dive) const; // Note: writes into dive->cns
int calculate_cns(struct dive &dive) const; // Note: writes into dive->cns
};
/* this is used for both git and xml format */