12345678910111213141516171819202122232425262728293031323334353637 |
- #ifndef COMMANDEDITOR_H
- #define COMMANDEDITOR_H
- #include <atomic>
- #include <thread>
- #include <mutex>
- #include "common/utils/RingBuffer.h"
- #include "common/utils/String.h"
- class CommandEditor final {
- public:
- CommandEditor();
- ~CommandEditor();
- CommandEditor(const CommandEditor& other) = delete;
- CommandEditor& operator=(const CommandEditor& other) = delete;
- CommandEditor(CommandEditor&& other) = delete;
- CommandEditor& operator=(CommandEditor&& other) = delete;
-
- void preTick() const;
- void postTick() const;
-
- bool hasCommand() const;
- String readCommand();
- private:
- static void onLineRead(char* line);
- void loop();
-
- static std::mutex queueMutex;
- static RingBuffer<String, 5> queue;
-
- std::atomic_bool running;
- std::thread readThread;
- };
- #endif
|