diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-05 23:14:07 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-07-18 05:50:22 -0700 |
commit | 469cc68b029ac3308b4338a43acfa21679493e8b (patch) | |
tree | 110eaf78f7c1123784313009f2b8ee4844ec16f8 /core/profile.h | |
parent | 29005b578de4680556f6a3fa01781a8af842ced8 (diff) | |
download | subsurface-469cc68b029ac3308b4338a43acfa21679493e8b.tar.gz |
Cleanup: replace pressure reading macros by inline functions
Replace the INTERPOLATED_PRESSURE and SENSOR_PRESSURE macros by
inline functions. Generate a common inline function that reads
a pressure value for a dynamic sensor.
Not all SENSOR_PRESSURE macros can be replaced, because the
macro is also used to set the value and C sadly doesn't know
the concept of "return reference from a function".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/profile.h')
-rw-r--r-- | core/profile.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/core/profile.h b/core/profile.h index 8e2912671..761f270d7 100644 --- a/core/profile.h +++ b/core/profile.h @@ -98,12 +98,26 @@ int get_maxdepth(struct plot_info *pi); #define SENSOR_PR 0 #define INTERPOLATED_PR 1 #define SENSOR_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][SENSOR_PR] -#define INTERPOLATED_PRESSURE(_entry,_idx) (_entry)->pressure[_idx][INTERPOLATED_PR] + +static inline int get_plot_pressure_data(const struct plot_data *entry, int sensor, int idx) +{ + return entry->pressure[idx][sensor]; +} + +static inline int get_plot_sensor_pressure(const struct plot_data *entry, int idx) +{ + return get_plot_pressure_data(entry, SENSOR_PR, idx); +} + +static inline int get_plot_interpolated_pressure(const struct plot_data *entry, int idx) +{ + return get_plot_pressure_data(entry, INTERPOLATED_PR, idx); +} static inline int get_plot_pressure(const struct plot_data *entry, int idx) { - int res = SENSOR_PRESSURE(entry, idx); - return res ? res : INTERPOLATED_PRESSURE(entry, idx); + int res = get_plot_sensor_pressure(entry, idx); + return res ? res : get_plot_interpolated_pressure(entry, idx); } #ifdef __cplusplus |