]> git.saurik.com Git - wxWidgets.git/blob - include/wx/module.h
fix for CW compilation
[wxWidgets.git] / include / wx / module.h
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
12 #ifndef _WX_MODULE_H_
13 #define _WX_MODULE_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "module.h"
17 #endif
18
19 #include "wx/object.h"
20 #include "wx/list.h"
21
22 // declare a linked list of modules
23 class WXDLLIMPEXP_BASE wxModule;
24 WX_DECLARE_USER_EXPORTED_LIST(wxModule, wxModuleList, WXDLLIMPEXP_BASE);
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 WXDLLIMPEXP_BASE wxModule : public wxObject
30 {
31 public:
32 wxModule() {}
33 virtual ~wxModule() {}
34
35 // if module init routine returns false the application
36 // will fail to startup
37
38 bool Init() { return OnInit(); }
39 void Exit() { OnExit(); }
40
41 // Override both of these
42
43 // called on program startup
44
45 virtual bool OnInit() = 0;
46
47 // called just before program termination, but only if OnInit()
48 // succeeded
49
50 virtual void OnExit() = 0;
51
52 static void RegisterModule(wxModule *module);
53 static void RegisterModules();
54 static bool InitializeModules();
55 static void CleanUpModules();
56
57 // used by wxObjectLoader when unloading shared libs's
58
59 static void UnregisterModule(wxModule *module);
60
61 protected:
62 static wxModuleList m_modules;
63
64 DECLARE_CLASS(wxModule)
65 };
66
67 #endif // _WX_MODULE_H_
68