From 864eeb3a526b1a32c72e1f31a3e1f23dcc5c7409 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 9 Oct 2011 01:12:50 -0700 Subject: 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. --- includes/Main.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'includes/Main.h') 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 +#include +#include 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); \ } \ } -- cgit v1.2.3