mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: turn divecomputer list into std::vector<>
Since struct divecomputer is now fully C++ (i.e. cleans up after itself), we can simply turn the list of divecomputers into an std::vector<>. This makes the code quite a bit simpler, because the first divecomputer was actually a subobject. Yes, this makes the common case of a single divecomputer a little bit less efficient, but it really shouldn't matter. If it does, we can still write a special std::vector<>- like container that keeps the first element inline. This change makes pointers-to-divecomputers not stable. So always access the divecomputer via its index. As far as I can tell, most of the code already does this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e237f29fb2
commit
284582d2e8
54 changed files with 738 additions and 893 deletions
14
core/dive.h
14
core/dive.h
|
@ -10,6 +10,7 @@
|
|||
#include "picture.h" // TODO: remove
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern int last_xml_version;
|
||||
|
||||
|
@ -22,6 +23,7 @@ struct dive_trip;
|
|||
struct full_text_cache;
|
||||
struct event;
|
||||
struct trip_table;
|
||||
|
||||
struct dive {
|
||||
struct dive_trip *divetrip = nullptr;
|
||||
timestamp_t when = 0;
|
||||
|
@ -45,7 +47,7 @@ struct dive {
|
|||
int user_salinity = 0; // water density reflecting a user-specified type
|
||||
|
||||
struct tag_entry *tag_list = nullptr;
|
||||
struct divecomputer dc;
|
||||
std::vector<divecomputer> dcs; // Attn: pointers to divecomputers are not stable!
|
||||
int id = 0; // unique ID for this dive
|
||||
struct picture_table pictures = { };
|
||||
unsigned char git_id[20] = {};
|
||||
|
@ -117,8 +119,10 @@ extern std::string get_dive_country(const struct dive *dive);
|
|||
extern std::string get_dive_location(const struct dive *dive);
|
||||
extern unsigned int number_of_computers(const struct dive *dive);
|
||||
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);
|
||||
extern const struct divecomputer *get_dive_dc_const(const struct dive *dive, int nr);
|
||||
extern const struct divecomputer *get_dive_dc(const struct dive *dive, int nr);
|
||||
extern timestamp_t dive_endtime(const struct dive *dive);
|
||||
extern temperature_t dc_airtemp(const struct dive *dive);
|
||||
extern temperature_t dc_watertemp(const struct dive *dive);
|
||||
|
||||
extern void set_git_prefs(const char *prefs);
|
||||
|
||||
|
@ -136,12 +140,6 @@ void split_divecomputer(const struct dive *src, int num, struct dive **out1, str
|
|||
#define for_each_dive(_i, _x) \
|
||||
for ((_i) = 0; ((_x) = get_dive(_i)) != NULL; (_i)++)
|
||||
|
||||
#define for_each_dc(_dive, _dc) \
|
||||
for (_dc = &_dive->dc; _dc; _dc = _dc->next)
|
||||
|
||||
#define for_each_relevant_dc(_dive, _dc) \
|
||||
for (_dc = &_dive->dc; _dc; _dc = _dc->next) if (!is_logged(_dive) || !is_dc_planner(_dc))
|
||||
|
||||
extern struct dive *get_dive_by_uniq_id(int id);
|
||||
extern int get_idx_by_uniq_id(int id);
|
||||
extern bool dive_site_has_gps_location(const struct dive_site *ds);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue