]> git.saurik.com Git - wxWidgets.git/blob - src/common/module.cpp
Removed duplicate code
[wxWidgets.git] / src / common / module.cpp
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"
24
25 IMPLEMENT_CLASS(wxModule, wxObject)
26
27 wxList wxModule::m_modules;
28
29 void wxModule::RegisterModule(wxModule* module)
30 {
31 m_modules.Append(module);
32 }
33
34 // Collect up all module-derived classes, create an instance of each,
35 // and register them.
36 bool wxModule::RegisterModules(void)
37 {
38 wxClassInfo* classInfo = wxClassInfo::first;
39 while (classInfo)
40 {
41 if ((classInfo != (& (wxModule::classwxModule))) &&
42 classInfo->IsKindOf(CLASSINFO(wxModule)))
43 {
44 wxModule* module = (wxModule*) classInfo->CreateObject();
45 RegisterModule(module);
46 }
47 classInfo = classInfo->next;
48 }
49 return TRUE;
50 }
51
52 bool wxModule::InitializeModules(void)
53 {
54 // Initialize user-defined modules
55 for (wxNode *node = m_modules.First(); node; node = node->Next())
56 {
57 if (!((wxModule*)(node->Data()))->Init())
58 return FALSE;
59 }
60 return TRUE;
61 }
62
63 void wxModule::CleanUpModules(void)
64 {
65 // Cleanup user-defined modules
66 for(wxNode* node = m_modules.Last(); node; node = node->Previous())
67 {
68 ((wxModule*)(node->Data()))->Exit();
69 delete (wxModule*)(node->Data());
70 }
71 m_modules.Clear();
72 }
73