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"
25 #include "wx/listimpl.cpp"
28 void wxwxModuleListNode::DeleteData()
30 delete (_WX_LIST_ITEM_TYPE_wxModuleList
*)GetData();
33 WX_DEFINE_LIST(wxModuleList
);
36 IMPLEMENT_CLASS(wxModule
, wxObject
)
38 wxModuleList
wxModule::m_modules
;
40 void wxModule::RegisterModule(wxModule
* module)
42 m_modules
.Append(module);
45 void wxModule::UnregisterModule(wxModule
* module)
47 m_modules
.DeleteObject(module);
50 // Collect up all module-derived classes, create an instance of each,
52 void wxModule::RegisterModules()
55 wxClassInfo
* classInfo
;
57 wxClassInfo::sm_classTable
->BeginFind();
58 node
= wxClassInfo::sm_classTable
->Next();
61 classInfo
= (wxClassInfo
*)node
->Data();
62 if ( classInfo
->IsKindOf(CLASSINFO(wxModule
)) &&
63 (classInfo
!= (& (wxModule::sm_classwxModule
))) )
65 wxModule
* module = (wxModule
*)classInfo
->CreateObject();
66 RegisterModule(module);
68 node
= wxClassInfo::sm_classTable
->Next();
72 bool wxModule::InitializeModules()
74 // Initialize user-defined modules
75 wxModuleList::Node
*node
;
76 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
78 if ( !node
->GetData()->Init() )
80 // clean up already initialized modules - process in reverse order
81 wxModuleList::Node
*n
;
82 for ( n
= node
->GetPrevious(); n
; n
= n
->GetPrevious() )
84 n
->GetData()->OnExit();
94 void wxModule::CleanUpModules()
96 // Cleanup user-defined modules
97 wxModuleList::Node
*node
;
98 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
100 node
->GetData()->Exit();
103 m_modules
.DeleteContents(TRUE
);