figments: figment: redefine task startup state semantics
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@ -22,16 +22,14 @@ struct Task : public virtual Loopable {
|
||||
};
|
||||
|
||||
Task() {}
|
||||
explicit Task(State initialState) : Task(0, initialState) {}
|
||||
explicit Task(const char* name) : Task(name, Running) {}
|
||||
Task(const char* name, State initialState) : name(name), state(initialState) {}
|
||||
explicit Task(const char* name) : name(name) {}
|
||||
|
||||
void start() { state = Running; onStart(); }
|
||||
void stop() { onStop(); state = Stopped; }
|
||||
virtual bool isFigment() const { return false; }
|
||||
|
||||
const char* name = "";
|
||||
State state = Running;
|
||||
State state = Stopped;
|
||||
};
|
||||
|
||||
struct TaskFunc: public Task {
|
||||
@ -42,9 +40,7 @@ struct TaskFunc: public Task {
|
||||
|
||||
struct Figment: public Task {
|
||||
Figment() : Task() {}
|
||||
explicit Figment(State initialState) : Task(initialState) {}
|
||||
explicit Figment(const char* name) : Task(name) {}
|
||||
Figment(const char* name, State initialState) : Task(name, initialState) {}
|
||||
virtual void render(Display* dpy) const = 0;
|
||||
bool isFigment() const override { return true; }
|
||||
};
|
||||
|
@ -114,8 +114,6 @@ class InputSource: public Task {
|
||||
public:
|
||||
InputSource() : Task() {init();}
|
||||
explicit InputSource(const char* name) : Task(name) {init();}
|
||||
explicit InputSource(Task::State initialState) : Task(initialState) {init();}
|
||||
InputSource(const char* name, Task::State initialState) : Task(name, initialState) {init();}
|
||||
void loop() override;
|
||||
void onStart() override;
|
||||
virtual InputEvent read() = 0;
|
||||
@ -134,7 +132,6 @@ class InputFunc : public InputSource {
|
||||
public:
|
||||
InputFunc(std::function<InputEvent(void)> f) : InputSource(), m_func(f) {}
|
||||
InputFunc(std::function<InputEvent(void)> f, const char* name) : InputSource(name), m_func(f) {}
|
||||
InputFunc(std::function<InputEvent(void)> f, const char* name, Task::State initialState) : InputSource(name, initialState), m_func(f) {}
|
||||
|
||||
InputEvent read() override {
|
||||
return m_func();
|
||||
|
Reference in New Issue
Block a user