MuldeR's Utilities for Qt
MUtilities
|
This class represents a job object. More...
#include <JobObject.h>
Public Member Functions | |
JobObject (void) | |
Create a new JobObject instance. More... | |
~JobObject (void) | |
Destroys the JobObject instance. More... | |
bool | isObjectCreated (void) |
Test whether job object was created successfully. More... | |
bool | addProcessToJob (const QProcess *const process) |
Add a process to the job object. More... | |
bool | terminateJob (const quint32 &exitCode) |
Terminate all sub-processes of the job object. More... | |
This class represents a job object.
Call addProcessToJob() to add another sub-process to this job object. Call terminateJob() to terminate all sub-processes that belong to this job object. Note that all sub-processes that belong to this job object will also be terminated when this process exits, gracefully or due to a crash.
Also, when the JobObject instance is destroyed, all sub-process that belong to its corresponding job object and that are still running will be terminated!
MUtils::JobObject::JobObject | ( | void | ) |
Create a new JobObject instance.
Creating a new JobObject instance automatically creates a new job object on the system-level. Check isObjectCreated() to test whether the job object was successfully created or not.
MUtils::JobObject::~JobObject | ( | void | ) |
bool MUtils::JobObject::addProcessToJob | ( | const QProcess *const | process | ) |
Add a process to the job object.
This function adds a another sub-process to the job object that is represented by this JobObject instance. Job object limitations apply to the sub-process a
process | A read-only pointer to the QProcess object that represents the sub-process to be added to the job object. The sub-process must be in the "running" state; otherwise the function will fail. |
true
, if and only if the process was successfully added to the job object; otherwise it returns false
. bool MUtils::JobObject::isObjectCreated | ( | void | ) |
Test whether job object was created successfully.
The job object will be created automatically when a new JobObject instance is created. However, the constructor has no to tell whether the job object was created successfully on the system-level. Call this function to test whether the job object has been created.
true
, if and only if a job object was successfully created; otherwise it returns false
. bool MUtils::JobObject::terminateJob | ( | const quint32 & | exitCode | ) |
Terminate all sub-processes of the job object.
This function immediately terminates all running sub-processes that belong to the job object represented by this JobObject instance at once.
exitCode | The exit code to be set for the sub-process when they are terminated. |
true
, if the sub-processes were destroyed successfully, even if there were no running sub-process left; otherwise it returns false
.