Nebula
Loading...
Searching...
No Matches
processbase.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11#include "util/string.h"
12#include "io/uri.h"
13#include "io/stream.h"
14
15//------------------------------------------------------------------------------
16namespace Base
17{
19{
20public:
21
23 Process();
24
26 void SetExecutable(const IO::URI& uri);
28 void SetWorkingDirectory(const IO::URI& uri);
30 void SetArguments(const Util::String& args);
32 void SetNoConsoleWindow(bool b);
34 void SetStdoutCaptureStream(const Ptr<IO::Stream>& stream);
38 void SetStderrCaptureStream(const Ptr<IO::Stream>& stream);
41
43 virtual bool LaunchWait() const = 0;
45 virtual bool Launch() = 0;
47 virtual bool IsRunning() = 0;
49 virtual void UpdateStdoutStream() = 0;
51 virtual bool CheckIfExists() = 0;
52
53protected:
54
62};
63
64
65//------------------------------------------------------------------------------
68inline
70 noConsoleWindow(false),
71 isRunning(false),
72 stdoutCaptureStream(nullptr)
73{
74 // empty
75}
76
77//------------------------------------------------------------------------------
80inline void
82{
83 this->exePath = uri;
84}
85
86//------------------------------------------------------------------------------
89inline void
91{
92 this->workingDir = uri;
93}
94
95//------------------------------------------------------------------------------
98inline void
100{
101 this->args = a;
102}
103
104
105//------------------------------------------------------------------------------
108inline void
110{
111 this->noConsoleWindow = b;
112}
113
114//------------------------------------------------------------------------------
117inline void
119{
120 this->stdoutCaptureStream = stream;
121}
122
123//------------------------------------------------------------------------------
126inline const Ptr<IO::Stream>&
128{
129 return this->stdoutCaptureStream;
130}
131
132//------------------------------------------------------------------------------
135inline void
137{
138 this->stderrCaptureStream = stream;
139}
140
141//------------------------------------------------------------------------------
144inline const Ptr<IO::Stream>&
146{
147 return this->stderrCaptureStream;
148}
149
150
151} // namespace Base
152//------------------------------------------------------------------------------
153
Base class for launching an external application.
Definition processbase.h:19
virtual void UpdateStdoutStream()=0
Read data from the captured stdout and writes it to the stream.
virtual bool CheckIfExists()=0
Detect if an instance of the process is already running.
void SetExecutable(const IO::URI &uri)
set the executable path
Definition processbase.h:81
IO::URI workingDir
Definition processbase.h:58
Ptr< IO::Stream > stdoutCaptureStream
Definition processbase.h:60
const Ptr< IO::Stream > & GetStdoutCaptureStream() const
get optional pointer to stdout capture stream
Definition processbase.h:127
void SetArguments(const Util::String &args)
set command line arguments
Definition processbase.h:99
void SetWorkingDirectory(const IO::URI &uri)
set working directory
Definition processbase.h:90
virtual bool LaunchWait() const =0
launch application and wait for its termination
Ptr< IO::Stream > stderrCaptureStream
Definition processbase.h:61
bool isRunning
Definition processbase.h:56
const Ptr< IO::Stream > & GetStderrCaptureStream() const
get optional pointer to stderr capture stream
Definition processbase.h:145
void SetStderrCaptureStream(const Ptr< IO::Stream > &stream)
set optional stderr capture stream
Definition processbase.h:136
Process()
constructor
Definition processbase.h:69
void SetStdoutCaptureStream(const Ptr< IO::Stream > &stream)
set optional stdout capture stream
Definition processbase.h:118
virtual bool IsRunning()=0
Gets the state of application. Call this per frame.
void SetNoConsoleWindow(bool b)
do not open a console window for the new process
Definition processbase.h:109
bool noConsoleWindow
Definition processbase.h:55
Util::String args
Definition processbase.h:59
IO::URI exePath
Definition processbase.h:57
virtual bool Launch()=0
launch application (returns immediately)
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition uri.h:67
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Definition gamecontentserverbase.cc:10
Nebula's universal string class.
Definition string.h:50