mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
a01ab81713
core/device.h was declaring a number of functions that were related to divecomputers (dcs): creating a fake dc for manually entered dives and registering / accessing dc nicknames. On could argue whether these should be lumped together, but it is what it is. However, part of that was implemented in C++/Qt code in a separate core/divecomputer.cpp file. Some function therein where only accessible to C++ and declared in core/divecomputer.h. All in all, a big mess. Let's simply combine the files and conditionally compile the C++-only functions depending on the __cplusplus define. Yes, that means turning device.c into device.cpp. A brave soul might turn the C++/Qt code into C code if they whish later on. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef DEVICE_H
|
|
#define DEVICE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct divecomputer;
|
|
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 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();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
// Functions and global variables that are only available to C++ code
|
|
#ifdef __cplusplus
|
|
|
|
#include <QString>
|
|
#include <QVector>
|
|
class DiveComputerNode {
|
|
public:
|
|
bool operator==(const DiveComputerNode &a) const;
|
|
bool operator!=(const DiveComputerNode &a) const;
|
|
bool operator<(const DiveComputerNode &a) const;
|
|
void showchanges(const QString &n, const QString &s, const QString &f) const;
|
|
QString model;
|
|
uint32_t deviceId;
|
|
QString serialNumber;
|
|
QString firmware;
|
|
QString nickName;
|
|
};
|
|
|
|
class DiveComputerList {
|
|
public:
|
|
const DiveComputerNode *getExact(const QString &m, uint32_t d);
|
|
const DiveComputerNode *get(const QString &m);
|
|
void addDC(QString m, uint32_t d, QString n = QString(), QString s = QString(), QString f = QString());
|
|
|
|
// Keep the dive computers in a vector sorted by (model, deviceId)
|
|
QVector<DiveComputerNode> dcs;
|
|
};
|
|
|
|
QString get_dc_nickname(const struct divecomputer *dc);
|
|
extern DiveComputerList dcList;
|
|
|
|
#endif
|
|
|
|
#endif // DEVICE_H
|