Changeset 9869 in orxonox.OLD for trunk/src/lib/shell/shell_command.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r9406 r9869 20 20 21 21 #include "compiler.h" 22 #include "helper_functions.h" 22 23 #include "debug.h" 23 #include "class_list.h"24 24 25 25 #include "key_names.h" … … 27 27 namespace OrxShell 28 28 { 29 ObjectListDefinition(ShellCommand); 29 30 SHELL_COMMAND(debug, ShellCommandClass, help); 30 31 … … 36 37 * @param paramCount the count of parameters this command takes 37 38 */ 38 ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, Executor * executor)39 { 40 this-> setClassID(CL_SHELL_COMMAND, "ShellCommand");39 ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, Executor<const SubString>* executor) 40 { 41 this->registerObject(this, ShellCommand::_objectList); 41 42 PRINTF(4)("create shellcommand '%s' for class '%s'\n", commandName.c_str(), className.c_str()); 42 43 this->setName(commandName); … … 44 45 // copy the executor: 45 46 this->executor = executor; 46 this->executor->setName(commandName);47 47 48 48 for (unsigned int i = 0; i < this->executor->getParamCount(); i++) … … 75 75 * @brief registers a new ShellCommand 76 76 */ 77 ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, Executor * executor)77 ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, Executor<const SubString>* executor) 78 78 { 79 79 if (ShellCommand::exists(commandName, className)) … … 94 94 void ShellCommand::unregisterCommand(const std::string& commandName, const std::string& className) 95 95 { 96 97 96 ShellCommandClass* cmdClass = ShellCommandClass::acquireCommandClass(className); 98 97 if (cmdClass != NULL) 99 98 { 100 99 CmdList::iterator cmd; 101 for (cmd = cmdClass-> commandList.begin(); cmd != cmdClass->commandList.end(); cmd++)100 for (cmd = cmdClass->_commandList.begin(); cmd != cmdClass->_commandList.end(); cmd++) 102 101 if (commandName == (*cmd)->getName()) 103 102 { … … 119 118 120 119 CmdList::const_iterator elem; 121 for (unsigned int i = 0; i < cmdClass-> commandList.size(); i++)122 { 123 if (commandName == cmdClass-> commandList[i]->getName())124 return (cmdClass-> commandList[i]);120 for (unsigned int i = 0; i < cmdClass->_commandList.size(); i++) 121 { 122 if (commandName == cmdClass->_commandList[i]->getName()) 123 return (cmdClass->_commandList[i]); 125 124 } 126 125 return NULL; … … 242 241 return false; 243 242 244 const std::list<BaseObject*>* objectList = ClassList::getList(cmd->shellClass->getName());243 const ObjectListBase* const objectList = ObjectListBase::getObjectList(cmd->shellClass->getName()); 245 244 if (objectList != NULL) 246 245 { 247 std::list<BaseObject*>::const_iterator bo; 246 ObjectListBase::base_list list; 247 objectList->getBaseObjectList(&list); 248 ObjectListBase::base_iterator it; 248 249 249 250 // No Description given (only for speedup) 250 251 if (objectDescriptor.empty()) 251 252 { 252 for ( bo = objectList->begin(); bo != objectList->end(); bo++)253 boList->push_back(* bo);253 for (it = list.begin(); it != list.end(); it++) 254 boList->push_back(*it); 254 255 } 255 256 // some description 256 257 else 257 258 { 258 for ( bo = objectList->begin(); bo != objectList->end(); bo++)259 if (!nocaseCmp(objectDescriptor, (* bo)->getName(), objectDescriptor.size()))260 boList->push_back(* bo);259 for (it = list.begin(); it != list.end(); it++) 260 if (!nocaseCmp(objectDescriptor, (*it)->getName(), objectDescriptor.size())) 261 boList->push_back(*it); 261 262 } 262 263 } … … 299 300 if (sc != NULL) 300 301 { 301 for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo) 302 { 303 PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName()); 304 (*sc->executor)((*bo), inputSplits.subSet(paramBegin)); 305 } 302 303 if(sc->executor->getType() == Executor<const SubString>::FunctionStatic ) 304 { 305 PRINT(0)("Static Command '%s' of Class '%s' with parameters\n", sc->getCName(), sc->shellClass->getCName()); 306 (*sc->executor)(NULL, inputSplits.subSet(paramBegin)); 307 } 308 else 309 for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo) 310 { 311 PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName()); 312 (*sc->executor)((*bo), inputSplits.subSet(paramBegin)); 313 } 306 314 return true; 307 315 } … … 376 384 else 377 385 { 378 // if(this->completors[parameter] == NULL)379 // delete this->completors[parameter];380 // this->completors[parameter] = completorPlugin.clone();386 // if(this->completors[parameter] == NULL) 387 // delete this->completors[parameter]; 388 // this->completors[parameter] = completorPlugin.clone(); 381 389 } 382 390 return this;
Note: See TracChangeset
for help on using the changeset viewer.