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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "module.h"
19 #include "wx/object.h"
22 // declare a linked list of modules
24 WX_DECLARE_USER_EXPORTED_LIST(wxModule
, wxModuleList
, WXDLLIMPEXP_BASE
);
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
33 virtual ~wxModule() {}
35 // if module init routine returns false the application
36 // will fail to startup
38 bool Init() { return OnInit(); }
39 void Exit() { OnExit(); }
41 // Override both of these
43 // called on program startup
45 virtual bool OnInit() = 0;
47 // called just before program termination, but only if OnInit()
50 virtual void OnExit() = 0;
52 static void RegisterModule(wxModule
*module);
53 static void RegisterModules();
54 static bool InitializeModules();
55 static void CleanUpModules();
57 // used by wxObjectLoader when unloading shared libs's
59 static void UnregisterModule(wxModule
*module);
62 static wxModuleList m_modules
;
64 DECLARE_CLASS(wxModule
)
67 #endif // _WX_MODULE_H_