60f6006c59fb1bc5dc2e603e6d7f6a9075845294
[matthijs/ABM2.git] / ABM2 / Engine / Kernel.h
1 // Kernel.h: interface for the CKernel class.\r
2 //\r
3 //////////////////////////////////////////////////////////////////////\r
4 \r
5 #if !defined(AFX_KERNEL_H__4E822B7D_1078_4F70_BC8F_3BB4F83ED0AF__INCLUDED_)\r
6 #define AFX_KERNEL_H__4E822B7D_1078_4F70_BC8F_3BB4F83ED0AF__INCLUDED_\r
7 \r
8 #if _MSC_VER > 1000\r
9 #pragma once\r
10 #endif // _MSC_VER > 1000\r
11 \r
12 #include "singleton.h"\r
13 \r
14 \r
15 class CClient;\r
16 class CServer;\r
17 \r
18 class ITask;\r
19 \r
20 class CKernel : public Singleton<CKernel>\r
21 {\r
22 public:\r
23         CKernel();\r
24         virtual ~CKernel();\r
25 \r
26         int Execute();\r
27 \r
28         bool AddTask(CMMPointer<ITask> t);\r
29         void SuspendTask(CMMPointer<ITask> t);\r
30         void ResumeTask(CMMPointer<ITask> t);\r
31         void RemoveTask(CMMPointer<ITask> t);\r
32         void KillAllTasks();\r
33 \r
34 protected:\r
35         std::list< CMMPointer<ITask> > taskList;\r
36         std::list< CMMPointer<ITask> > pausedTaskList;\r
37 };\r
38 \r
39 class ITask : public IMMObject\r
40 {\r
41 public:\r
42         ITask(){canKill=false;priority=5000;}\r
43         virtual bool Start()=0;\r
44         virtual void OnSuspend(){};\r
45         virtual void Update()=0;\r
46         virtual void OnResume(){};\r
47         virtual void Stop()=0;\r
48 \r
49         bool canKill;\r
50         long priority;\r
51 };\r
52 \r
53 #endif // !defined(AFX_KERNEL_H__4E822B7D_1078_4F70_BC8F_3BB4F83ED0AF__INCLUDED_)\r