]>
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"
25 #include "wx/listimpl.cpp"
27 WX_DEFINE_LIST(wxModuleList
);
29 IMPLEMENT_CLASS(wxModule
, wxObject
)
31 wxModuleList
wxModule::m_modules
;
33 void wxModule::RegisterModule(wxModule
* module)
35 m_modules
.Append(module);
38 void wxModule::UnregisterModule(wxModule
* module)
40 m_modules
.DeleteObject(module);
43 // Collect up all module-derived classes, create an instance of each,
45 void wxModule::RegisterModules()
48 wxClassInfo
* classInfo
;
50 wxClassInfo::sm_classTable
->BeginFind();
51 node
= wxClassInfo::sm_classTable
->Next();
54 classInfo
= (wxClassInfo
*)node
->GetData();
55 if ( classInfo
->IsKindOf(CLASSINFO(wxModule
)) &&
56 (classInfo
!= (& (wxModule::sm_classwxModule
))) )
58 wxModule
* module = (wxModule
*)classInfo
->CreateObject();
59 RegisterModule(module);
61 node
= wxClassInfo::sm_classTable
->Next();
65 bool wxModule::InitializeModules()
67 // Initialize user-defined modules
68 wxModuleList::Node
*node
;
69 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
71 if ( !node
->GetData()->Init() )
73 // clean up already initialized modules - process in reverse order
74 wxModuleList::Node
*n
;
75 for ( n
= node
->GetPrevious(); n
; n
= n
->GetPrevious() )
77 n
->GetData()->OnExit();
87 void wxModule::CleanUpModules()
89 // Cleanup user-defined modules
90 wxModuleList::Node
*node
;
91 for ( node
= m_modules
.GetFirst(); node
; node
= node
->GetNext() )
93 node
->GetData()->Exit();
96 m_modules
.DeleteContents(TRUE
);