aboutsummaryrefslogtreecommitdiffstats
path: root/core/dive.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-25 09:14:16 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-25 13:59:52 -0700
commit8212acc9925b28ecd546b01047c6a8fc574326ef (patch)
treef4ce765228f3bb2511a186373eb2b3394b647709 /core/dive.h
parentd82a7b8b73c13451f469832d6402303ccf2ee3d3 (diff)
downloadsubsurface-8212acc9925b28ecd546b01047c6a8fc574326ef.tar.gz
cleanup: break out event-related code into event.[c|h]
In an effort to reduce the size of dive.h and dive.c, break out the event related functions. Moreover event-names were handled by the profile-code, collect that also in the new source files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.h')
-rw-r--r--core/dive.h43
1 files changed, 2 insertions, 41 deletions
diff --git a/core/dive.h b/core/dive.h
index 735e760c1..27e73375f 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -20,41 +20,14 @@
extern "C" {
#endif
+struct event;
+
extern int last_xml_version;
extern const char *cylinderuse_text[NUM_GAS_USE];
extern const char *divemode_text_ui[];
extern const char *divemode_text[];
-/*
- * Events are currently based straight on what libdivecomputer gives us.
- * We need to wrap these into our own events at some point to remove some of the limitations.
- */
-struct event {
- struct event *next;
- duration_t time;
- int type;
- /* This is the annoying libdivecomputer format. */
- int flags, value;
- /* .. and this is our "extended" data for some event types */
- union {
- enum divemode_t divemode; // for divemode change events
- /*
- * NOTE! The index may be -1, which means "unknown". In that
- * case, the get_cylinder_index() function will give the best
- * match with the cylinders in the dive based on gasmix.
- */
- struct { // for gas switch events
- int index;
- struct gasmix mix;
- } gas;
- };
- bool deleted;
- char name[];
-};
-
-extern int event_is_gaschange(const struct event *ev);
-
extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, struct gasmix mix, double po2, enum divemode_t dctype);
/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
@@ -323,21 +296,16 @@ extern int split_dive(const struct dive *dive, struct dive **new1, struct dive *
extern int split_dive_at_time(const struct dive *dive, duration_t time, struct dive **new1, struct dive **new2);
extern struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, bool prefer_downloaded, struct dive_trip **trip, struct dive_site **site);
extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded);
-extern struct event *clone_event(const struct event *src_ev);
extern void copy_events(const struct divecomputer *s, struct divecomputer *d);
extern void copy_events_until(const struct dive *sd, struct dive *dd, int time);
-extern void free_events(struct event *ev);
extern void copy_used_cylinders(const struct dive *s, struct dive *d, bool used_only);
extern void copy_samples(const struct divecomputer *s, struct divecomputer *d);
extern bool is_cylinder_used(const struct dive *dive, int idx);
extern bool is_cylinder_prot(const struct dive *dive, int idx);
extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx);
-extern struct event *create_event(unsigned int time, int type, int flags, int value, const char *name);
extern struct event *create_gas_switch_event(struct dive *dive, struct divecomputer *dc, int seconds, int idx);
-extern struct event *clone_event_rename(const struct event *ev, const char *name);
extern void add_event_to_dc(struct divecomputer *dc, struct event *ev);
extern void swap_event(struct divecomputer *dc, struct event *from, struct event *to);
-extern bool same_event(const struct event *a, const struct event *b);
extern struct event *add_event(struct divecomputer *dc, unsigned int time, int type, int flags, int value, const char *name);
extern void remove_event_from_dc(struct divecomputer *dc, struct event *event);
extern void update_event_name(struct dive *d, struct event *event, const char *name);
@@ -350,11 +318,8 @@ extern int nr_weightsystems(const struct dive *dive);
/* UI related protopypes */
-extern void remember_event(const char *eventname);
extern void invalidate_dive_cache(struct dive *dc);
-extern void clear_events(void);
-
extern void set_autogroup(bool value);
extern int total_weight(const struct dive *);
@@ -370,10 +335,6 @@ extern void subsurface_command_line_exit(int *, char ***);
extern bool is_dc_planner(const struct divecomputer *dc);
extern bool has_planned(const struct dive *dive, bool planned);
-/* Since C doesn't have parameter-based overloading, two versions of get_next_event. */
-extern const struct event *get_next_event(const struct event *event, const char *name);
-extern struct event *get_next_event_mutable(struct event *event, const char *name);
-
/* Get gasmixes at increasing timestamps.
* In "evp", pass a pointer to a "struct event *" which is NULL-initialized on first invocation.
* On subsequent calls, pass the same "evp" and the "gasmix" from previous calls.