-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.h
62 lines (46 loc) · 1.36 KB
/
controller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef EVOBOT_CONTROLLER_H
#define EVOBOT_CONTROLLER_H
#include <QObject>
namespace EvoBot {
class RobotService;
class Controller : public QObject
{
Q_OBJECT
Q_PROPERTY(int error READ error NOTIFY errorOccured FINAL)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorOccured FINAL)
Q_PROPERTY(int state READ state NOTIFY stateChanged FINAL)
Q_PROPERTY(EvoBot::RobotService *robotService READ robotService CONSTANT FINAL)
public:
enum State {
UninitializedState,
DeviceDiscoveryState,
ServiceDiscoveryState,
ConnectingState,
ConnectedState,
ErrorState,
};
Q_ENUM(State)
enum Error {
NoError,
BluetoothMissingError,
DeviceDiscoveryError,
DeviceError,
};
Q_ENUM(Error)
explicit Controller(QObject *parent = {});
~Controller();
Error error() const;
QString errorString() const;
State state() const;
Q_INVOKABLE static QByteArray stateName(int state) { return stateName(static_cast<State>(state)); }
static const char *stateName(State state);
RobotService *robotService() const;
signals:
void errorOccured(Error error, const QString &errorString);
void stateChanged(State newState, State oldState);
private:
class Private;
Private *const d;
};
} // namespace EvoBot
#endif // EVOBOT_CONTROLLER_H