Changeset 5196 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 18, 2005, 2:39:39 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5195 r5196 41 41 this->classID = CL_NULL; 42 42 this->commandList = new tList<ShellCommandBase>; 43 this->aliasList = new tList<ShellCommandAlias>;44 43 45 44 ShellCommandClass::commandClassList->add(this); … … 91 90 bool ShellCommandClass::getCommandListOfAlias(tList<const char>* stringList) 92 91 { 93 if (stringList == NULL )92 if (stringList == NULL || ShellCommandClass::aliasList == NULL) 94 93 return false; 95 94 96 95 tIterator<ShellCommandAlias>* iterator = ShellCommandClass::aliasList->getIterator(); 97 ShellCommandAlias* elem = iterator->firstElement();98 while(elem != NULL)99 {100 stringList->add(elem->getName());101 elem = iterator->nextElement();102 }103 delete iterator;104 return true;96 ShellCommandAlias* elem = iterator->firstElement(); 97 while(elem != NULL) 98 { 99 stringList->add(elem->getName()); 100 elem = iterator->nextElement(); 101 } 102 delete iterator; 103 return true; 105 104 } 106 105 … … 126 125 127 126 // unregister all aliases (there should be nothing to do here :)) 128 tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator(); 129 ShellCommandAlias* elemAL = itAL->firstElement(); 130 while(elemAL != NULL) 131 { 132 delete elemAL; 133 elemAL = itAL->nextElement(); 134 } 135 delete itAL; 136 delete ShellCommandClass::aliasList; 137 ShellCommandClass::aliasList = NULL; 127 if (ShellCommandClass::aliasList != NULL) 128 { 129 tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator(); 130 ShellCommandAlias* elemAL = itAL->firstElement(); 131 while(elemAL != NULL) 132 { 133 delete elemAL; 134 elemAL = itAL->nextElement(); 135 } 136 delete itAL; 137 delete ShellCommandClass::aliasList; 138 ShellCommandClass::aliasList = NULL; 139 } 138 140 } 139 141 … … 213 215 this->setName(commandName); 214 216 this->description = NULL; 217 this->alias = NULL; 215 218 216 219 // this->classID = classID; … … 267 270 { 268 271 delete[] this->parameters; 272 if (this->alias != NULL && ShellCommandClass::aliasList != NULL) 273 { 274 ShellCommandClass::aliasList->remove(this->alias); 275 delete this->alias; 276 } 269 277 } 270 278 … … 462 470 ShellCommandBase* ShellCommandBase::setAlias(const char* alias) 463 471 { 464 ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this); 465 ShellCommandClass::aliasList->add(aliasCMD); 472 if (this == NULL) 473 return NULL; 474 475 if (this->alias != NULL) 476 { 477 PRINTF(2)("not more than one Alias allowed for functions (%s::%s)\n", this->getName(), this->shellClass->getName()); 478 } 479 else 480 { 481 if (ShellCommandClass::aliasList == NULL) 482 ShellCommandClass::aliasList = new tList<ShellCommandAlias>; 483 484 ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this); 485 ShellCommandClass::aliasList->add(aliasCMD); 486 this->alias = aliasCMD; 487 } 488 return this; 466 489 } 467 490 -
trunk/src/lib/shell/shell_command.h
r5195 r5196 85 85 86 86 /** @returns the CommandList of the Shell */ 87 88 87 static void unregisterCommand(const char* commandName, const char* className); 89 88 … … 114 113 private: 115 114 ShellCommandClass* shellClass; //!< A Pointer to the Shell-Class this Command belongs to. 115 ShellCommandAlias* alias; //!< An Alias for the Class. 116 116 117 117 const char* description; //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla"); … … 319 319 class ShellCommandAlias 320 320 { 321 friend class ShellCommandBase; 321 322 public: 322 ShellCommandAlias(const char* aliasName, ShellCommandBase* command) { this->aliasName = aliasName; this->command = command; };323 324 323 const char* getName() const { return this->aliasName; }; 325 324 ShellCommandBase* getCommand() const { return this->command; }; 325 326 private: 327 ShellCommandAlias(const char* aliasName, ShellCommandBase* command) { this->aliasName = aliasName; this->command = command; }; 328 326 329 private: 327 330 const char* aliasName;
Note: See TracChangeset
for help on using the changeset viewer.