2022-01-06 19:29:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QVariantList>
|
|
|
|
|
|
|
|
namespace Signals
|
|
|
|
{
|
|
|
|
Q_NAMESPACE
|
|
|
|
|
|
|
|
enum SignalType
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Unknown,
|
|
|
|
NodeLogin,
|
|
|
|
NodeReady,
|
|
|
|
NodeStarted,
|
|
|
|
NodeStopped,
|
|
|
|
NodeCrashed
|
2022-01-06 19:29:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_ENUM_NS(SignalType)
|
|
|
|
|
|
|
|
struct Signal
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
SignalType signalType;
|
2022-01-06 19:29:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct NodeSignal : Signal
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
QString error;
|
2022-01-06 19:29:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Manager : public QObject
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Q_OBJECT
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
public:
|
2022-02-21 18:03:38 +00:00
|
|
|
static Manager* instance();
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
signals:
|
2022-02-21 18:03:38 +00:00
|
|
|
void signal(SignalType signal);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
void nodeReady(NodeSignal signal);
|
|
|
|
void nodeStarted(NodeSignal signal);
|
|
|
|
void nodeStopped(NodeSignal signal);
|
|
|
|
void nodeLogin(NodeSignal signal);
|
|
|
|
void nodeCrashed(NodeSignal signal);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
|
|
|
private:
|
2022-02-21 18:03:38 +00:00
|
|
|
explicit Manager(QObject* parent = nullptr);
|
|
|
|
static std::map<QString, SignalType> signalMap;
|
|
|
|
static void signalCallback(const char* data);
|
|
|
|
void processSignal(QString ev);
|
|
|
|
void decode(const QJsonObject& signalEvent);
|
2022-01-06 19:29:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Signals
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Signals::Signal)
|
2022-02-21 18:03:38 +00:00
|
|
|
Q_DECLARE_METATYPE(Signals::NodeSignal)
|