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