3 This file is part of libmspcore
4 Copyright © 2006-2008, 2011 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_CORE_APPLICATION_H_
9 #define MSP_CORE_APPLICATION_H_
14 Base class for applications. Inherit the main class from this and add a static
15 member of type RegApp<MainClass>.
25 virtual ~Starter() { }
27 virtual Application *create_app(int, char **) = 0;
34 static Starter *starter_;
35 static Application *app_;
38 Application(const Application &);
39 Application &operator=(const Application &);
43 virtual ~Application() { }
45 static int run(int, char **, void * =0);
46 static void *get_data() { return data_; }
50 void catch_signal(int);
52 virtual void tick() { }
53 virtual void sighandler(int) { }
55 static void sighandler_(int);
60 class RegisteredApplication: public Application
63 class Starter: public Application::Starter
66 Application *create_app(int argc, char **argv) { return new T(argc, argv); }
69 static Starter starter_;
72 // Force the starter into existence
73 RegisteredApplication() { (void)starter_; }
77 typename RegisteredApplication<T>::Starter RegisteredApplication<T>::starter_;