diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-05 20:55:57 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-16 14:26:37 -0700 |
commit | c4bfecce1bcd9a7b5f2fc85b1466adf9a1d2336a (patch) | |
tree | 1d7e7def04354b5cdb9735adb0370aac773d07e4 /core/device.h | |
parent | 4a50badb57efd7725fa540ea7bb13f1e334cb83c (diff) | |
download | subsurface-c4bfecce1bcd9a7b5f2fc85b1466adf9a1d2336a.tar.gz |
core: add C struct device and struct device_table accessors
Up to now, "struct device" and "struct device_table" were C++
only, because they used C++ strings for convenience. Since we
switched from QString to std::string, we can create accessors
for these structs. For the C code, we simply declare them as
opaque structs and give the full definition only for C++.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/device.h')
-rw-r--r-- | core/device.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/device.h b/core/device.h index 28ad696bb..a976a7e64 100644 --- a/core/device.h +++ b/core/device.h @@ -9,15 +9,30 @@ extern "C" { #endif struct divecomputer; +struct device; +struct device_table; + +// global device table +extern struct device_table device_table; + extern void fake_dc(struct divecomputer *dc); extern void set_dc_deviceid(struct divecomputer *dc, unsigned int deviceid); extern void set_dc_nickname(struct dive *dive); extern void create_device_node(const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname); +extern int nr_devices(const struct device_table *table); +extern const struct device *get_device(const struct device_table *table, int i); extern void call_for_each_dc(void *f, void (*callback)(void *, const char *, uint32_t, const char *, const char *, const char *), bool select_only); extern void clear_device_nodes(); const char *get_dc_nickname(const struct divecomputer *dc); +// struct device accessors for C-code. The returned strings are not stable! +const char *device_get_model(const struct device *dev); +const uint32_t device_get_id(const struct device *dev); +const char *device_get_serial(const struct device *dev); +const char *device_get_firmware(const struct device *dev); +const char *device_get_nickname(const struct device *dev); + #ifdef __cplusplus } #endif @@ -44,8 +59,6 @@ struct device_table { std::vector<device> devices; }; -extern struct device_table device_table; - #endif #endif // DEVICE_H |