#include <modlist.h>
Inheritance diagram for ModuleList:
Public Member Functions | |
~ModuleList () | |
Destroys a module list, destroying all modules in the list too. | |
ModuleListItem * | Add (Module *, OILModule *) |
Safe addition of modules to the kernel's list of known modules. A module will only be added if its ID has not already been used. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (ModuleList) |
Definition at line 158 of file modlist.h.
|
Destroys a module list, destroying all modules in the list too.
Definition at line 184 of file modlist.cpp. 00185 { 00186 // Call destructors on all objects in the list 00187 00188 ModuleListItem *Item = (ModuleListItem *) RemoveHead(); 00189 00190 while (Item != NULL) 00191 { 00192 // Delete the list item 00193 delete Item; 00194 00195 // Try the next item 00196 Item = (ModuleListItem *) RemoveHead(); 00197 } 00198 00199 }
|
|
Safe addition of modules to the kernel's list of known modules. A module will only be added if its ID has not already been used.
Definition at line 220 of file modlist.cpp. 00221 { 00222 // Construct a tentative list item. 00223 ModuleListItem *NewItem = new ModuleListItem(pNewModule, pNewOILModule); 00224 if (NewItem == NULL) 00225 return NULL; 00226 00227 // Fill in the OILModule pointer with the pointer provided by the caller. 00228 NewItem->m_pOILModule = pNewOILModule; 00229 00230 // Interrogate module about itself. 00231 if( NewItem->m_ModInfo.ID == MODULEID_INVALID ) 00232 { 00233 // Invalid ID - discard new list item and abort. 00234 NewItem->m_pModule = NULL; // dont delete the module 00235 delete NewItem; 00236 return NULL; 00237 } 00238 00239 00240 // Search list to make sure this ID is not already in use. 00241 ModuleListItem *Item = (ModuleListItem *) GetHead(); 00242 00243 while (Item != NULL) 00244 { 00245 if( Item->m_ModInfo.ID == NewItem->m_ModInfo.ID ) 00246 { 00247 // Found ID already in use - discard new list item and abort. 00248 NewItem->m_pModule = NULL; // dont delete the module 00249 delete NewItem; 00250 return NULL; 00251 } 00252 00253 // Try the next node in the list. 00254 Item = (ModuleListItem *) GetNext(Item); 00255 } 00256 00257 // The ID is not already in use so add the module to the list. 00258 AddTail(NewItem); 00259 return NewItem; 00260 }
|
|
|