1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Modules handling
4 // Author: Wolfram Gloger/adapted by Guilhem Lavaux
8 // Copyright: (c) Wolfram Gloger and Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/object.h"
18 // declare a linked list of modules
19 class WXDLLIMPEXP_BASE wxModule
;
20 WX_DECLARE_USER_EXPORTED_LIST(wxModule
, wxModuleList
, WXDLLIMPEXP_BASE
);
22 // declaring a class derived from wxModule will automatically create an
23 // instance of this class on program startup, call its OnInit() method and call
24 // OnExit() on program termination (but only if OnInit() succeeded)
25 class WXDLLIMPEXP_BASE wxModule
: public wxObject
29 virtual ~wxModule() {}
31 // if module init routine returns false the application
32 // will fail to startup
34 bool Init() { return OnInit(); }
35 void Exit() { OnExit(); }
37 // Override both of these
39 // called on program startup
41 virtual bool OnInit() = 0;
43 // called just before program termination, but only if OnInit()
46 virtual void OnExit() = 0;
48 static void RegisterModule(wxModule
*module);
49 static void RegisterModules();
50 static bool InitializeModules();
51 static void CleanUpModules();
53 // used by wxObjectLoader when unloading shared libs's
55 static void UnregisterModule(wxModule
*module);
58 static wxModuleList m_modules
;
60 DECLARE_CLASS(wxModule
)
63 #endif // _WX_MODULE_H_