]>
git.saurik.com Git - wxWidgets.git/blob - src/common/module.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Modules initialization/destruction
4 // Author: Wolfram Gloger/adapted by Guilhem Lavaux
8 // Copyright: (c) Wolfram Gloger and Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "module.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/module.h"
26 IMPLEMENT_CLASS(wxModule
, wxObject
)
28 wxList
wxModule::m_modules
;
30 void wxModule::RegisterModule(wxModule
* module)
32 m_modules
.Append(module);
35 // Collect up all module-derived classes, create an instance of each,
37 bool wxModule::RegisterModules(void)
40 wxClassInfo
* classInfo
;
42 wxClassInfo::classTable
.BeginFind();
43 node
= wxClassInfo::classTable
.Next();
46 classInfo
= (wxClassInfo
*)node
->Data();
47 if ((classInfo
!= (& (wxModule::classwxModule
))) &&
48 classInfo
->IsKindOf(CLASSINFO(wxModule
)))
50 wxModule
* module = (wxModule
*) classInfo
->CreateObject();
51 RegisterModule(module);
53 node
= wxClassInfo::classTable
.Next();
58 bool wxModule::InitializeModules(void)
60 // Initialize user-defined modules
61 for (wxNode
*node
= m_modules
.First(); node
; node
= node
->Next())
63 if (!((wxModule
*)(node
->Data()))->Init())
69 void wxModule::CleanUpModules(void)
71 // Cleanup user-defined modules
72 for(wxNode
* node
= m_modules
.Last(); node
; node
= node
->Previous())
74 ((wxModule
*)(node
->Data()))->Exit();
75 delete (wxModule
*)(node
->Data());