2 This file is part of libmspframework
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
6 #ifndef MSP_FRAMEWORK_APPLICATION_H_
7 #define MSP_FRAMEWORK_APPLICATION_H_
10 #include "win32signum.h"
20 Base class for applications. Inherit the main class from this and add a static
21 member of type RegApp<MainClass>.
26 Poller::Slot &add_pollable(Pollable *, short);
27 EventManager::Event &create_event();
28 virtual ~Application();
30 static int run(int, char **);
31 static void usage(const char *, bool);
36 AFTER_POLL, /// One tick after each poll
37 IDLE /// Constant torrent of ticks
43 virtual Application *create_app(int, char **)=0;
44 virtual void usage(const char *, bool)=0;
45 virtual ~RegBase() { }
51 class RegApp: public RegBase
54 Application *create_app(int argc, char **argv) { return new T(argc, argv); }
55 void usage(const char *a, bool b) { T::usage(a,b); }
61 Application(): exit_code(0), tick_mode_(IDLE), poller_(0), ev_mgr_(0), main_tid(pthread_self()) { }
63 void catch_signal(int);
64 void set_tick_mode(TickMode);
66 virtual void tick() { }
67 virtual void sighandler(int) { }
71 EventManager *ev_mgr_;
74 Application(const Application &);
75 Application &operator=(const Application &);
77 static RegBase *reg_app_;
78 static Application *app_;
80 static void sighandler_(int);
81 static void sigalrm_(int) { }