Command
Namespace: COMLIB · Library: Communication Library
#include <com/command.h>
class COMLIB::Command
Named, parameterised command exchanged with mne_rt_server; supports both JSON and CLI serialisation.
Holds the command keyword, description, parallel lists of parameter names / values / descriptions, and a JSON-vs-CLI flag. Constructible either from a parsed QJsonObject (when echoing the server’s advertised command list) or from explicit string/value lists (when authoring a request). Implements ICommand so it can be dispatched through CommandManager and surfaces parameter access by both name (operator[](QString)) and index (operator[](qint32)).
Inheritance
Public Methods
Command(p_bIsJson, parent)
Constructs a Command.
Parameters:
-
p_bIsJson : bool If is received/should be send as JSON (optional, default true).
-
parent : *QObject ** Parent QObject (optional).
Command(p_sCommand, p_qCommandContent, p_bIsJson, parent)
Constructor which parses a command stored in a json object.
Parameters:
-
p_sCommand : const QString &
Command. -
p_qCommandContent : const QJsonObject & Content encapsulated in a JsonObject.
-
p_bIsJson : bool If is received/should be send as JSON (optional, default true).
-
parent : *QObject ** Parent QObject (optional).
Command(p_sCommand, p_sDescription, p_bIsJson, parent)
Constructs a command without parameters.
Parameters:
-
p_sCommand : const QString &
Command. -
p_sDescription : const QString &
Commanddescription. -
p_bIsJson : bool If is received/should be send as JSON (optional, default true).
-
parent : *QObject ** Parent QObject (optional).
Command(p_sCommand, p_sDescription, p_qListParamNames, p_qListParamValues, p_bIsJson, parent)
Constructor which assembles a command from single parts.
Parameters:
-
p_sCommand : const QString &
Command. -
p_sDescription : const QString &
Commanddescription. -
p_qListParamNames : const QStringList & Parameter names.
-
p_qListParamValues : const QList< QVariant > & Parameter values/types.
-
p_bIsJson : bool If is received/should be send as JSON (optional, default true).
-
parent : *QObject ** Parent QObject (optional).
Command(p_sCommand, p_sDescription, p_qListParamNames, p_qListParamValues, p_vecParameterDescriptions, p_bIsJson, parent)
Constructor which assembles a command from single parts.
Parameters:
-
p_sCommand : const QString &
Command. -
p_sDescription : const QString &
Commanddescription. -
p_qListParamNames : const QStringList & Parameter names.
-
p_qListParamValues : const QList< QVariant > & Parameter values/types.
-
p_vecParameterDescriptions : const QStringList & Parameter descriptions;.
-
p_bIsJson : bool Whether the command is exchanged in JSON format.
-
parent : *QObject ** Parent QObject.
Command(p_Command)
Copy constructor.
Parameters:
- p_Command : const Command &
Commandto be copied.
~Command()
Destroys the command.
command()
Short command for this request.
Returns:
- QString — Short command representation.
count()
Returns the number of parameters.
Returns:
- quint32 — number of parameters.
description()
Gets the help text or description of this command.
Returns:
- QString — Help text.
execute()
Inherited by ICommand.
Emits received().
isJson()
If received command was Json fomratted or triggered command should be Json formatted.
Returns:
- bool & — Json formatted.
pDescriptions()
Get parameter descriptions.
Returns:
- QList< QString > — parameter descriptions.
pNames()
Get parameter names.
Returns:
- QList< QString > — parameter names.
pValues()
Returns parameter values.
Returns:
- QList< QVariant > & — parameter values.
reply(p_sReply)
Inherited command reply channel.
Parameters:
- p_sReply : const QString & command reply.
send()
Sender slot which emmits triggered signal.
toJsonObject()
Creates a JSON Command Object.
Returns:
- QJsonObject —
Commandconverted to a JSON Object.
toStringList()
Creates a StringList with three items.
First item is the command, second the parameter list and thrid the description.
Returns:
- QStringList —
Commandas a StringList.
toStringReadySend()
Creates a string JSON formatted ready send command.
Returns:
- QString —
Commandas a JSON formatted string which contains parameter values too.
operator=(rhs)
Assignment Operator.
Parameters:
Returns:
- Command & — Reference to this object.
operator[](key)
Subscript operator [] to access parameter values by name.
Parameters:
- key : const QString & the parameter name.
Returns:
- QVariant & — Parameter value related to the parameter name.
operator[](idx)
Subscript operator [] to access parameter values by index.
Parameters:
- idx : qint32 the parameter index.
Returns:
- QVariant & — Parameter value related to the parameter index.
operator[](key)
Subscript operator [].
Parameters:
- key : const QString & the parameter name.
Returns:
- const QVariant — Parameter value related to the parameter name.
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>