]> git.saurik.com Git - wxWidgets.git/blame - src/common/module.cpp
bundle icon
[wxWidgets.git] / src / common / module.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: module.cpp
3// Purpose: Modules initialization/destruction
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "module.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#include "wx/module.h"
f4a8c29f 24#include "wx/hash.h"
8aa4edd2
VZ
25#include "wx/listimpl.cpp"
26
27WX_DEFINE_LIST(wxModuleList);
c801d85f
KB
28
29IMPLEMENT_CLASS(wxModule, wxObject)
30
8aa4edd2 31wxModuleList wxModule::m_modules;
c801d85f
KB
32
33void wxModule::RegisterModule(wxModule* module)
34{
8aa4edd2 35 m_modules.Append(module);
c801d85f
KB
36}
37
0b9ab0bd
RL
38void wxModule::UnregisterModule(wxModule* module)
39{
40 m_modules.DeleteObject(module);
41}
42
c801d85f
KB
43// Collect up all module-derived classes, create an instance of each,
44// and register them.
8aa4edd2 45void wxModule::RegisterModules()
c801d85f 46{
f4a8c29f
GL
47 wxNode *node;
48 wxClassInfo* classInfo;
49
0c32066b
JS
50 wxClassInfo::sm_classTable->BeginFind();
51 node = wxClassInfo::sm_classTable->Next();
f4a8c29f 52 while (node)
c801d85f 53 {
b1d4dd7a 54 classInfo = (wxClassInfo *)node->GetData();
8aa4edd2
VZ
55 if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
56 (classInfo != (& (wxModule::sm_classwxModule))) )
c801d85f 57 {
8aa4edd2 58 wxModule* module = (wxModule *)classInfo->CreateObject();
c801d85f
KB
59 RegisterModule(module);
60 }
0c32066b 61 node = wxClassInfo::sm_classTable->Next();
c801d85f 62 }
c801d85f
KB
63}
64
8aa4edd2 65bool wxModule::InitializeModules()
c801d85f 66{
8aa4edd2
VZ
67 // Initialize user-defined modules
68 wxModuleList::Node *node;
69 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
c801d85f 70 {
8aa4edd2
VZ
71 if ( !node->GetData()->Init() )
72 {
73 // clean up already initialized modules - process in reverse order
74 wxModuleList::Node *n;
75 for ( n = node->GetPrevious(); n; n = n->GetPrevious() )
76 {
77 n->GetData()->OnExit();
78 }
79
80 return FALSE;
81 }
c801d85f 82 }
8aa4edd2 83
c801d85f
KB
84 return TRUE;
85}
86
8aa4edd2 87void wxModule::CleanUpModules()
c801d85f 88{
8aa4edd2
VZ
89 // Cleanup user-defined modules
90 wxModuleList::Node *node;
91 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
c801d85f 92 {
8aa4edd2 93 node->GetData()->Exit();
c801d85f 94 }
8aa4edd2
VZ
95
96 m_modules.DeleteContents(TRUE);
c801d85f
KB
97 m_modules.Clear();
98}
99