]> git.saurik.com Git - wxWidgets.git/blob - src/common/module.cpp
set error to GSOCK_TIMEOUT if the socket timed out (modified and extended patch 1303554)
[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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #include "wx/module.h"
20 #include "wx/hash.h"
21 #include "wx/intl.h"
22 #include "wx/log.h"
23 #include "wx/listimpl.cpp"
24
25 WX_DEFINE_LIST(wxModuleList)
26
27 IMPLEMENT_CLASS(wxModule, wxObject)
28
29 wxModuleList wxModule::m_modules;
30
31 void wxModule::RegisterModule(wxModule* module)
32 {
33 m_modules.Append(module);
34 }
35
36 void wxModule::UnregisterModule(wxModule* module)
37 {
38 m_modules.DeleteObject(module);
39 delete module;
40 }
41
42 // Collect up all module-derived classes, create an instance of each,
43 // and register them.
44 void wxModule::RegisterModules()
45 {
46 wxHashTable::compatibility_iterator node;
47 wxClassInfo* classInfo;
48
49 wxClassInfo::sm_classTable->BeginFind();
50 node = wxClassInfo::sm_classTable->Next();
51 while (node)
52 {
53 classInfo = (wxClassInfo *)node->GetData();
54 if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
55 (classInfo != (& (wxModule::ms_classInfo))) )
56 {
57 wxModule* module = (wxModule *)classInfo->CreateObject();
58 RegisterModule(module);
59 }
60 node = wxClassInfo::sm_classTable->Next();
61 }
62 }
63
64 bool wxModule::InitializeModules()
65 {
66 // Initialize user-defined modules
67 wxModuleList::compatibility_iterator node;
68 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
69 {
70 wxModule *module = node->GetData();
71 if ( !module->Init() )
72 {
73 wxLogError(_("Module \"%s\" initialization failed"),
74 module->GetClassInfo()->GetClassName());
75
76 // clean up already initialized modules - process in reverse order
77 wxModuleList::compatibility_iterator n;
78 for ( n = node->GetPrevious(); n; n = n->GetPrevious() )
79 {
80 n->GetData()->OnExit();
81 }
82
83 return false;
84 }
85 }
86
87 return true;
88 }
89
90 void wxModule::CleanUpModules()
91 {
92 // Cleanup user-defined modules
93 wxModuleList::compatibility_iterator node;
94 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
95 {
96 node->GetData()->Exit();
97 }
98
99 WX_CLEAR_LIST(wxModuleList, m_modules);
100 }
101