PProcess.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Analytics Supervisor.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 
18 PAPILLON_BEGIN_NAMESPACE
19 
20 class PString;
21 class PStringList;
22 
28 class PAPILLON_API_CORE PProcess : public PObject
29 {
30 public:
35  {
38  E_RUNNING
39  };
40 
45  {
48  };
49 
50 public:
54  PProcess();
55 
59  virtual ~PProcess();
60 
64  bool IsRunning() const;
65 
69  bool IsCrashed() const;
70 
74  bool IsFinished() const;
75 
79  void SetName(const PString& name);
80 
84  PString GetName() const;
85 
89  void SetId(papillon::int32 id);
90 
94  papillon::int32 GetId() const;
95 
99  papillon::int64 GetProcessId() const;
100 
104  void SetProcessEnvironment(const PString& parameter, const PString& value, bool replaceExisting = true);
105 
109  PResult GetProcessEnvironment(PStringList& environment);
110 
114  void SetWorkingDirectory(const PString& directory);
115 
119  PString GetWorkingDirectory() const;
120 
124  const PString& GetCommand() const;
125 
129  EProcessState GetState() const;
130 
134  const PString& GetStateAsString() const;
135 
139  PResult Start(const PString& command);
140 
144  void Restart();
145 
149  void Kill();
150 
156  void Wait();
157 
163  PResult GetExitStatus(PProcess::EExitStatus& exitStatus) const;
164 
170  PResult GetExitCode(papillon::int32& exitCode) const;
171 
175  PString GetStandardOutput();
176 
180  PString GetErrorOutput();
181 };
182 
183 PAPILLON_END_NAMESPACE
The PString class provides an Unicode character strings.
Definition: PString.h:37
The process is not running.
Definition: PProcess.h:36
The PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
The process is starting.
Definition: PProcess.h:37
EProcessState
EProcessState describes all the different states of a PProcess.
Definition: PProcess.h:34
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
The process exited normally.
Definition: PProcess.h:46
The PStringList class represents a list of PString; NOT thread-safe.
Definition: PStringList.h:26
The PProcess class is a toolbox to ease process spawning and management.
Definition: PProcess.h:28
Class PObject: the root class of all Papillon classes.
EExitStatus
EExitStatus describes all the different statuses of a PProcess.
Definition: PProcess.h:44
The process crashed.
Definition: PProcess.h:47