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_
16 Base class for applications. Inherit the main class from this and add a static
17 member of type RegApp<MainClass>.
22 Poller::Slot &add_pollable(Pollable *, short);
23 EventManager::Event &create_event();
24 virtual ~Application();
26 static int run(int, char **);
27 static void usage(const char *, bool);
32 AFTER_POLL, /// One tick after each poll
33 IDLE /// Constant torrent of ticks
39 virtual Application *create_app(int, char **)=0;
40 virtual void usage(const char *, bool)=0;
41 virtual ~RegBase() { }
47 class RegApp: public RegBase
50 Application *create_app(int argc, char **argv) { return new T(argc, argv); }
51 void usage(const char *a, bool b) { T::usage(a,b); }
59 void catch_signal(int);
60 void set_tick_mode(TickMode);
62 virtual void tick() { }
63 virtual void sighandler(int) { }
67 EventManager *ev_mgr_;
68 ThreadHandle main_tid;
70 Application(const Application &);
71 Application &operator=(const Application &);
73 static RegBase *reg_app_;
74 static Application *app_;
76 static void sighandler_(int);
77 static void sigalrm_(int) { }