Skip to main content

CommandManager

Namespace: COMLIB  ·  Library: Communication Library

#include <com/command_manager.h>

class COMLIB::CommandManager

Observer-side registry of Command schemas a subsystem accepts from the shared CommandParser.

Holds a QMap<QString,Command> indexed by command keyword; when CommandParser notifies attached managers of a new RawCommand, each manager looks the keyword up in its own map and either dispatches the corresponding Command (re-emitting triggered / response) or silently passes. Schemas can be added one at a time or bulk-loaded from a QJsonDocument matching the server’s self-described command list.

Inheritance​


Public Methods​

CommandManager(p_bIsActive, parent)​


CommandManager(p_qByteArrayJsonDoc, p_bIsActive, parent)​


CommandManager(p_jsonDoc, p_bIsActive, parent)​


~CommandManager()​


clear()​

Clears the command manager.


commandMap()​

Returns the lookup table of all available commands.

Returns:

  • QMap< QString, Command > & — the command lookup table.

hasCommand(p_sCommand)​

Checks if a command is managed;.

Parameters:

  • p_sCommand : const QString & COmmand to check.

Returns:

  • bool — true if part of command manager, false otherwise.

insert(p_jsonDocument)​

Inserts commands encoded in a json document.

Attention existing items are overwritten.

Parameters:

  • p_jsonDocument : const QJsonDocument & JSON document containing commands.

insert(p_sKey, p_sDescription)​

Inserts a single command.

Attention existing items are overwritten.

Parameters:

  • p_sKey : const QString & Command name used as the key.

  • p_sDescription : const QString & Human-readable description of the command.


insert(p_sKey, p_command)​

Inserts a new command and emmits dataChanged signal.

Parameters:

  • p_sKey : const QString & Command key word.

  • p_command : const Command & Command content. Attention CommandManager takes ownership of that command by reseting commad's parent;.


isActive()​

Returns if CommandManager is active.

If true, this manager parses incomming commands.

Returns:

  • bool — if true, incomming commands are parsed.

setStatus(status)​

Sets the activation status of the CommandManager.

Parameters:


update(p_pSubject)​

Updates the IObserver (CommandManager) when a new command was received.

Parameters:


operator[](key)​

Subscript operator [] to access commands by command name.

Parameters:

  • key : const QString & the command key word.

Returns:


operator[](key)​

Subscript operator [] to access commands by command name.

Parameters:

  • key : const QString & the command key word.

Returns:


Authors of this file​