|
Maki
Formally verfied low-code orchestration
|
Executes and manages a sequence of external processes. More...
#include <pipeline.h>
Classes | |
| struct | ProcessInfo |
| struct | GroupInfo |
| struct | Info |
| struct | PipelineProcess |
| Internal representation of a process registered in the pipeline. More... | |
| struct | PipelineGroup |
| Internal representation of a group of processes. More... | |
Public Types | |
| enum class | State { Unknown , Idle , Running , Aborting , Done , Error } |
| Internal state of the pipeline execution. More... | |
Signals | |
| void | startingProcess (const Info &info, const QString &process, const QStringList &arguments) |
| Emitted before a process starts. | |
| void | processStarted (const Info &info, const QString &process, const QStringList &arguments) |
| Emitted after a process starts. | |
| void | finished (const Info &info, int exitCode, QProcess::ExitStatus status) |
| Emitted when the currently running process finishes. | |
| void | finishedLast (const Info &info, int exitCode, const QString &message) |
| Emitted when the last process in the pipeline finishes. | |
| void | startingPipeline (const Info &info) |
| Emitted when the complete pipeline is started. | |
| void | startingGroup (const Info &info, const QString &groupName) |
| Emitted before a group starts. | |
| void | finishedGroup (const Info &info, const QString &groupName, int exitCode, const QString &message) |
| Emitted when the last process in a group finishes. | |
| void | readyReadStandardOutput (const QByteArray &message) |
| Emitted when new data is available on the standard output stream. | |
| void | readyReadStandardError (const QByteArray &message) |
| Emitted when new data is available on the standard error stream. | |
| void | errorOccurred (const Info &info, QProcess::ProcessError error, const QString &message) |
| Emitted when a process error occurs. | |
Public Member Functions | |
| Pipeline (QObject *parent=nullptr) | |
| Constructs a Pipeline instance. | |
| ~Pipeline () | |
| Destructs a Pipeline instance. | |
| VoidResult | add (QProcess *process, maki::OnFail onFail, std::function< void(int &exitCode, QProcess::ExitStatus &status)> callback=nullptr) override |
| Adds a process to the pipeline. | |
| VoidResult | start () |
| Starts executing the pipeline. | |
| QString | name () const |
| Returns the pipeline name. | |
| void | setName (const QString &name) |
| Sets the pipeline name. | |
| int | size () const |
| Returns the number of processes registered in the pipeline. | |
| bool | isRunning () const |
| Indicates whether the pipeline is currently running. | |
| VoidResult | abort (bool syncAbort=false) |
| Aborts the currently running pipeline. | |
Private Slots | |
| void | onReadyReadStandardOutput () |
| Slot triggered when the process produces standard output. | |
| void | onReadyReadStandardError () |
| Slot triggered when the process produces standard error output. | |
| void | onFinished (int exitCode, QProcess::ExitStatus status) |
| Slot triggered when a process finishes execution. | |
| void | onErrorOccurred (QProcess::ProcessError error) |
| Slot triggered when a process error occurs. | |
Private Member Functions | |
| void | startNextOrEnd (int exitCode, QProcess::ExitStatus status) |
| Starts the next process or ends the pipeline. | |
| bool | handleInputData (QByteArray &data) const |
| Processes incoming output data from the running process. | |
Private Attributes | |
| std::mutex | mStateMutex |
| Mutex protecting access to the pipeline state. | |
| QString | mName |
| Name of the pipeline. | |
| std::shared_ptr< PipelineProcess > | mRunningProcess |
| Currently running process. | |
Executes and manages a sequence of external processes.
Pipeline provides a simple orchestration mechanism for running a set of QProcess instances sequentially. Each process can define a failure policy and an optional callback that is invoked when the process finishes.
The class emits signals to allow observers (such as UI components) to track process execution, receive output streams, and react to failures.
|
strong |
| Pipeline::Pipeline | ( | QObject * | parent = nullptr | ) |
Constructs a Pipeline instance.
| parent | Optional Qt parent object. |
| VoidResult Pipeline::abort | ( | bool | syncAbort = false | ) |
Aborts the currently running pipeline.
If a process is currently executing, the pipeline transitions to the aborting state and stops further execution.
|
override |
Adds a process to the pipeline.
The process will be executed in the order it was added. The behavior in case of failure is determined by the provided OnFail policy.
| process | Pointer to the QProcess to execute. |
| onFail | Policy describing what should happen if the process fails. |
| callback | Optional callback executed when the process finishes. |
|
signal |
Emitted when a process error occurs.
| info | Information about the pipeline and group. |
| error | Error reported by QProcess. |
| message | Additional message. |
|
signal |
Emitted when the currently running process finishes.
| info | Information about the pipeline and group. |
| exitCode | Exit code returned by the process. |
| status | Exit status reported by QProcess. |
|
signal |
Emitted when the last process in a group finishes.
| info | Information about the pipeline and group. |
| groupName | Name of the group which finished |
| exitCode | Exit code returned by the process. |
| message | Additional message. |
|
signal |
Emitted when the last process in the pipeline finishes.
| info | Information about the pipeline and group. |
| exitCode | Exit code returned by the process. |
| message | Additional message. |
|
private |
Processes incoming output data from the running process.
This may perform filtering, buffering, or preprocessing of the data before it is emitted through signals.
| data | Data read from the process stream. |
| bool Pipeline::isRunning | ( | ) | const |
Indicates whether the pipeline is currently running.
| QString Pipeline::name | ( | ) | const |
Returns the pipeline name.
|
privateslot |
Slot triggered when a process error occurs.
| error | Error reported by QProcess. |
|
privateslot |
Slot triggered when a process finishes execution.
| exitCode | Exit code returned by the process. |
| status | Exit status reported by QProcess. |
|
signal |
Emitted after a process starts.
Allows observers to track which external command is being executed.
| info | Information about the pipeline and group. |
| process | Executable name. |
| arguments | Command line arguments. |
|
signal |
Emitted when new data is available on the standard error stream.
| message | Data read from the process stderr. |
|
signal |
Emitted when new data is available on the standard output stream.
| message | Data read from the process stdout. |
| void Pipeline::setName | ( | const QString & | name | ) |
Sets the pipeline name.
| name | New pipeline name. |
| int Pipeline::size | ( | ) | const |
Returns the number of processes registered in the pipeline.
| VoidResult Pipeline::start | ( | ) |
Starts executing the pipeline.
Processes will be executed sequentially until the pipeline finishes, aborts, or encounters a failure depending on the configured policy.
|
signal |
Emitted before a group starts.
Allows observers to track which group is being executed
| info | Information about the pipeline and group. |
| groupName | Name of the group which is starting |
|
signal |
Emitted when the complete pipeline is started.
| info | Information about the pipeline and group. |
|
signal |
Emitted before a process starts.
Allows observers to track which external command is being executed.
| info | Information about the pipeline and group. |
| process | Executable name. |
| arguments | Command line arguments. |
|
private |
Starts the next process or ends the pipeline.
This method decides whether to continue with the next process or finish the pipeline depending on the exit status and failure policies.
| exitCode | Exit code of the completed process. |
| status | Exit status of the completed process. |