v2.0.0
Loading...
Searching...
No Matches
command_parser.h File Reference

Front-end tokeniser that turns incoming JSON or CLI payloads into COMLIB::RawCommand objects and notifies attached managers. More...

#include "../com_global.h"
#include "raw_command.h"
#include "command.h"
#include <utils/generics/observerpattern.h>
#include <QObject>
#include <QVector>
#include <QMultiMap>
Include dependency graph for command_parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  COMLIB::CommandParser
 Observer-pattern subject that decodes JSON or CLI command strings into RawCommand and notifies attached managers. More...

Namespaces

namespace  COMLIB
 Real-time client/server communication primitives for talking to mne_rt_server.

Detailed Description

Front-end tokeniser that turns incoming JSON or CLI payloads into COMLIB::RawCommand objects and notifies attached managers.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.0.0
Date
March 2026

COMLIB::CommandParser owns the Subject side of the observer pattern in utils/generics: every COMLIB::CommandManager that wants to react to a slice of the command vocabulary attaches itself, and the parser then fans every accepted request out to all of them. That decoupling lets multiple subsystems (data acquisition, source estimation, GUI plumbing) each register only the commands they know how to handle without growing a single monolithic dispatcher.

Two wire dialects are accepted on the same entry point. CLI input is whitespace-tokenised into a command keyword plus string arguments; JSON input is decoded with QJsonDocument and may contain either a single command object or an array of commands, allowing batched requests in one round-trip. In either case the result is the same untyped RawCommand handed to the observers — the type-aware Command is constructed downstream once a manager has identified which schema applies.

parse() returns true when at least one observer claimed the input and additionally records the names of the recognised commands in p_qListCommandsParsed; the response(QString, Command) signal is the reverse channel used by managers to push reply text back to whichever socket originally produced the request.

Definition in file command_parser.h.