2024-11-11 08:29:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QHash>
|
2024-11-20 10:31:31 +00:00
|
|
|
#include <memory>
|
2024-11-11 08:29:59 +00:00
|
|
|
#include "cmds_basic.h"
|
2024-11-17 15:36:43 +00:00
|
|
|
#include "validate_basic.h"
|
2024-11-11 08:29:59 +00:00
|
|
|
|
|
|
|
namespace dispatch {
|
|
|
|
class IOutput {
|
|
|
|
public:
|
|
|
|
virtual ~IOutput() = default;
|
|
|
|
|
2024-11-20 10:31:31 +00:00
|
|
|
virtual void write(const QString &type, const QString& title, const QString& desc) = 0;
|
|
|
|
virtual void flush() = 0;
|
2024-11-11 08:29:59 +00:00
|
|
|
};
|
|
|
|
|
2024-11-17 14:08:08 +00:00
|
|
|
|
2024-11-11 08:29:59 +00:00
|
|
|
class Dispatch {
|
|
|
|
private:
|
|
|
|
QHash<quint64, std::pair<QString, Inlet::IRunbase*>> _cmds_map;
|
2024-11-17 14:08:08 +00:00
|
|
|
QHash<quint64, validate::IValidatorTemplet*> _cmds_validators;
|
2024-11-11 08:29:59 +00:00
|
|
|
QHash<quint64, std::pair<QString, Inlet::IRunbase*>> _events_map;
|
|
|
|
|
2024-11-20 10:31:31 +00:00
|
|
|
QList<std::shared_ptr<IOutput>> _output_list;
|
2024-11-11 08:29:59 +00:00
|
|
|
|
2024-11-17 14:08:08 +00:00
|
|
|
static Dispatch* _unique_inst;
|
|
|
|
|
2024-11-11 08:29:59 +00:00
|
|
|
public:
|
2024-11-17 14:08:08 +00:00
|
|
|
static Dispatch* unique();
|
|
|
|
|
2024-11-20 10:31:31 +00:00
|
|
|
void loadOutput(std::shared_ptr<IOutput> out_ins);
|
|
|
|
|
2024-11-11 08:29:59 +00:00
|
|
|
QList<quint64> allCmds() const;
|
2024-11-17 14:08:08 +00:00
|
|
|
void registerCmd(quint64 addr, Inlet::IRunbase* unit);
|
|
|
|
void setCmdAlias(quint64 addr, const QString& alias);
|
|
|
|
void setCmdValidator(quint64 addr, validate::IValidatorTemplet* inst);
|
2024-11-11 08:29:59 +00:00
|
|
|
QString getCmdAlias(quint64 addr) const;
|
|
|
|
QString getCmdDefault(quint64 addr) const;
|
|
|
|
void runWith(Inlet::IRunbase* unit);
|
|
|
|
|
2024-11-18 15:33:51 +00:00
|
|
|
void getValidateDepict(datas::IDataObject &object) const;
|
|
|
|
|
2024-11-11 08:29:59 +00:00
|
|
|
QList<quint64> allEvents() const;
|
2024-11-17 14:08:08 +00:00
|
|
|
void registerEvent(quint64 addr, Inlet::IRunbase* unit);
|
|
|
|
void setEventAlias(quint64 addr, const QString& alias);
|
2024-11-11 08:29:59 +00:00
|
|
|
QString getEventAlias(quint64 addr) const;
|
|
|
|
QString getEventDefault(quint64 addr) const;
|
2024-11-17 14:08:08 +00:00
|
|
|
void notifyWith(Inlet::IRunbase* unit);
|
2024-11-11 08:29:59 +00:00
|
|
|
|
|
|
|
};
|
2024-11-17 14:08:08 +00:00
|
|
|
|
2024-11-11 08:29:59 +00:00
|
|
|
}
|