]> git.saurik.com Git - wxWidgets.git/blame - src/common/module.cpp
Changed an OBJARRAY to an EXPORTED_OBJARRAY
[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
ce3ed50d
JS
27#ifdef __SALFORDC__
28void wxwxModuleListNode::DeleteData()
29{
30 delete (_WX_LIST_ITEM_TYPE_wxModuleList *)GetData();
31}
32#else
8aa4edd2 33WX_DEFINE_LIST(wxModuleList);
ce3ed50d 34#endif
c801d85f
KB
35
36IMPLEMENT_CLASS(wxModule, wxObject)
37
8aa4edd2 38wxModuleList wxModule::m_modules;
c801d85f
KB
39
40void wxModule::RegisterModule(wxModule* module)
41{
8aa4edd2 42 m_modules.Append(module);
c801d85f
KB
43}
44
45// Collect up all module-derived classes, create an instance of each,
46// and register them.
8aa4edd2 47void wxModule::RegisterModules()
c801d85f 48{
f4a8c29f
GL
49 wxNode *node;
50 wxClassInfo* classInfo;
51
0c32066b
JS
52 wxClassInfo::sm_classTable->BeginFind();
53 node = wxClassInfo::sm_classTable->Next();
f4a8c29f 54 while (node)
c801d85f 55 {
f4a8c29f 56 classInfo = (wxClassInfo *)node->Data();
8aa4edd2
VZ
57 if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
58 (classInfo != (& (wxModule::sm_classwxModule))) )
c801d85f 59 {
8aa4edd2 60 wxModule* module = (wxModule *)classInfo->CreateObject();
c801d85f
KB
61 RegisterModule(module);
62 }
0c32066b 63 node = wxClassInfo::sm_classTable->Next();
c801d85f 64 }
c801d85f
KB
65}
66
8aa4edd2 67bool wxModule::InitializeModules()
c801d85f 68{
8aa4edd2
VZ
69 // Initialize user-defined modules
70 wxModuleList::Node *node;
71 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
c801d85f 72 {
8aa4edd2
VZ
73 if ( !node->GetData()->Init() )
74 {
75 // clean up already initialized modules - process in reverse order
76 wxModuleList::Node *n;
77 for ( n = node->GetPrevious(); n; n = n->GetPrevious() )
78 {
79 n->GetData()->OnExit();
80 }
81
82 return FALSE;
83 }
c801d85f 84 }
8aa4edd2 85
c801d85f
KB
86 return TRUE;
87}
88
8aa4edd2 89void wxModule::CleanUpModules()
c801d85f 90{
8aa4edd2
VZ
91 // Cleanup user-defined modules
92 wxModuleList::Node *node;
93 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
c801d85f 94 {
8aa4edd2 95 node->GetData()->Exit();
c801d85f 96 }
8aa4edd2
VZ
97
98 m_modules.DeleteContents(TRUE);
c801d85f
KB
99 m_modules.Clear();
100}
101