X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/af266e5bf7e064ba818c1b1619325eb8c5b874f7..a4ea083bbdf710d3234dcbd2eafb5d0e078f8348:/src/common/module.cpp diff --git a/src/common/module.cpp b/src/common/module.cpp index 9167848b89..b8438d4602 100644 --- a/src/common/module.cpp +++ b/src/common/module.cpp @@ -4,7 +4,6 @@ // Author: Wolfram Gloger/adapted by Guilhem Lavaux // Modified by: // Created: 04/11/98 -// RCS-ID: $Id$ // Copyright: (c) Wolfram Gloger and Guilhem Lavaux // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -26,11 +25,11 @@ #include "wx/listimpl.cpp" -#define TRACE_MODULE _T("module") +#define TRACE_MODULE wxT("module") WX_DEFINE_LIST(wxModuleList) -IMPLEMENT_CLASS(wxModule, wxObject) +wxIMPLEMENT_ABSTRACT_CLASS(wxModule, wxObject) wxModuleList wxModule::m_modules; @@ -50,23 +49,20 @@ void wxModule::UnregisterModule(wxModule* module) // and register them. void wxModule::RegisterModules() { - wxHashTable::compatibility_iterator node; - wxClassInfo* classInfo; - - wxClassInfo::sm_classTable->BeginFind(); - node = wxClassInfo::sm_classTable->Next(); - while (node) + for (wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo(), + end = wxClassInfo::end_classinfo(); + it != end; ++it) { - classInfo = (wxClassInfo *)node->GetData(); - if ( classInfo->IsKindOf(CLASSINFO(wxModule)) && - (classInfo != (& (wxModule::ms_classInfo))) ) + const wxClassInfo* classInfo = *it; + + if ( classInfo->IsKindOf(wxCLASSINFO(wxModule)) && + (classInfo != (& (wxModule::ms_classInfo))) ) { wxLogTrace(TRACE_MODULE, wxT("Registering module %s"), classInfo->GetClassName()); wxModule* module = (wxModule *)classInfo->CreateObject(); - RegisterModule(module); + wxModule::RegisterModule(module); } - node = wxClassInfo::sm_classTable->Next(); } } @@ -82,6 +78,10 @@ bool wxModule::DoInitializeModule(wxModule *module, module->m_state = State_Initializing; + // translate named dependencies to the normal ones first + if ( !module->ResolveNamedDependencies() ) + return false; + const wxArrayClassInfo& dependencies = module->m_dependencies; // satisfy module dependencies by loading them before the current module @@ -191,7 +191,7 @@ void wxModule::DoCleanUpModules(const wxModuleList& modules) wxModule * module = node->GetData(); wxASSERT_MSG( module->m_state == State_Initialized, - _T("not initialized module being cleaned up") ); + wxT("not initialized module being cleaned up") ); module->Exit(); module->m_state = State_Registered; @@ -200,3 +200,25 @@ void wxModule::DoCleanUpModules(const wxModuleList& modules) // clear all modules, even the non-initialized ones WX_CLEAR_LIST(wxModuleList, m_modules); } + +bool wxModule::ResolveNamedDependencies() +{ + // first resolve required dependencies + for ( size_t i = 0; i < m_namedDependencies.size(); ++i ) + { + wxClassInfo *info = wxClassInfo::FindClass(m_namedDependencies[i]); + + if ( !info ) + { + // required dependency not found + return false; + } + + // add it even if it is not derived from wxModule because + // DoInitializeModule() will make sure a module with the same class + // info exists and fail if it doesn't + m_dependencies.Add(info); + } + + return true; +}