ScummVM API documentation
task.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MUTATIONOFJB_TASK_H
23 #define MUTATIONOFJB_TASK_H
24 
25 #include "common/scummsys.h"
26 #include "common/ptr.h"
27 #include "common/array.h"
28 
29 namespace MutationOfJB {
30 
31 class TaskManager;
32 
36 class Task {
37 public:
38  enum State {
39  IDLE,
40  RUNNING,
41  FINISHED
42  };
43 
44  Task() : _taskManager(nullptr), _state(IDLE) {}
45  virtual ~Task() {}
46 
47  virtual void start() = 0;
48  virtual void update() = 0;
49  virtual void stop() {
50  assert(false); // Assert by default - stopping might not be safe for all tasks.
51  }
52 
53  void setTaskManager(TaskManager *taskMan) {
54  _taskManager = taskMan;
55  }
56 
57  TaskManager *getTaskManager() {
58  return _taskManager;
59  }
60 
61  State getState() const {
62  return _state;
63  }
64 
65 protected:
66  void setState(State state) {
67  _state = state;
68  }
69 
70 private:
71  TaskManager *_taskManager;
72  State _state;
73 };
74 
77 
78 }
79 
80 #endif
Definition: taskmanager.h:37
Definition: array.h:52
Definition: task.h:36
Definition: animationdecoder.h:36