50, m_bIsActive(p_bIsActive)
59, m_bIsActive(p_bIsActive)
63 m_jsonDocumentOrigin = QJsonDocument::fromJson(p_qByteArrayJsonDoc);
65 insert(m_jsonDocumentOrigin);
72, m_bIsActive(p_bIsActive)
73, m_jsonDocumentOrigin(p_jsonDoc)
77 insert(m_jsonDocumentOrigin);
94 m_qMapCommands.clear();
99void CommandManager::init()
107 QJsonObject t_jsonObjectCommand;
110 if(p_jsonDocument.isObject() && p_jsonDocument.object().value(QString(
"commands")) != QJsonValue::Undefined)
111 t_jsonObjectCommand = p_jsonDocument.object().value(QString(
"commands")).toObject();
115 QJsonObject::Iterator it;
116 for(it = t_jsonObjectCommand.begin(); it != t_jsonObjectCommand.end(); ++it)
118 if(!m_qMapCommands.contains(it.key()))
119 m_qMapCommands.insert(it.key(),
Command(it.key(), it.value().toObject(),
true,
this));
121 qWarning(
"Warning: CommandMap contains command %s already. Insertion skipped.\n", it.key().toUtf8().constData());
131 Command t_command(p_sKey, p_sDescription,
false,
this);
132 insert(p_sKey, t_command);
140 t_command.setParent(
this);
141 m_qMapCommands.insert(p_sKey, t_command);
156 QString t_sCommandName = t_rawCommand.
command();
162 if(t_rawCommand.
count() >= m_qMapCommands[t_sCommandName].count())
164 m_qMapCommands[t_sCommandName].isJson() = t_rawCommand.
isJson();
167 for(quint32 i = 0; i < m_qMapCommands[t_sCommandName].count(); ++i)
169 QMetaType t_metaType = m_qMapCommands[t_sCommandName][i].metaType();
171 QVariant t_qVariantParam(t_rawCommand.
pValues()[i]);
173 if(t_qVariantParam.canConvert(t_metaType) && t_qVariantParam.convert(t_metaType))
174 m_qMapCommands[t_sCommandName][i] = t_qVariantParam;
179 m_qMapCommands[t_sCommandName].execute();
187 return m_qMapCommands[key];
194 return m_qMapCommands[key];
Per-component registry of COMLIB::Command schemas; receives COMLIB::RawCommand from the parser and di...
Untyped intermediate produced by COMLIB::CommandParser before type information is bound to parameters...
Real-time client/server communication primitives for talking to mne_rt_server.
Named, parameterised command exchanged with mne_rt_server; supports both JSON and CLI serialisation.
virtual void update(UTILSLIB::Subject *p_pSubject)
bool hasCommand(const QString &p_sCommand) const
CommandManager(bool p_bIsActive=true, QObject *parent=0)
Command & operator[](const QString &key)
virtual ~CommandManager()
void insert(const QJsonDocument &p_jsonDocument)
Observer-pattern subject that decodes JSON or CLI command strings into RawCommand and notifies attach...
RawCommand & getRawCommand()
Tokenised but unresolved command: a keyword plus a list of raw string arguments awaiting type binding...
QList< QString > & pValues()
The Subject class provides the base class of every subject of the observer design pattern.