]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: module.h | |
3 | // Purpose: Modules handling | |
4 | // Author: Wolfram Gloger/adapted by Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: 04/11/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Wolfram Gloger and Guilhem Lavaux | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_MODULEH__ |
13 | #define _WX_MODULEH__ | |
c801d85f | 14 | |
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
8aa4edd2 | 16 | #pragma interface "module.h" |
c801d85f KB |
17 | #endif |
18 | ||
19 | #include "wx/object.h" | |
20 | #include "wx/list.h" | |
c801d85f | 21 | |
8aa4edd2 VZ |
22 | // declare a linked list of modules |
23 | class wxModule; | |
f6bcfd97 | 24 | WX_DECLARE_EXPORTED_LIST(wxModule, wxModuleList); |
8aa4edd2 VZ |
25 | |
26 | // declaring a class derived from wxModule will automatically create an | |
27 | // instance of this class on program startup, call its OnInit() method and call | |
28 | // OnExit() on program termination (but only if OnInit() succeeded) | |
29 | class WXDLLEXPORT wxModule : public wxObject | |
c801d85f KB |
30 | { |
31 | public: | |
8aa4edd2 VZ |
32 | wxModule() {} |
33 | virtual ~wxModule() {} | |
c801d85f | 34 | |
0b9ab0bd RL |
35 | // if module init routine returns FALSE application |
36 | // will fail to startup | |
37 | ||
8aa4edd2 VZ |
38 | bool Init() { return OnInit(); } |
39 | void Exit() { OnExit(); } | |
c801d85f | 40 | |
0b9ab0bd | 41 | // Override both of these |
8aa4edd2 | 42 | // called on program startup |
0b9ab0bd | 43 | |
8aa4edd2 | 44 | virtual bool OnInit() = 0; |
0b9ab0bd RL |
45 | |
46 | // called just before program termination, but only if OnInit() | |
8aa4edd2 | 47 | // succeeded |
0b9ab0bd | 48 | |
8aa4edd2 | 49 | virtual void OnExit() = 0; |
c801d85f KB |
50 | |
51 | static void RegisterModule(wxModule* module); | |
8aa4edd2 VZ |
52 | static void RegisterModules(); |
53 | static bool InitializeModules(); | |
54 | static void CleanUpModules(); | |
c801d85f | 55 | |
0b9ab0bd RL |
56 | // used by wxObjectLoader when unloading shared libs's |
57 | ||
58 | static void UnregisterModule(wxModule* module); | |
59 | ||
c801d85f | 60 | protected: |
8aa4edd2 | 61 | static wxModuleList m_modules; |
c801d85f | 62 | |
8aa4edd2 | 63 | DECLARE_CLASS(wxModule) |
c801d85f KB |
64 | }; |
65 | ||
8aa4edd2 | 66 | #endif // _WX_MODULEH__ |
c801d85f | 67 |