planner: C++-ify a bit more

Use constructor and member functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-09-07 14:25:48 +02:00 committed by Michael Keller
parent 74c8bd34a0
commit 0745c50e58
4 changed files with 79 additions and 82 deletions

View file

@ -9,15 +9,27 @@
/* this should be converted to use our types */
struct divedatapoint {
int time;
int time = 0;
depth_t depth;
int cylinderid;
int cylinderid = 0;
pressure_t minimum_gas;
int setpoint;
bool entered;
enum divemode_t divemode;
int setpoint = 0;
bool entered = false;
enum divemode_t divemode = OC;
divedatapoint() = default;
divedatapoint(const divedatapoint &) = default;
divedatapoint(divedatapoint &&) = default;
divedatapoint &operator=(const divedatapoint &) = default;
divedatapoint(int time_incr, int depth, int cylinderid, int po2, bool entered);
};
typedef enum {
PLAN_OK,
PLAN_ERROR_TIMEOUT,
PLAN_ERROR_INAPPROPRIATE_GAS,
} planner_error_t;
struct diveplan {
diveplan();
~diveplan();
@ -33,19 +45,15 @@ struct diveplan {
std::vector<divedatapoint> dp;
int eff_gflow = 0, eff_gfhigh = 0;
int surface_interval = 0;
bool is_empty() const;
void add_plan_to_notes(struct dive &dive, bool show_disclaimer, planner_error_t error);
int duration() const;
};
struct deco_state_cache;
typedef enum {
PLAN_OK,
PLAN_ERROR_TIMEOUT,
PLAN_ERROR_INAPPROPRIATE_GAS,
} planner_error_t;
extern int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
extern bool diveplan_empty(const struct diveplan &diveplan);
extern void add_plan_to_notes(struct diveplan &diveplan, struct dive *dive, bool show_disclaimer, planner_error_t error);
extern const char *get_planner_disclaimer();
void plan_add_segment(struct diveplan &diveplan, int duration, int depth, int cylinderid, int po2, bool entered, enum divemode_t divemode);