2017-04-27 18:18:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2011-09-05 19:12:58 +00:00
|
|
|
#ifndef DIVELIST_H
|
|
|
|
#define DIVELIST_H
|
|
|
|
|
2024-06-07 08:25:09 +00:00
|
|
|
#include "triptable.h"
|
|
|
|
#include "divesitetable.h"
|
2020-05-01 11:43:52 +00:00
|
|
|
#include "units.h"
|
2024-06-04 11:52:48 +00:00
|
|
|
#include <memory>
|
2024-05-31 05:08:54 +00:00
|
|
|
#include <vector>
|
2019-03-04 22:20:29 +00:00
|
|
|
|
2020-05-01 11:43:52 +00:00
|
|
|
struct dive;
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
struct divelog;
|
2024-05-31 05:08:54 +00:00
|
|
|
struct device;
|
2019-08-05 18:43:06 +00:00
|
|
|
struct deco_state;
|
|
|
|
|
2024-06-07 08:25:09 +00:00
|
|
|
int comp_dives(const struct dive &a, const struct dive &b);
|
|
|
|
int comp_dives_ptr(const struct dive *a, const struct dive *b);
|
|
|
|
|
|
|
|
struct dive_table : public sorted_owning_table<dive, &comp_dives> {
|
|
|
|
dive *get_by_uniq_id(int id) const;
|
|
|
|
void record_dive(std::unique_ptr<dive> d); // call fixup_dive() before adding dive to table.
|
|
|
|
std::unique_ptr<dive> unregister_dive(int idx);
|
2024-06-18 18:57:10 +00:00
|
|
|
|
2024-06-18 19:07:58 +00:00
|
|
|
int get_dive_nr_at_idx(int idx) const;
|
2024-06-18 19:01:16 +00:00
|
|
|
timestamp_t get_surface_interval(timestamp_t when) const;
|
2024-06-18 18:57:10 +00:00
|
|
|
struct dive *find_next_visible_dive(timestamp_t when);
|
2020-05-01 11:43:52 +00:00
|
|
|
};
|
|
|
|
|
2015-06-20 13:45:12 +00:00
|
|
|
/* this is used for both git and xml format */
|
|
|
|
#define DATAFORMAT_VERSION 3
|
|
|
|
|
2011-11-13 17:29:07 +00:00
|
|
|
extern void update_cylinder_related_info(struct dive *);
|
2021-02-12 16:39:46 +00:00
|
|
|
extern int init_decompression(struct deco_state *ds, const struct dive *dive, bool in_planner);
|
2013-04-07 03:49:06 +00:00
|
|
|
|
|
|
|
/* divelist core logic functions */
|
2018-09-23 10:53:35 +00:00
|
|
|
extern void process_loaded_dives();
|
2019-01-13 20:53:57 +00:00
|
|
|
/* flags for process_imported_dives() */
|
|
|
|
#define IMPORT_PREFER_IMPORTED (1 << 0)
|
|
|
|
#define IMPORT_IS_DOWNLOADED (1 << 1)
|
|
|
|
#define IMPORT_MERGE_ALL_TRIPS (1 << 2)
|
|
|
|
#define IMPORT_ADD_TO_NEW_TRIP (1 << 3)
|
2024-06-07 08:25:09 +00:00
|
|
|
extern void add_imported_dives(struct divelog &log, int flags);
|
|
|
|
|
|
|
|
struct process_imported_dives_result {
|
|
|
|
dive_table dives_to_add;
|
|
|
|
std::vector<dive *> dives_to_remove;
|
|
|
|
trip_table trips_to_add;
|
|
|
|
dive_site_table sites_to_add;
|
|
|
|
std::vector<device> devices_to_add;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern process_imported_dives_result process_imported_dives(struct divelog &import_log, int flags);
|
|
|
|
|
2018-10-13 20:32:53 +00:00
|
|
|
extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
2019-05-31 14:09:14 +00:00
|
|
|
|
2015-06-20 13:45:12 +00:00
|
|
|
int get_min_datafile_version();
|
|
|
|
void report_datafile_version(int version);
|
2015-07-24 20:18:30 +00:00
|
|
|
void clear_dive_file_data();
|
2024-06-04 11:52:48 +00:00
|
|
|
struct dive *register_dive(std::unique_ptr<dive> d);
|
2021-10-30 19:39:36 +00:00
|
|
|
extern bool has_dive(unsigned int deviceid, unsigned int diveid);
|
2015-06-20 13:45:12 +00:00
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVELIST_H
|