code format
This commit is contained in:
@@ -5,22 +5,22 @@
|
||||
* \~russian Внешний процесс
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Process
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Process
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIPROCESS_H
|
||||
@@ -28,19 +28,18 @@
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
|
||||
#include "pithread.h"
|
||||
#include "pifile.h"
|
||||
# include "pifile.h"
|
||||
# include "pithread.h"
|
||||
|
||||
|
||||
//! \ingroup System
|
||||
//! \~\brief
|
||||
//! \~english External process.
|
||||
//! \~russian Внешний процесс.
|
||||
class PIP_EXPORT PIProcess: public PIThread
|
||||
{
|
||||
class PIP_EXPORT PIProcess: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PIProcess, PIThread);
|
||||
public:
|
||||
|
||||
public:
|
||||
//! \~english Construct empty %PIProcess
|
||||
//! \~russian Создает пустой %PIProcess
|
||||
PIProcess();
|
||||
@@ -50,70 +49,76 @@ public:
|
||||
|
||||
//! \~english Returns last attached execution exit code
|
||||
//! \~russian Возвращает код завершения последнего выполнения
|
||||
int exitCode() const {return exit_code;}
|
||||
int exitCode() const { return exit_code; }
|
||||
|
||||
//! \~english Returns current attached execution process ID
|
||||
//! \~russian Возвращает ID процесса текущего выполнения
|
||||
int pID() const;
|
||||
|
||||
void setGrabInput(bool yes) {g_in = yes;}
|
||||
void setGrabInput(bool yes) { g_in = yes; }
|
||||
|
||||
//! \~english Set attached execution grab output stream enabled
|
||||
//! \~russian
|
||||
void setGrabOutput(bool yes) {g_out = yes;}
|
||||
void setGrabOutput(bool yes) { g_out = yes; }
|
||||
|
||||
//! \~english Set attached execution grab error stream enabled
|
||||
//! \~russian
|
||||
void setGrabError(bool yes) {g_err = yes;}
|
||||
void setGrabError(bool yes) { g_err = yes; }
|
||||
|
||||
void setInputFile(const PIString & path) {f_in.setPath(path);}
|
||||
void setInputFile(const PIString & path) { f_in.setPath(path); }
|
||||
|
||||
//! \~english Set attached execution grab output stream file
|
||||
//! \~russian
|
||||
void setOutputFile(const PIString & path) {f_out.setPath(path);}
|
||||
void setOutputFile(const PIString & path) { f_out.setPath(path); }
|
||||
|
||||
//! \~english Set attached execution grab error stream file
|
||||
//! \~russian
|
||||
void setErrorFile(const PIString & path) {f_err.setPath(path);}
|
||||
void setErrorFile(const PIString & path) { f_err.setPath(path); }
|
||||
|
||||
void unsetInputFile() {f_in.setPath("");}
|
||||
void unsetInputFile() { f_in.setPath(""); }
|
||||
|
||||
//! \~english Reset attached execution grab output stream file
|
||||
//! \~russian
|
||||
void unsetOutputFile() {f_out.setPath("");}
|
||||
void unsetOutputFile() { f_out.setPath(""); }
|
||||
|
||||
//! \~english Reset attached execution grab error stream file
|
||||
//! \~russian
|
||||
void unsetErrorFile() {f_err.setPath("");}
|
||||
void unsetErrorFile() { f_err.setPath(""); }
|
||||
|
||||
//! \~english Returns current attached execution working directory or empty string if it wasn`t set
|
||||
//! \~russian
|
||||
PIString workingDirectory() const {return wd;}
|
||||
PIString workingDirectory() const { return wd; }
|
||||
|
||||
//! \~english Set attached execution working directory
|
||||
//! \~russian
|
||||
void setWorkingDirectory(const PIString & path) {wd = path;}
|
||||
void setWorkingDirectory(const PIString & path) { wd = path; }
|
||||
|
||||
//! \~english Rseet attached execution working directory, application working dir will be used
|
||||
//! \~russian
|
||||
void resetWorkingDirectory() {wd.clear();}
|
||||
void resetWorkingDirectory() { wd.clear(); }
|
||||
|
||||
//! \~english Returns all attached execution output stream
|
||||
//! \~russian
|
||||
PIByteArray readOutput() {f_out.open(PIIODevice::ReadOnly); return f_out.readAll();}
|
||||
PIByteArray readOutput() {
|
||||
f_out.open(PIIODevice::ReadOnly);
|
||||
return f_out.readAll();
|
||||
}
|
||||
|
||||
//! \~english Returns all attached execution error stream
|
||||
//! \~russian
|
||||
PIByteArray readError() {f_err.open(PIIODevice::ReadOnly); return f_err.readAll();}
|
||||
PIByteArray readError() {
|
||||
f_err.open(PIIODevice::ReadOnly);
|
||||
return f_err.readAll();
|
||||
}
|
||||
|
||||
|
||||
//! \~english Returns current attached execution environment
|
||||
//! \~russian
|
||||
PIStringList environment() {return env;}
|
||||
PIStringList environment() { return env; }
|
||||
|
||||
//! \~english Clear current attached execution environment. Call before \a exec()
|
||||
//! \~russian
|
||||
void clearEnvironment() {env.clear();}
|
||||
void clearEnvironment() { env.clear(); }
|
||||
|
||||
//! \~english Remove variable "variable" from current attached execution environment. Call before \a exec()
|
||||
//! \~russian
|
||||
@@ -125,13 +130,25 @@ public:
|
||||
|
||||
//! \~english Start attached execution "program" with one argument "arg"
|
||||
//! \~russian
|
||||
void exec(const PIString & program, const PIString & arg) {args.clear(); args << program << arg; exec_();}
|
||||
void exec(const PIString & program, const PIString & arg) {
|
||||
args.clear();
|
||||
args << program << arg;
|
||||
exec_();
|
||||
}
|
||||
|
||||
EVENT_HANDLER1(void, exec, const PIString & , program) {args.clear(); args << program; exec_();}
|
||||
EVENT_HANDLER2(void, exec, const PIString & , program, const PIStringList & , args_) {args.clear(); args << program << args_; exec_();}
|
||||
EVENT_HANDLER1(void, exec, const PIString &, program) {
|
||||
args.clear();
|
||||
args << program;
|
||||
exec_();
|
||||
}
|
||||
EVENT_HANDLER2(void, exec, const PIString &, program, const PIStringList &, args_) {
|
||||
args.clear();
|
||||
args << program << args_;
|
||||
exec_();
|
||||
}
|
||||
EVENT_HANDLER(void, terminate);
|
||||
EVENT_HANDLER(bool, waitForFinish) {return waitForFinish(60000);}
|
||||
EVENT_HANDLER1(bool, waitForFinish, int, timeout_msecs) {return PIThread::waitForFinish(timeout_msecs);}
|
||||
EVENT_HANDLER(bool, waitForFinish) { return waitForFinish(60000); }
|
||||
EVENT_HANDLER1(bool, waitForFinish, int, timeout_msecs) { return PIThread::waitForFinish(timeout_msecs); }
|
||||
|
||||
EVENT1(execStarted, PIString, program);
|
||||
EVENT2(execFinished, PIString, program, int, exit_code);
|
||||
@@ -139,11 +156,11 @@ public:
|
||||
|
||||
//! \~english Start detached execution "program" without arguments
|
||||
//! \~russian
|
||||
static void execIndependent(const PIString & program) {execIndependent(program, PIStringList());}
|
||||
static void execIndependent(const PIString & program) { execIndependent(program, PIStringList()); }
|
||||
|
||||
//! \~english Start detached execution "program" with one argument "arg"
|
||||
//! \~russian
|
||||
static void execIndependent(const PIString & program, const PIString & arg) {execIndependent(program, PIStringList() << arg);}
|
||||
static void execIndependent(const PIString & program, const PIString & arg) { execIndependent(program, PIStringList() << arg); }
|
||||
|
||||
//! \~english Start detached execution "program" with arguments "args"
|
||||
//! \~russian
|
||||
@@ -162,8 +179,8 @@ public:
|
||||
//! \~russian
|
||||
static PIString getEnvironmentVariable(const PIString & variable);
|
||||
|
||||
//! \handlers
|
||||
//! \{
|
||||
//! \handlers
|
||||
//! \{
|
||||
|
||||
//! \fn void exec(const PIString & program)
|
||||
//! \brief
|
||||
@@ -190,9 +207,9 @@ public:
|
||||
//! \~english Wait for attached execution finish maximum for "timeout_msecs" milliseconds
|
||||
//! \~russian
|
||||
|
||||
//! \}
|
||||
//! \events
|
||||
//! \{
|
||||
//! \}
|
||||
//! \events
|
||||
//! \{
|
||||
|
||||
//! \fn void execStarted(PIString program)
|
||||
//! \brief
|
||||
@@ -204,7 +221,7 @@ public:
|
||||
//! \~english Raise on attached execution finish
|
||||
//! \~russian
|
||||
|
||||
//! \}
|
||||
//! \}
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
@@ -219,7 +236,6 @@ private:
|
||||
bool g_in, g_out, g_err, t_in, t_out, t_err;
|
||||
int exit_code;
|
||||
bool is_exec;
|
||||
|
||||
};
|
||||
|
||||
#endif // MICRO_PIP
|
||||
|
||||
Reference in New Issue
Block a user