#include <module.h>
Inheritance diagram for Module:
Static Public Member Functions | |
static BOOL | InitModules () |
Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase. | |
static void | DeinitModules () |
Deletes all allocated modules (and hence tools), then asks OIL to tidy up. Safe to call more than once. | |
static ModuleListItem * | Find (UINT32 ModuleID) |
Anyone can ask about a module's presence by its ID. | |
static ModuleListItem * | Declare (Module *, OILModule *) |
Called by OIL code to declare new modules. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (Module) | |
Static Private Member Functions | |
static BOOL | CreateTools () |
Scan all modules known to the kernel, and try to create an instance of each tool they contain, and add this tool to the kernel's list. | |
Static Private Attributes | |
static ModuleList * | Modules = NULL |
Definition at line 258 of file module.h.
|
|
|
Scan all modules known to the kernel, and try to create an instance of each tool they contain, and add this tool to the kernel's list.
Definition at line 332 of file module.cpp. 00333 { 00334 // Scan the list of modules 00335 ModuleListItem *Item = (ModuleListItem *) Modules->GetHead(); 00336 00337 while (Item != NULL) 00338 { 00339 // Interrogate module 00340 ModInfo Info; 00341 Item->m_pModule->Describe(&Info); 00342 00343 // Try to create an instance of each tool in this module 00344 for (unsigned tool = 1; tool <= Info.NumTools; tool++) 00345 { 00346 Tool *NewTool = (Tool *) Item->m_pModule->CreateTool(tool); 00347 00348 if (NewTool != NULL) 00349 { 00350 // Tool was created - add it to the list 00351 Tool::Declare(NewTool, Info.ID); 00352 00353 } 00354 } 00355 00356 // Try the next module in the list. 00357 Item = (ModuleListItem *) Modules->GetNext(Item); 00358 } 00359 // Tool* NewTool ; 00360 // NewTool = (Tool*)new ZoomTool; if ( NewTool ) Tool::Declare(NewTool,1); 00361 // NewTool = (Tool*)new PushTool; if ( NewTool ) Tool::Declare(NewTool,Info.ID); 00362 00363 // No error codes yet 00364 return TRUE; 00365 }
|
|
Called by OIL code to declare new modules.
Definition at line 227 of file module.cpp. 00228 { 00229 // Try to add the module to the kernel's list. 00230 ModuleListItem *NewItem = Modules->Add(NewModule, pOILModule); 00231 00232 if (NewItem == NULL) 00233 { 00234 // Either out of memory or Module has invalid ID - print error message and 00235 // destroy module. 00236 #ifdef _DEBUG 00237 ModInfo Info; 00238 NewModule->Describe(&Info); 00239 TRACE( _T("Module %u is invalid or has no memory to initialise with.\n"), Info.ID ); 00240 #endif 00241 00242 delete NewModule; 00243 } 00244 00245 return NewItem; 00246 }
|
|
Deletes all allocated modules (and hence tools), then asks OIL to tidy up. Safe to call more than once.
Definition at line 300 of file module.cpp. 00301 { 00302 if (Modules != NULL) 00303 { 00304 // Delete the list itself. 00305 delete Modules; 00306 Modules = NULL; 00307 00308 // Perform any clean-up required by the OIL layer. 00309 PORTNOTE("other","Removed OILModule usage") 00310 #ifndef EXCLUDE_FROM_XARALX 00311 OILModule::Deinit(); 00312 #endif 00313 } 00314 }
|
|
Anyone can ask about a module's presence by its ID.
Definition at line 263 of file module.cpp. 00264 { 00265 // Simple search of list for ID 00266 00267 ModuleListItem *Item = (ModuleListItem *) Modules->GetHead(); 00268 00269 while (Item != NULL) 00270 { 00271 if (Item->m_ModInfo.ID == ModuleID) 00272 // Found ID - return pointer to this list item. 00273 return Item; 00274 00275 Item = (ModuleListItem *) Modules->GetNext(Item); 00276 } 00277 00278 // Not found 00279 return NULL; 00280 }
|
|
Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase.
Definition at line 146 of file module.cpp. 00147 { 00148 // Initialise the list of Modules. 00149 Modules = new ModuleList; 00150 if (!Modules) 00151 return FALSE; 00152 00153 if (!OILModule::Init()) // get OIL's list of modules. This works 00154 return FALSE; // by calling back to DescribeModule. 00155 // NB. OILModule::Init does it own error 00156 BOOL Finished; // reporting 00157 00158 do 00159 { 00160 // All the modules have been 'new'ed now. We can now ask them to initialise themselves. 00161 // If they don't want to, they get 'delete'ed. 00162 00163 ModuleListItem *Item = (ModuleListItem *) Modules->GetHead(); 00164 00165 Finished = TRUE; 00166 00167 while (Item != NULL) 00168 { 00169 Module *Module = Item->m_pModule; 00170 00171 // If this module exists and has not been initialised yet, then try to 00172 // initialise it. If it initialises ok, set the item's flag, and force 00173 // another scan of the remaining modules in case one of them depends on 00174 // this module being present. 00175 if ((Module != NULL) && (!Item->m_Initialised) && (Module->Init())) 00176 { 00177 Item->m_Initialised = TRUE; // Tool initialised ok. 00178 Finished = FALSE; // At least one more loop to try 00179 } 00180 00181 // Try the next module 00182 Item = (ModuleListItem *) Modules->GetNext(Item); 00183 } 00184 00185 } while (!Finished); 00186 00187 // Delete any un-initialised modules 00188 ModuleListItem *Item = (ModuleListItem *) Modules->GetHead(); 00189 00190 while (Item != NULL) 00191 { 00192 if ((Item->m_pModule != NULL) && (!Item->m_Initialised)) 00193 { 00194 delete Item->m_pModule; 00195 Item->m_pModule = NULL; 00196 } 00197 00198 // Try the next module 00199 Item = (ModuleListItem *) Modules->GetNext(Item); 00200 } 00201 00202 // Scan all the modules and create (but do not initialise) any tools they provide. 00203 if (!Tool::InitToolList() || !CreateTools()) 00204 return FALSE; 00205 00206 return TRUE; 00207 }
|
|
|