mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
1daa4f0584
The old code was wild: For the yearly statistics it would allocate one entry per dive in the log. Of course, it would also leak C-style strings. Convert the whole thing to somewhat idiomatic C++. Somewhat wasted work, because I'd like to convert the whole thing to the new statistics code. But let's finish the conversion to C++ first. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* statistics.h
|
|
*
|
|
* core logic functions called from statistics UI
|
|
* common types and variables
|
|
*/
|
|
|
|
#ifndef STATISTICS_H
|
|
#define STATISTICS_H
|
|
|
|
#include "core/units.h"
|
|
|
|
#define STATS_MAX_DEPTH 300 /* Max depth for stats bucket is 300m */
|
|
#define STATS_DEPTH_BUCKET 10 /* Size of buckets for depth range */
|
|
#define STATS_MAX_TEMP 40 /* Max temp for stats bucket is 40C */
|
|
#define STATS_TEMP_BUCKET 5 /* Size of buckets for temp range */
|
|
|
|
struct dive;
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct stats_t
|
|
{
|
|
int period = 0;
|
|
duration_t total_time = { 0 };
|
|
/* total time of dives with non-zero average depth */
|
|
duration_t total_average_depth_time = { 0 };
|
|
/* avg_time is simply total_time / nr -- let's not keep this */
|
|
duration_t shortest_time = { 0 };
|
|
duration_t longest_time = { 0 };
|
|
depth_t max_depth = { 0 };
|
|
depth_t min_depth = { 0 };
|
|
depth_t avg_depth = { 0 };
|
|
depth_t combined_max_depth = { 0 };
|
|
volume_t max_sac = { 0 };
|
|
volume_t min_sac = { 0 };
|
|
volume_t avg_sac = { 0 };
|
|
temperature_t max_temp = { 0 };
|
|
temperature_t min_temp = { 0 };
|
|
temperature_sum_t combined_temp = { 0 };
|
|
unsigned int combined_count = 0;
|
|
unsigned int selection_size = 0;
|
|
duration_t total_sac_time = { 0 };
|
|
bool is_year = false;
|
|
bool is_trip = false;
|
|
std::string location;
|
|
};
|
|
|
|
struct stats_summary {
|
|
stats_summary();
|
|
~stats_summary();
|
|
std::vector<stats_t> stats_yearly;
|
|
std::vector<stats_t> stats_monthly;
|
|
std::vector<stats_t> stats_by_trip;
|
|
std::vector<stats_t> stats_by_type;
|
|
std::vector<stats_t> stats_by_depth;
|
|
std::vector<stats_t> stats_by_temp;
|
|
};
|
|
|
|
extern stats_summary calculate_stats_summary(bool selected_only);
|
|
extern stats_t calculate_stats_selected();
|
|
extern std::vector<volume_t> get_gas_used(struct dive *dive);
|
|
extern std::pair<volume_t, volume_t> selected_dives_gas_parts(); // returns (O2, He) tuple
|
|
|
|
#endif
|
|
|
|
#endif // STATISTICS_H
|