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 // Collect up all module-derived classes, create an instance of each,
47 void wxModule::RegisterModules()
50 wxClassInfo
* classInfo
;
52 wxClassInfo::sm_classTable
->BeginFind();
53 node
= wxClassInfo::sm_classTable
->Next();
56 classInfo
= (wxClassInfo
*)node
->Data();
57 if ( classInfo
->IsKindOf(CLASSINFO(wxModule
)) &&
58 (classInfo
!= (& (wxModule::sm_classwxModule
))) )
60 wxModule
* module = (wxModule
*)classInfo
->CreateObject();
61 RegisterModule(module);
63 node
= wxClassInfo::sm_classTable
->Next();
67 bool wxModule::InitializeModules()
69 // Initialize user-defined modules
70 wxModuleList::Node
*node
;
71 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
73 if ( !node
->GetData()->Init() )
75 // clean up already initialized modules - process in reverse order
76 wxModuleList::Node
*n
;
77 for ( n
= node
->GetPrevious(); n
; n
= n
->GetPrevious() )
79 n
->GetData()->OnExit();
89 void wxModule::CleanUpModules()
91 // Cleanup user-defined modules
92 wxModuleList::Node
*node
;
93 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
95 node
->GetData()->Exit();
98 m_modules
.DeleteContents(TRUE
);