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