4.06.2013 - Version 0.3.4 - PIOBJECT() macro, ethernet improvement, documentation based on Doxygen
This commit is contained in:
27
piprocess.h
27
piprocess.h
@@ -40,11 +40,12 @@
|
||||
/// bool exec(const PIString & program, const PIStringList & args)
|
||||
/// void terminate()
|
||||
/// bool waitForFinish(int timeout_msecs = 60000)
|
||||
class PIProcess: private PIThread
|
||||
class PIP_EXPORT PIProcess: private PIThread
|
||||
{
|
||||
PIOBJECT(PIProcess)
|
||||
public:
|
||||
PIProcess();
|
||||
~PIProcess();
|
||||
virtual ~PIProcess();
|
||||
|
||||
int exitCode() const {return exit_code;}
|
||||
#ifdef WINDOWS
|
||||
@@ -65,18 +66,18 @@ public:
|
||||
PIString workingDirectory() const {return wd;}
|
||||
void setWorkingDirectory(const PIString & path) {wd = path;}
|
||||
void resetWorkingDirectory() {wd.clear();}
|
||||
EVENT_HANDLER1(PIProcess, void, exec, const PIString & , program) {args.clear(); args << program; exec_();}
|
||||
EVENT_HANDLER2(PIProcess, void, exec, const PIString & , program, const PIString & , arg) {args.clear(); args << program << arg; exec_();}
|
||||
EVENT_HANDLER3(PIProcess, void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2) {args.clear(); args << program << arg1 << arg2; exec_();}
|
||||
EVENT_HANDLER4(PIProcess, void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2, const PIString & , arg3) {args.clear(); args << program << arg1 << arg2 << arg3; exec_();}
|
||||
EVENT_HANDLER2(PIProcess, void, exec, const PIString & , program, const PIStringList & , args_) {args << program << args_; exec_();}
|
||||
EVENT_HANDLER1(void, exec, const PIString & , program) {args.clear(); args << program; exec_();}
|
||||
EVENT_HANDLER2(void, exec, const PIString & , program, const PIString & , arg) {args.clear(); args << program << arg; exec_();}
|
||||
EVENT_HANDLER3(void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2) {args.clear(); args << program << arg1 << arg2; exec_();}
|
||||
EVENT_HANDLER4(void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2, const PIString & , arg3) {args.clear(); args << program << arg1 << arg2 << arg3; exec_();}
|
||||
EVENT_HANDLER2(void, exec, const PIString & , program, const PIStringList & , args_) {args << program << args_; exec_();}
|
||||
#ifdef WINDOWS
|
||||
EVENT_HANDLER(PIProcess, void, terminate) {if (is_exec) if (!TerminateProcess(pi.hProcess, 0)) return; pi.dwProcessId = 0;}
|
||||
EVENT_HANDLER(void, terminate) {if (is_exec) if (!TerminateProcess(pi.hProcess, 0)) return; pi.dwProcessId = 0;}
|
||||
#else
|
||||
EVENT_HANDLER(PIProcess, void, terminate) {if (is_exec) kill(pid, SIGKILL); pid = 0;}
|
||||
EVENT_HANDLER(void, terminate) {if (is_exec) kill(pid, SIGKILL); pid = 0;}
|
||||
#endif
|
||||
EVENT_HANDLER(PIProcess, bool, waitForFinish) {return waitForFinish(60000);}
|
||||
EVENT_HANDLER1(PIProcess, 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);}
|
||||
PIByteArray readOutput() {f_out.open(PIIODevice::ReadOnly); return f_out.readAll();}
|
||||
PIByteArray readError() {f_err.open(PIIODevice::ReadOnly); return f_err.readAll();}
|
||||
|
||||
@@ -92,8 +93,8 @@ public:
|
||||
static int currentPID() {return getpid();}
|
||||
#endif
|
||||
|
||||
EVENT1(PIProcess, execStarted, PIString, program)
|
||||
EVENT2(PIProcess, execFinished, PIString, program, int, exit_code)
|
||||
EVENT1(execStarted, PIString, program)
|
||||
EVENT2(execFinished, PIString, program, int, exit_code)
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
|
||||
Reference in New Issue
Block a user