From f5d9fe6211bd397deb0ac19b634f551edfa0f6b8 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 30 Jan 2022 20:19:02 +0100 Subject: Initialize project --- src/Process.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Process.hpp (limited to 'src/Process.hpp') diff --git a/src/Process.hpp b/src/Process.hpp new file mode 100644 index 0000000..3265cc9 --- /dev/null +++ b/src/Process.hpp @@ -0,0 +1,28 @@ +#include + +#define ENGINE_TIMEOUT 5 // In seconds +#define BUFFER_SIZE 1024 + +namespace uciadapter { + +class Process { + +public: + /// @brief Kill the engine + virtual void Kill() = 0; + /// @brief Start the engine from file path + virtual void Start(std::string) = 0; + /// @brief Read one line from the stdout of the engine (could raise a ReadTimeoutExpire) + virtual std::string ReadLine() = 0; + /// @brief Write to engine stdin + virtual void Write(std::string) = 0; +}; + +struct FailedToStartEngine : public std::exception { + const char *what() const throw() { return ("Could not start the engine"); } +}; +struct ReadTimeoutExpire : public std::exception { + const char *what() const throw() { return ("Engine is not responding"); } +}; + +} // namespace uciadapter \ No newline at end of file -- cgit v1.2.3