core: default initialize units-type objects to 0

Makes the code much nicer to read.

Default initialize cylinder_t to the empty cylinder.

This produces lots of warnings, because most structure are now
not PODs anymore and shouldn't be erased using memset().

These memset()s will be removed one-by-one and replaced by
proper constructors.

The whole ordeal made it necessary to add a constructor to
struct event. To simplify things the whole optimization of
the variable-size event names was removed. In upcoming commits
this will be replaced by std::string anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 19:15:47 +02:00 committed by bstoeger
parent b82fdd1d20
commit 408b31b6ce
34 changed files with 128 additions and 148 deletions

View file

@ -7,6 +7,7 @@
#include <memory>
#include <string>
#include <array>
#include <vector>
enum velocity_t {
@ -32,7 +33,7 @@ struct divecomputer;
* sensor data for a given cylinder
*/
struct plot_pressure_data {
int data[NUM_PLOT_PRESSURES];
std::array<int, NUM_PLOT_PRESSURES> data;
};
struct plot_data {
@ -42,8 +43,8 @@ struct plot_data {
/* Depth info */
int depth = 0;
int ceiling = 0;
int ceilings[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int percentages[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
std::array<int, 16> ceilings;
std::array<int, 16> percentages;
int ndl = 0;
int tts = 0;
int rbt = 0;
@ -55,10 +56,10 @@ struct plot_data {
int running_sum = 0;
struct gas_pressures pressures;
// TODO: make pressure_t default to 0
pressure_t o2pressure = { 0 }; // for rebreathers, this is consensus measured po2, or setpoint otherwise. 0 for OC.
pressure_t o2sensor[MAX_O2_SENSORS] = {{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }}; //for rebreathers with several sensors
pressure_t o2setpoint = { 0 };
pressure_t scr_OC_pO2 = { 0 };
pressure_t o2pressure; // for rebreathers, this is consensus measured po2, or setpoint otherwise. 0 for OC.
std::array<pressure_t, MAX_O2_SENSORS> o2sensor; //for rebreathers with several sensors
pressure_t o2setpoint;
pressure_t scr_OC_pO2;
int mod = 0, ead = 0, end = 0, eadd = 0;
velocity_t velocity = STABLE;
int speed = 0;