Changeset 5171 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 7, 2005, 1:08:21 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5170 r5171 57 57 } 58 58 59 const ShellCommandClass* ShellCommandClass::isRegistered(const char* className) 60 { 61 if (ShellCommandClass::commandClassList == NULL)62 initCommandClassList(); 63 59 /** 60 * unregisters all Commands that exist 61 */ 62 void ShellCommandClass::unregisterAllCommands() 63 { 64 64 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 65 65 ShellCommandClass* elem = iterator->firstElement(); 66 66 while(elem != NULL) 67 67 { 68 delete elem; 69 70 elem = iterator->nextElement(); 71 } 72 delete iterator; 73 74 delete ShellCommandClass::commandClassList; 75 ShellCommandClass::commandClassList = NULL; 76 } 77 78 const ShellCommandClass* ShellCommandClass::isRegistered(const char* className) 79 { 80 if (ShellCommandClass::commandClassList == NULL) 81 initCommandClassList(); 82 83 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 84 ShellCommandClass* elem = iterator->firstElement(); 85 while(elem != NULL) 86 { 68 87 if (!strcmp(className, elem->className)) 69 88 { 89 if (elem->classID == CL_NULL) 90 elem->classID = ClassList::StringToID(className); 91 70 92 delete iterator; 71 93 return elem; … … 178 200 179 201 /** 180 * unregisters all Commands that exist181 */182 void ShellCommandBase::unregisterAllCommands()183 {184 // tIterator<ShellCommandBase>* iterator = ShellCommandBase::commandList->getIterator();185 // ShellCommandBase* elem = iterator->firstElement();186 // while(elem != NULL)187 // {188 // delete elem;189 //190 // elem = iterator->nextElement();191 // }192 // delete iterator;193 //194 // delete ShellCommandBase::commandList;195 // ShellCommandBase::commandList = NULL;196 }197 198 /**199 202 * unregister an existing commandName 200 203 * @param className the name of the Class the command belongs to. … … 205 208 void ShellCommandBase::unregisterCommand(const char* commandName, const char* className) 206 209 { 207 PRINTF(1)("IMPLEMENT THIS\n"); 210 if (ShellCommandClass::commandClassList == NULL) 211 ShellCommandClass::initCommandClassList(); 212 213 const ShellCommandClass* checkClass = ShellCommandClass::isRegistered(className); 214 215 if (checkClass != NULL) 216 { 217 tIterator<ShellCommandBase>* iterator = checkClass->commandList->getIterator(); 218 ShellCommandBase* elem = iterator->firstElement(); 219 while(elem != NULL) 220 { 221 if (!strcmp(commandName, elem->getName())) 222 { 223 checkClass->commandList->remove(elem); 224 delete elem; 225 break; 226 } 227 elem = iterator->nextElement(); 228 } 229 delete iterator; 230 231 if (checkClass->commandList->getSize() == 0) 232 { 233 ShellCommandClass::commandClassList->remove(checkClass); 234 delete checkClass; 235 } 236 } 208 237 } 209 238 … … 378 407 if (ShellCommandClass::commandClassList == NULL) 379 408 { 380 PRINT(0)("No Command registered so far\n");409 PRINT(0)("No Command registered.\n"); 381 410 return; 382 411 } … … 386 415 while(elemCL != NULL) 387 416 { 417 PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize()); 388 418 tIterator<ShellCommandBase>* iterator = elemCL->commandList->getIterator(); 389 419 const ShellCommandBase* elem = iterator->firstElement(); 390 420 { 391 PRINT(0)("Class:'%s' registered: \n", elemCL->className); 392 PRINT(0)(" command:'%s':params:%d: ", elem->getName(), elem->paramCount); 421 PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->paramCount); 393 422 for (unsigned int i = 0; i< elem->paramCount; i++) 394 423 printf("%s ", ShellCommandBase::paramToString(elem->parameters[i])); -
trunk/src/lib/shell/shell_command.h
r5170 r5171 45 45 static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; }; 46 46 static ShellCommandClass* getCommandClass(const char* className); 47 static void unregisterAllCommands(); 47 48 48 49 private: … … 54 55 55 56 private: 56 const char* className;57 ClassID classID;58 tList<ShellCommandBase>* commandList;59 static tList<ShellCommandClass>* commandClassList;//!< A list of Classes57 const char* className; //!< The Name of the Class. This should match the ClassName of the Commands Class. 58 long classID; //!< The classID of this Class 59 tList<ShellCommandBase>* commandList; //!< A list of Commands from this Class 60 static tList<ShellCommandClass>* commandClassList; //!< A list of Classes 60 61 }; 61 62 … … 72 73 /** @returns the CommandList of the Shell */ 73 74 74 static void unregisterAllCommands();75 75 static void unregisterCommand(const char* commandName, const char* className); 76 76 -
trunk/src/lib/util/list.h
r5131 r5171 37 37 void add(T* entity); 38 38 void addAtBeginning(T* entity); //!< @todo This should be made with an ENUM 39 void remove( T* entity);39 void remove(const T* entity); 40 40 void removeLast(); 41 41 void flush(); … … 138 138 */ 139 139 template<class T> 140 inline void tList<T>::remove( T* entity)140 inline void tList<T>::remove(const T* entity) 141 141 { 142 142 this->currentEl = this->first;
Note: See TracChangeset
for help on using the changeset viewer.