HumanRender/human_render/Utils/Process.h

44 lines
1.1 KiB
C
Raw Normal View History

2024-12-19 17:46:41 +00:00
#pragma once
#include <string>
#include "include/base/cef_macros.h"
class Process {
public:
Process() = default;
Process(const std::string& path, const std::string& args = "", const std::string& workDir = "")
: path_(path), args_(args), workDir_(workDir) {}
virtual ~Process() { }
static Process* Create();
static Process* Create(const std::string& path,
const std::string& args = "", const std::string& workDir = "");
void SetWorkingDirectory(const std::string& dir) { workDir_ = dir; }
bool Excucete() { return OnExecute(); }
bool Excucete(const std::string& path) {
path_ = path;
return OnExecute();
}
bool Excucete(const std::string& path, const std::string& args) {
path_ = path;
args_ = args;
return OnExecute();
}
void Terminate() {
OnTerminate();
}
protected:
virtual bool OnExecute() = 0;
virtual void OnTerminate() = 0;
protected:
std::string path_;
std::string args_;
std::string workDir_;
DISALLOW_COPY_AND_ASSIGN(Process);
};