summaryrefslogtreecommitdiff
path: root/includes/Main.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-09 01:12:50 -0700
committerPixel <pixel@nobis-crew.org>2011-10-09 01:12:50 -0700
commit864eeb3a526b1a32c72e1f31a3e1f23dcc5c7409 (patch)
tree7cc7037e2d7137180a67fb10b29469d4d68e677f /includes/Main.h
parent4f7b984f9f848ba6adae2040c520a97bb5c0e354 (diff)
More work on the Task manager.
Now "Main" is a Task, among the most important changes. Introduced the notion of Events, and managed a coherent task switch. Also, renamed a lot of the variables to have a more coherent naming scheme.
Diffstat (limited to 'includes/Main.h')
-rw-r--r--includes/Main.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/includes/Main.h b/includes/Main.h
index eee7ff7..44764a3 100644
--- a/includes/Main.h
+++ b/includes/Main.h
@@ -37,9 +37,17 @@ class Exit : public GeneralException {
};
#include <Printer.h>
+#include <Task.h>
+#include <TaskMan.h>
namespace Balau {
+class MainTask : public Task {
+ public:
+ virtual const char * getName() { return "Main Task"; }
+ virtual void Do();
+};
+
class Main {
public:
enum Status {
@@ -49,11 +57,10 @@ class Main {
STOPPING,
STOPPED,
};
- Main() : m_status(UNKNOWN) { application = this; }
- virtual int startup() throw (GeneralException) = 0;
- static Status status() { return application->m_status; }
+ Main() : m_status(UNKNOWN) { Assert(s_application == 0); s_application = this; }
+ static Status status() { return s_application->m_status; }
int bootstrap(int _argc, char ** _argv) {
- int r;
+ int r = 0;
m_status = STARTING;
argc = _argc;
@@ -65,7 +72,8 @@ class Main {
try {
m_status = RUNNING;
- r = startup();
+ MainTask * mainTask = new MainTask();
+ TaskMan::getTaskMan()->mainLoop();
m_status = STOPPING;
}
catch (Exit e) {
@@ -96,7 +104,7 @@ class Main {
char ** enve;
private:
Status m_status;
- static Main * application;
+ static Main * s_application;
};
#define BALAU_STARTUP \
@@ -106,12 +114,11 @@ class Application : public Balau::Main { \
virtual int startup() throw (Balau::GeneralException); \
}; \
\
-static Application application; \
-\
extern "C" { \
int main(int argc, char ** argv) { \
setlocale(LC_ALL, ""); \
- return application.bootstrap(argc, argv); \
+ Balau::Main mainClass; \
+ return mainClass.bootstrap(argc, argv); \
} \
}