diff options
Diffstat (limited to 'include/cru/common/SubProcess.h')
-rw-r--r-- | include/cru/common/SubProcess.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/cru/common/SubProcess.h b/include/cru/common/SubProcess.h new file mode 100644 index 00000000..341afc5c --- /dev/null +++ b/include/cru/common/SubProcess.h @@ -0,0 +1,54 @@ +#pragma once +#include "Base.h" +#include "String.h" + +#include <chrono> +#include <optional> +#include <vector> + +namespace cru { +enum class PlatformSubProcessStatus { + /** + * @brief The process has not been created and started. + */ + Prepare, + /** + * @brief The process is running now. + */ + Running, + /** + * @brief The process has been exited. + */ + Exited, +}; + +/** + * Interface of a platform process. It is one-time, which means it starts and + * exits and can't start again. + */ +struct IPlatformSubProcess : virtual Interface { + /** + * Create and start a real process. + */ + void Start(String program, std::vector<String> arguments, + std::vector<String> environments); + void Wait(std::optional<std::chrono::milliseconds> wait_time); + void Reap(); + PlatformSubProcessStatus GetStatus() const; + int GetExitCode() const; +}; + +class CRU_BASE_API SubProcess : public Object { + public: + SubProcess(); + + CRU_DELETE_COPY(SubProcess) + + SubProcess(SubProcess&& other); + SubProcess& operator=(SubProcess&& other); + + ~SubProcess(); + + private: +}; +} // namespace cru |