Changeset 7389 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Apr 26, 2006, 11:39:51 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7388 r7389 54 54 ShellCommand::~ShellCommand() 55 55 { 56 if (this->alias != NULL && ShellCommandClass::aliasList != NULL) 57 { 58 ShellCommandClass::aliasList->remove(this->alias); 56 if (this->alias != NULL) 59 57 delete this->alias; 60 }61 58 delete this->executor; 62 59 } … … 172 169 { 173 170 // CHECK FOR ALIAS 174 if (ShellCommandClass::aliasList != NULL) 175 { 176 std::list<ShellCommandAlias*>::iterator alias; 177 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++ ) 178 { 179 if (inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL && 180 (*alias)->getCommand()->shellClass != NULL ) 181 { 182 objectList = ClassList::getList((*alias)->getCommand()->shellClass->getName()); 183 if (objectList != NULL) 184 { 185 (*(*alias)->getCommand()->executor)(objectList->front(), inputSplits.getSubSet(1).join()); /// TODO CHECK IF OK 186 return true; 187 } 188 /// TODO CHECK FOR STATIC functions. 189 } 171 std::vector<ShellCommandAlias*>::iterator alias; 172 for (alias = ShellCommandAlias::aliasList.begin(); alias != ShellCommandAlias::aliasList.end(); alias++ ) 173 { 174 if (inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL && 175 (*alias)->getCommand()->shellClass != NULL ) 176 { 177 objectList = ClassList::getList((*alias)->getCommand()->shellClass->getName()); 178 if (objectList != NULL) 179 { 180 (*(*alias)->getCommand()->executor)(objectList->front(), inputSplits.getSubSet(1).join()); 181 return true; 182 } 183 /// TODO CHECK FOR STATIC functions. 190 184 } 191 185 } … … 271 265 272 266 /** 273 * adds an Alias to this Command267 * @brief adds an Alias to this Command 274 268 * @param alias the name of the Alias to set 275 269 * @returns itself … … 286 280 else 287 281 { 288 if (ShellCommandClass::aliasList == NULL)289 ShellCommandClass::aliasList = new std::list<ShellCommandAlias*>;290 291 282 ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this); 292 ShellCommand Class::aliasList->push_back(aliasCMD);283 ShellCommandAlias::aliasList.push_back(aliasCMD); 293 284 this->alias = aliasCMD; 294 285 } … … 357 348 } 358 349 350 351 ShellCommandAlias::ShellCommandAlias(const std::string& aliasName, ShellCommand* command) 352 { 353 this->aliasName = aliasName; 354 this->command = command; 355 ShellCommandAlias::aliasList.push_back(this); 356 }; 357 358 ShellCommandAlias::~ShellCommandAlias() 359 { 360 std::vector<ShellCommandAlias*>::iterator delA = std::find(aliasList.begin(), aliasList.end(), this); 361 if (delA != aliasList.end()) 362 ShellCommandAlias::aliasList.push_back(this); 363 364 } 365 366 std::vector<ShellCommandAlias*> ShellCommandAlias::aliasList; 367 /** 368 * @brief collects the Aliases registered to the ShellCommands 369 * @param stringList a List to paste the Aliases into. 370 * @returns true on success, false otherwise 371 */ 372 bool ShellCommandAlias::getCommandListOfAlias(std::list<std::string>& stringList) 373 { 374 std::vector<ShellCommandAlias*>::iterator alias; 375 for (alias = ShellCommandAlias::aliasList.begin(); alias != ShellCommandAlias::aliasList.end(); alias++) 376 stringList.push_back((*alias)->getName()); 377 return true; 378 } 379 380 359 381 } -
trunk/src/lib/shell/shell_command.h
r7388 r7389 101 101 /** @returns the Command, this Alias is asociated with */ 102 102 ShellCommand* getCommand() const { return this->command; }; 103 static bool getCommandListOfAlias(std::list<std::string>& stringList); 103 104 104 105 private: 105 106 /** @param aliasName the name of the Alias @param command the Command, to associate this alias with */ 106 ShellCommandAlias(const std::string& aliasName, ShellCommand* command) { this->aliasName = aliasName; this->command = command; };107 107 ShellCommandAlias(const std::string& aliasName, ShellCommand* command); 108 ~ShellCommandAlias(); 108 109 private: 109 110 std::string aliasName; //!< the name of the Alias 110 111 ShellCommand* command; //!< a pointer to the command, this alias executes. 112 113 static std::vector<ShellCommandAlias*> aliasList; //!< A list of Aliases to A Commands. 111 114 }; 112 115 -
trunk/src/lib/shell/shell_command_class.cc
r7388 r7389 26 26 namespace OrxShell 27 27 { 28 29 28 std::list<ShellCommandClass*>* ShellCommandClass::commandClassList = NULL; 30 std::list<ShellCommandAlias*>* ShellCommandClass::aliasList = NULL;31 29 32 30 /** … … 79 77 80 78 /** 81 * collects the Aliases registered to the ShellCommands 82 * @param stringList a List to paste the Aliases into. 83 * @returns true on success, false otherwise 84 */ 85 bool ShellCommandClass::getCommandListOfAlias(std::list<std::string>& stringList) 86 { 87 if (ShellCommandClass::aliasList == NULL) 88 return false; 89 90 std::list<ShellCommandAlias*>::iterator alias; 91 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++) 92 stringList.push_back((*alias)->getName()); 93 return true; 94 } 95 96 /** 97 * unregisters all Commands that exist 79 * @brief unregisters all Commands that exist 98 80 */ 99 81 void ShellCommandClass::unregisterAllCommands() … … 109 91 } 110 92 111 // unregister all aliases (there should be nothing to do here :)) 112 if (ShellCommandClass::aliasList != NULL) 113 { 114 std::list<ShellCommandAlias*>::iterator alias; 115 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++) 116 delete (*alias); 117 delete ShellCommandClass::aliasList; 118 ShellCommandClass::aliasList = NULL; 119 } 120 } 121 122 /** 123 * checks if a Class is already registered to the Commands' class-stack 93 } 94 95 /** 96 * @brief checks if a Class is already registered to the Commands' class-stack 124 97 * @param className the Name of the Class to check for 125 98 * @returns the CommandClass if found, NULL otherwise … … 222 195 { 223 196 std::vector<ShellCommand*>::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command); 224 this->commandList.erase(delC); 197 if (delC != this->commandList.end()) 198 this->commandList.erase(delC); 225 199 } 226 200 -
trunk/src/lib/shell/shell_command_class.h
r7388 r7389 27 27 28 28 static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); 29 static bool getCommandListOfAlias(std::list<std::string>& aliasList);30 29 31 30 static ShellCommandClass* getCommandClass(const std::string& className); … … 49 48 std::vector<ShellCommand*> commandList; //!< A list of Commands from this Class 50 49 static std::list<ShellCommandClass*>* commandClassList; //!< A list of Classes 51 static std::list<ShellCommandAlias*>* aliasList; //!< A list of Aliases to A Commands.52 50 }; 53 51 -
trunk/src/lib/shell/shell_completion.cc
r7388 r7389 166 166 { 167 167 std::list<std::string> aliasList; 168 ShellCommand Class::getCommandListOfAlias(aliasList);168 ShellCommandAlias::getCommandListOfAlias(aliasList); 169 169 //printf("%s\n", boList->firstElement()->getName()); 170 170 if (!this->addToCompleteList(aliasList, aliasBegin, AliasCompletion))
Note: See TracChangeset
for help on using the changeset viewer.