QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlBoundProcess Class Reference

An encapsulation of QProcess which reports only the final state. More...

Inheritance diagram for QtlBoundProcess:

Signals

void terminated (const QtlBoundProcessResult &result)
 This signal is emitted when the process is terminated or failed to start. More...
 

Public Member Functions

void cancel ()
 Cancel the start of the process. More...
 
QIODevice * inputDevice () const
 Get the device representing the input pipe of the process. More...
 
void start ()
 Start the process. More...
 

Static Public Member Functions

static QtlBoundProcessnewInstance (const QString &program, const QStringList &arguments=QStringList(), int msRunTestTimeout=0, int maxProcessOutputSize=0, QObject *parent=0, const QProcessEnvironment &env=QProcessEnvironment(), bool pipeInput=false)
 Create a new instance. More...
 

Private Slots

void processError (QProcess::ProcessError error)
 Invoked when an error occurs on the process. More...
 
void processFinished (int exitCode, QProcess::ExitStatus exitStatus)
 Invoked when the process is finished. More...
 
void processTimeout ()
 Invoked when the process execution is too long. More...
 
void readOutputData ()
 Read as much data as possible from the process standard error and output. More...
 

Private Member Functions

 QtlBoundProcess (const QString &program, const QStringList &arguments, int msRunTestTimeout, int maxProcessOutputSize, QObject *parent, const QProcessEnvironment &env=QProcessEnvironment(), bool pipeInput=false)
 Private constructor. More...
 
 QtlBoundProcess () Q_DECL_EQ_DELETE
 
void sendTerminated (const QString &message)
 Send the terminated() signal. More...
 

Private Attributes

const int _maxProcessOutputSize
 Maximum size in bytes of process output. Ignored if negative or zero. More...
 
const int _msRunTestTimeout
 Timeout of process execution in milliseconds. Ignored if negative or zero. More...
 
bool _pipeInput
 Process input is an accessible pipe. More...
 
QProcess * _process
 Actual QProcess object. More...
 
QtlBoundProcessResult _result
 Process execution results. More...
 
bool _started
 start() was called. More...
 
bool _terminated
 terminated() has been signaled. More...
 
QTimer * _timer
 Process execution timeout. More...
 

Detailed Description

An encapsulation of QProcess which reports only the final state.

A QtlBoundProcess instance deletes itself automatically after process termination (after start()) or cancelation (after cancel()). It is both useless and invalid to explicitely delete the object. To enfore object creation on the heap, there is no public constructor. Always use the static method newInstance().

Constructor & Destructor Documentation

◆ QtlBoundProcess() [1/2]

QtlBoundProcess::QtlBoundProcess ( const QString &  program,
const QStringList &  arguments,
int  msRunTestTimeout,
int  maxProcessOutputSize,
QObject *  parent,
const QProcessEnvironment &  env = QProcessEnvironment(),
bool  pipeInput = false 
)
private

Private constructor.

Parameters
[in]programExecutable file path.
[in]argumentsCommand line arguments.
[in]msRunTestTimeoutTimeout of process execution in milliseconds. Ignored if negative or zero.
[in]maxProcessOutputSizeMaximum size in bytes of process output. Ignored if negative or zero.
[in]parentOptional parent object.
[in]envOptional process environment.
[in]pipeInputIf true, the standard input of the process can be fed using inputDevice().

◆ QtlBoundProcess() [2/2]

QtlBoundProcess::QtlBoundProcess ( )
private

Member Function Documentation

◆ newInstance()

QtlBoundProcess * QtlBoundProcess::newInstance ( const QString &  program,
const QStringList &  arguments = QStringList(),
int  msRunTestTimeout = 0,
int  maxProcessOutputSize = 0,
QObject *  parent = 0,
const QProcessEnvironment &  env = QProcessEnvironment(),
bool  pipeInput = false 
)
static

Create a new instance.

Enforce object creation on the heap.

Parameters
[in]programExecutable file path.
[in]argumentsCommand line arguments.
[in]msRunTestTimeoutTimeout of process execution in milliseconds. Ignored if negative or zero.
[in]maxProcessOutputSizeMaximum size in bytes of process output. Ignored if negative or zero.
[in]parentOptional parent object.
[in]envEnvironment for the process. Current environment by default.
[in]pipeInputIf true, the standard input of the process can be fed using inputDevice().
Returns
The new QtlBoundProcess instance.

◆ start()

void QtlBoundProcess::start ( )

Start the process.

◆ cancel()

void QtlBoundProcess::cancel ( )

Cancel the start of the process.

If the process is not yet started, it will never be and the terminated() signal is sent with a cancelation message.

◆ inputDevice()

QIODevice* QtlBoundProcess::inputDevice ( ) const
inline

Get the device representing the input pipe of the process.

The returned QIODevice is writeable only.

Returns
The input pipe as a QIODevice or zero if pipeInput was set to false in the constructor.

◆ terminated

void QtlBoundProcess::terminated ( const QtlBoundProcessResult result)
signal

This signal is emitted when the process is terminated or failed to start.

Parameters
[in]resultProcess execution results.

◆ readOutputData

void QtlBoundProcess::readOutputData ( )
privateslot

Read as much data as possible from the process standard error and output.

◆ processFinished

void QtlBoundProcess::processFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
)
privateslot

Invoked when the process is finished.

Parameters
[in]exitCodeProcess exit code.
[in]exitStatusQProcess exit status.

◆ processError

void QtlBoundProcess::processError ( QProcess::ProcessError  error)
privateslot

Invoked when an error occurs on the process.

Parameters
[in]errorQProcess error code.

◆ processTimeout

void QtlBoundProcess::processTimeout ( )
privateslot

Invoked when the process execution is too long.

◆ sendTerminated()

void QtlBoundProcess::sendTerminated ( const QString &  message)
private

Send the terminated() signal.

Parameters
[in]messageError message if process did not complete normally. Empty if process completed normally.

Member Data Documentation

◆ _msRunTestTimeout

const int QtlBoundProcess::_msRunTestTimeout
private

Timeout of process execution in milliseconds. Ignored if negative or zero.

◆ _maxProcessOutputSize

const int QtlBoundProcess::_maxProcessOutputSize
private

Maximum size in bytes of process output. Ignored if negative or zero.

◆ _result

QtlBoundProcessResult QtlBoundProcess::_result
private

Process execution results.

◆ _pipeInput

bool QtlBoundProcess::_pipeInput
private

Process input is an accessible pipe.

◆ _started

bool QtlBoundProcess::_started
private

start() was called.

◆ _terminated

bool QtlBoundProcess::_terminated
private

terminated() has been signaled.

◆ _process

QProcess* QtlBoundProcess::_process
private

Actual QProcess object.

◆ _timer

QTimer* QtlBoundProcess::_timer
private

Process execution timeout.


The documentation for this class was generated from the following files: