#include <toollist.h>
Inheritance diagram for ToolList:
Public Member Functions | |
~ToolList () | |
Destroys a ToolList object. Deletes the Tool and OILTool objects contained in the list items, and deletes the list items themselves. | |
ToolListItem * | Add (Tool *, UINT32 ParentID) |
Safe addition of tools to the kernel's list of known tools. A tool will only be added if its ID has not already been used. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (ToolList) |
Definition at line 153 of file toollist.h.
|
Destroys a ToolList object. Deletes the Tool and OILTool objects contained in the list items, and deletes the list items themselves.
Definition at line 184 of file toollist.cpp. 00185 { 00186 // Call destructors on all objects in the list 00187 00188 ToolListItem *Item = (ToolListItem *) RemoveHead(); 00189 00190 while (Item != NULL) 00191 { 00192 // Delete the list item 00193 delete Item; 00194 00195 // Try the next item 00196 Item = (ToolListItem *) RemoveHead(); 00197 } 00198 }
|
|
Safe addition of tools to the kernel's list of known tools. A tool will only be added if its ID has not already been used.
Definition at line 219 of file toollist.cpp. 00220 { 00221 // Construct a tentative list item 00222 ToolListItem *NewItem = new ToolListItem(NewTool, ParentID); 00223 if (NewItem == NULL) 00224 goto AbnormalExit; 00225 00226 // Create a new OIL tool for this node 00227 // NewItem->m_pOILTool = new OILTool(ParentID); 00228 // if (NewItem->m_pOILTool == NULL) 00229 // goto AbnormalExit; 00230 00231 // Interrogate tool about itself. 00232 /* if (NewItem->ToolInfo.ID == TOOLID_INVALID) 00233 goto AbnormalExit; 00234 00235 00236 // Search list to make sure this ID is not already in use. 00237 // (If I use one line initialisation the compiler complains that the gotos avoid it.) 00238 ToolListItem *Item; 00239 Item = (ToolListItem *) GetHead(); 00240 00241 while (Item != NULL) 00242 { 00243 if (Item->ToolInfo.ID == NewItem->ToolInfo.ID) 00244 // Found ID already in use - discard new list item and abort. 00245 goto AbnormalExit; 00246 00247 // Try the next node in the list. 00248 Item = (ToolListItem *) GetNext(Item); 00249 } 00250 */ 00251 // The ID is not already in use so add the tool to the list. 00252 AddTail(NewItem); 00253 return NewItem; 00254 00255 // Abnormal exit - clean up and return a NULL pointer to indicate it didn't work. 00256 AbnormalExit: 00257 // Set Tool pointer to NULL to avoid it being deleted by the ToolListItem's destructor, because 00258 // the caller is not expecting this tool to be deleted from under its feet. 00259 NewItem->m_pTool = NULL; 00260 00261 // Delete the ToolListItem 00262 delete NewItem; 00263 00264 return NULL; 00265 }
|
|
|