WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. | Zuble QML Types | Zuble C++ Classes | Zuble Overview |
Zuble
0.1
Zuble Framework C++/QML extension API
|
QML/Javascript wrapper for the QProcess class, allows QML programs to spawn and communicate with a background operating system process. More...
#include <ZProcess.h>
Public Types | |
enum | ProcessError { FailedToStart = QProcess::FailedToStart, Crashed = QProcess::Crashed, Timedout = QProcess::Timedout, ReadError = QProcess::ReadError, WriteError = QProcess::WriteError, UnknownError = QProcess::UnknownError } |
enum | ProcessState { NotRunning = QProcess::NotRunning, Starting = QProcess::Starting, Running = QProcess::Running } |
enum | ProcessChannel { StandardOutput = QProcess::StandardOutput, StandardError = QProcess::StandardError } |
enum | ProcessChannelMode { SeparateChannels = QProcess::SeparateChannels, MergedChannels = QProcess::MergedChannels, ForwardedChannels = QProcess::ForwardedChannels, ForwardedOutputChannel = QProcess::ForwardedOutputChannel, ForwardedErrorChannel = QProcess::ForwardedErrorChannel } |
enum | ExitStatus { NormalExit = QProcess::NormalExit, CrashExit = QProcess::CrashExit } |
Public Slots | |
void | start (int mode=static_cast< int >(ZioDevice::ReadWrite)) |
Starts the process. More... | |
void | closeWriteChannel () |
Schedules the write channel of the process to close once all input data has been read by the process. More... | |
void | getQDevice (QIODevice **device) |
Obtains the QIODevice pointer for this object. More... | |
Signals | |
void | tagsChanged () |
void | started () |
void | finished (int exitCode, QProcess::ExitStatus exitStatus) |
void | errorOccurred (QProcess::ProcessError error) |
void | stateChanged (QProcess::ProcessState state, QPrivateSignal) |
void | readyReadStandardOutput (QPrivateSignal) |
void | readyReadStandardError (QPrivateSignal) |
Public Member Functions | |
ZProcess (QObject *parent=nullptr) | |
virtual | ~ZProcess () |
QObject * | getJsDevice () |
QVariant | getTags () |
QStringList | getArguments () |
Returns the arguments that will be passed to the process when it starts. More... | |
void | setArguments (const QStringList &arguments) |
Sets the arguments that will be passed to the process when it starts. More... | |
QString | getProgram () const |
Returns the path to the program the process will be started with. More... | |
void | setProgram (const QString &program) |
Sets the path to the program the process will be started with. More... | |
void | setProcessChannelMode (int mode) |
Sets the process channel mode that will be used the next time the process starts. More... | |
int | getProcessChannelMode () const |
Returns the channel mode of the QProcess standard output and standard error channels. More... | |
void | setReadChannel (int channel) |
Determine which read channel is currently active. More... | |
int | getReadChannel () const |
Obtain the current read channel. More... | |
qint64 | getProcessID () const |
Obtain the process ID. Note that Linux will reuse process IDs. They are ephemeral, not unique. More... | |
int | getState () const |
Obtains the current process state. More... | |
int | getError () const |
Obtains the current error state. More... | |
int | exitCode () const |
Obtains the exit code of the last process that finished. More... | |
int | exitStatus () const |
Obtains the exit status of the last process that finished. More... | |
Q_INVOKABLE void | envClear () |
Clears the process execution environment that will be passed to the child process. More... | |
Q_INVOKABLE QStringList | envGetList () |
Obtains the list of process environment variables that will be passed to the child process. More... | |
Q_INVOKABLE void | envSetValue (const QString &name, const QString &value) |
Sets an environment variable that will be passed to the child process. More... | |
Q_INVOKABLE QString | envGetValue (const QString &name) |
Returns the value of an environment variable that will be passed to the child process. More... | |
Q_INVOKABLE bool | envValueExists (const QString &name) |
Determine if an environment variable has been set to be passed to the child process. More... | |
Q_INVOKABLE void | closeReadChannel (int channel) |
Closes the specified read channel of the process. More... | |
Q_INVOKABLE QObject * | readAllStandardError () |
Obtains all available data from the process's stderr channel. More... | |
Q_INVOKABLE QObject * | readAllStandardOutput () |
Obtains all available data from the process's stdout channel. More... | |
Static Public Member Functions | |
static void | registerType () |
Registers ZFile as a QML type. More... | |
Protected Member Functions | |
ZBL_DECLARE_LOGGED_OBJECT void | initZioDevice () |
Construct and connect a ZioDevice object that presents a Javascript interface to this process's QIODevice object. More... | |
void | createTags () |
Create the m_tag object that presents a Javascript interface for QProcess enumeration values. More... | |
Protected Attributes | |
QProcess * | m_p |
Smart pointer to the embedded QFile object. More... | |
ZioDevice * | m_zd |
Pointer to QioDevice interface object. More... | |
Static Protected Attributes | |
static QVariant | m_tags |
A QVariantMap used to pass QFile enumeration values to Javascript programs. More... | |
Properties | |
QObject | device |
A ZioDevice object that represents the File's QioDevice interface. More... | |
QVariant | tags |
A Javascript object containing QFile enumeration values. More... | |
QStringList | arguments |
Set/get the argument list for the process. More... | |
QString | program |
Set/get the program for the process. More... | |
int | processChannelMode |
Set/get the process channel mode for the process. More... | |
int | readChannel |
Set/get the current read channel. More... | |
qint64 | processId |
Set/get the operating system process ID for the last process run by this object. More... | |
qint64 | state |
Obtain the current process state. More... | |
qint64 | error |
Obtain the process's current error state. More... | |
QML/Javascript wrapper for the QProcess class, allows QML programs to spawn and communicate with a background operating system process.
Child process will inherit the originating process environment unless modified by calling envClear() or envSetValue().
Definition at line 20 of file ZProcess.h.
Enumerator | |
---|---|
NormalExit | |
CrashExit |
Definition at line 57 of file ZProcess.h.
Enumerator | |
---|---|
StandardOutput | |
StandardError |
Definition at line 42 of file ZProcess.h.
Enumerator | |
---|---|
SeparateChannels | |
MergedChannels | |
ForwardedChannels | |
ForwardedOutputChannel | |
ForwardedErrorChannel |
Definition at line 48 of file ZProcess.h.
Enumerator | |
---|---|
FailedToStart | |
Crashed | |
Timedout | |
ReadError | |
WriteError | |
UnknownError |
Definition at line 25 of file ZProcess.h.
Enumerator | |
---|---|
NotRunning | |
Starting | |
Running |
Definition at line 35 of file ZProcess.h.
|
explicit |
Definition at line 13 of file ZProcess.cpp.
|
virtual |
Definition at line 34 of file ZProcess.cpp.
void Zbl::ZProcess::closeReadChannel | ( | int | channel | ) |
Closes the specified read channel of the process.
channel | The read channel to close |
Definition at line 154 of file ZProcess.cpp.
|
slot |
Schedules the write channel of the process to close once all input data has been read by the process.
Definition at line 149 of file ZProcess.cpp.
|
protected |
Create the m_tag object that presents a Javascript interface for QProcess enumeration values.
Definition at line 55 of file ZProcess.cpp.
void Zbl::ZProcess::envClear | ( | ) |
Clears the process execution environment that will be passed to the child process.
Definition at line 218 of file ZProcess.cpp.
QStringList Zbl::ZProcess::envGetList | ( | ) |
Obtains the list of process environment variables that will be passed to the child process.
Definition at line 223 of file ZProcess.cpp.
QString Zbl::ZProcess::envGetValue | ( | const QString & | name | ) |
Returns the value of an environment variable that will be passed to the child process.
Definition at line 235 of file ZProcess.cpp.
void Zbl::ZProcess::envSetValue | ( | const QString & | name, |
const QString & | value | ||
) |
Sets an environment variable that will be passed to the child process.
Definition at line 228 of file ZProcess.cpp.
bool Zbl::ZProcess::envValueExists | ( | const QString & | name | ) |
Determine if an environment variable has been set to be passed to the child process.
Definition at line 240 of file ZProcess.cpp.
|
signal |
int Zbl::ZProcess::exitCode | ( | ) | const |
Obtains the exit code of the last process that finished.
Not valid unless exitStatus() returns ExitNormal.
Definition at line 208 of file ZProcess.cpp.
int Zbl::ZProcess::exitStatus | ( | ) | const |
Obtains the exit status of the last process that finished.
Definition at line 213 of file ZProcess.cpp.
|
signal |
QStringList Zbl::ZProcess::getArguments | ( | ) |
Returns the arguments that will be passed to the process when it starts.
Definition at line 129 of file ZProcess.cpp.
int Zbl::ZProcess::getError | ( | ) | const |
Obtains the current error state.
Definition at line 193 of file ZProcess.cpp.
QObject * Zbl::ZProcess::getJsDevice | ( | ) |
Definition at line 89 of file ZProcess.cpp.
int Zbl::ZProcess::getProcessChannelMode | ( | ) | const |
Returns the channel mode of the QProcess standard output and standard error channels.
Definition at line 203 of file ZProcess.cpp.
qint64 Zbl::ZProcess::getProcessID | ( | ) | const |
Obtain the process ID. Note that Linux will reuse process IDs. They are ephemeral, not unique.
Definition at line 159 of file ZProcess.cpp.
QString Zbl::ZProcess::getProgram | ( | ) | const |
Returns the path to the program the process will be started with.
Definition at line 139 of file ZProcess.cpp.
|
slot |
Obtains the QIODevice pointer for this object.
Connect this slot to ZioDevice::getCurrentDevice signal with a direct connection. This mechanism allows multiple Zuble QML types to share the QIODevice API definition.
// TBD: should we have used multiple inheritance instead?
device | Pointer to a pointer to a QIODevice that should receive the pointer to QProcess object cast to QIODevice pointer; |
Definition at line 96 of file ZProcess.cpp.
Referenced by initZioDevice().
int Zbl::ZProcess::getReadChannel | ( | ) | const |
Obtain the current read channel.
Definition at line 164 of file ZProcess.cpp.
int Zbl::ZProcess::getState | ( | ) | const |
Obtains the current process state.
Definition at line 188 of file ZProcess.cpp.
QVariant Zbl::ZProcess::getTags | ( | ) |
Definition at line 84 of file ZProcess.cpp.
|
protected |
Construct and connect a ZioDevice object that presents a Javascript interface to this process's QIODevice object.
Definition at line 47 of file ZProcess.cpp.
QObject * Zbl::ZProcess::readAllStandardError | ( | ) |
Obtains all available data from the process's stderr channel.
Definition at line 174 of file ZProcess.cpp.
QObject * Zbl::ZProcess::readAllStandardOutput | ( | ) |
Obtains all available data from the process's stdout channel.
Definition at line 181 of file ZProcess.cpp.
|
signal |
|
signal |
|
static |
Registers ZFile as a QML type.
Definition at line 40 of file ZProcess.cpp.
Referenced by Zbl::Zblcore::registerTypes().
void Zbl::ZProcess::setArguments | ( | const QStringList & | arguments | ) |
Sets the arguments that will be passed to the process when it starts.
A | list of program arguments |
Definition at line 134 of file ZProcess.cpp.
void Zbl::ZProcess::setProcessChannelMode | ( | int | mode | ) |
Sets the process channel mode that will be used the next time the process starts.
mode | The input channel mode to use |
Definition at line 198 of file ZProcess.cpp.
void Zbl::ZProcess::setProgram | ( | const QString & | program | ) |
Sets the path to the program the process will be started with.
This method must be called before calling start.
program | Path to the program to run. |
Definition at line 144 of file ZProcess.cpp.
void Zbl::ZProcess::setReadChannel | ( | int | channel | ) |
Determine which read channel is currently active.
Use this method to switch between reading stderr and stdout channels.
A | QProcess::ProcessChannel value to set the current read channel. |
Definition at line 169 of file ZProcess.cpp.
|
slot |
Starts the process.
mode | Open mode of the process. ZioDevice::ReadWrite is default. |
Script threads use ZProcess.device.tags.ReadWrite etc...
Definition at line 124 of file ZProcess.cpp.
|
signal |
Referenced by ZProcess().
|
signal |
|
signal |
|
protected |
Smart pointer to the embedded QFile object.
Definition at line 411 of file ZProcess.h.
Referenced by closeReadChannel(), closeWriteChannel(), envClear(), envGetList(), envGetValue(), envSetValue(), envValueExists(), exitCode(), exitStatus(), getArguments(), getError(), getProcessChannelMode(), getProcessID(), getProgram(), getQDevice(), getReadChannel(), getState(), readAllStandardError(), readAllStandardOutput(), setArguments(), setProcessChannelMode(), setProgram(), setReadChannel(), and start().
|
staticprotected |
A QVariantMap used to pass QFile enumeration values to Javascript programs.
Definition at line 423 of file ZProcess.h.
Referenced by createTags(), and getTags().
|
protected |
Pointer to QioDevice interface object.
Definition at line 416 of file ZProcess.h.
Referenced by getJsDevice(), and initZioDevice().
|
readwrite |
Set/get the argument list for the process.
Definition at line 93 of file ZProcess.h.
|
read |
A ZioDevice object that represents the File's QioDevice interface.
Definition at line 81 of file ZProcess.h.
|
read |
Obtain the process's current error state.
Definition at line 132 of file ZProcess.h.
|
readwrite |
Set/get the process channel mode for the process.
Definition at line 105 of file ZProcess.h.
|
read |
Set/get the operating system process ID for the last process run by this object.
Note that process IDs are reused by Linux.
Definition at line 120 of file ZProcess.h.
|
readwrite |
Set/get the program for the process.
Definition at line 99 of file ZProcess.h.
|
readwrite |
Set/get the current read channel.
Definition at line 111 of file ZProcess.h.
|
read |
Obtain the current process state.
Definition at line 126 of file ZProcess.h.
|
read |
A Javascript object containing QFile enumeration values.
Definition at line 87 of file ZProcess.h.
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.