Changeset 7388 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Apr 26, 2006, 11:19:29 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7374 r7388 24 24 25 25 #include "key_names.h" 26 #include <stdarg.h>27 #include <stdio.h>28 #include <string.h>29 26 30 27 namespace OrxShell … … 44 41 this->executor = executor.clone(); 45 42 this->executor->setName(commandName); 43 this->alias = NULL; 46 44 47 45 // this->classID = classID; 48 this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID);46 this->shellClass = ShellCommandClass::getCommandClass(className); 49 47 if (this->shellClass != NULL) 50 48 this->shellClass->commandList.push_back(this); … … 130 128 if (checkClass != NULL) 131 129 { 132 std:: list<ShellCommand*>::const_iterator elem;130 std::vector<ShellCommand*>::const_iterator elem; 133 131 for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++) 134 132 { … … 237 235 if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.size() >= 3))) 238 236 { 239 std:: list<ShellCommand*>::iterator cmdIT;237 std::vector<ShellCommand*>::iterator cmdIT; 240 238 for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++) 241 239 { … … 334 332 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 335 333 336 std:: list<ShellCommand*>::iterator cmdIT;334 std::vector<ShellCommand*>::iterator cmdIT; 337 335 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 338 336 { -
trunk/src/lib/shell/shell_command.h
r7386 r7388 88 88 ShellCommandAlias* alias; //!< An Alias for the Class. 89 89 90 std::string description; //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");90 std::string description; //!< A description for this commnand. (initially ""). Assigned with (create)->describe("blablabla"); 91 91 Executor* executor; //!< The Executor, that really executes the Function. 92 93 92 }; 94 93 -
trunk/src/lib/shell/shell_command_class.cc
r7386 r7388 24 24 #include "compiler.h" 25 25 26 #include <stdio.h>27 #include <string.h>28 29 26 namespace OrxShell 30 27 { … … 53 50 ShellCommandClass::~ShellCommandClass() 54 51 { 55 while( this->commandList.size() > 0)56 { 57 delete this->commandList. front();58 this->commandList.pop_ front();52 while(!this->commandList.empty()) 53 { 54 delete this->commandList.back(); 55 this->commandList.pop_back(); 59 56 } 60 57 } … … 73 70 if (className == (*elem)->getName()) 74 71 { 75 std:: list<ShellCommand*>::iterator command;72 std::vector<ShellCommand*>::iterator command; 76 73 for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++) 77 74 stringList.push_back((*command)->getName()); … … 194 191 { 195 192 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 196 std:: list<ShellCommand*>::const_iterator cmdIT;193 std::vector<ShellCommand*>::const_iterator cmdIT; 197 194 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 198 195 { … … 216 213 } 217 214 215 void ShellCommandClass::registerCommand(ShellCommand* command) 216 { 217 this->commandList.push_back(command); 218 } 219 220 221 void ShellCommandClass::unregisterCommand(ShellCommand* command) 222 { 223 std::vector<ShellCommand*>::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command); 224 this->commandList.erase(delC); 225 } 226 227 228 218 229 } 230 231 232 233 -
trunk/src/lib/shell/shell_command_class.h
r7386 r7388 8 8 9 9 #include "base_object.h" 10 #include < list>10 #include <vector> 11 11 12 12 … … 41 41 static void initCommandClassList(); 42 42 43 void registerCommand(ShellCommand* command); 44 void unregisterCommand(ShellCommand* command); 45 43 46 private: 44 47 const std::string className; //!< The Name of the Class. This should match the ClassName of the Commands Class. 45 48 long classID; //!< The classID of this Class 46 std:: list<ShellCommand*>commandList; //!< A list of Commands from this Class49 std::vector<ShellCommand*> commandList; //!< A list of Commands from this Class 47 50 static std::list<ShellCommandClass*>* commandClassList; //!< A list of Classes 48 static std::list<ShellCommandAlias*>* aliasList; //!< A n Alias to A Command. (only for classes with one Instance)51 static std::list<ShellCommandAlias*>* aliasList; //!< A list of Aliases to A Commands. 49 52 }; 50 53 -
trunk/src/lib/shell/shell_completion.cc
r7386 r7388 18 18 #include "shell_completion.h" 19 19 #include "shell_command_class.h" 20 #include "shell_completion_plugin.h" 20 21 21 22 #include "shell_command.h" … … 50 51 bool ShellCompletion::autoComplete(std::string& input) 51 52 { 52 const char* completionLine; //< the inputLine we complete. 53 54 long classID; //< the classID retrieved from the Class. 53 long classID; //< the classID retrieved from the Class. 55 54 const std::list<BaseObject*>* objectList; //< the list of Objects stored in classID 56 bool emptyComplete = false; //< if the completion input is empty string. e.g ""57 long completeType = NullCompletion; //< the Type we'd like to complete.58 std::string completeString; //< the string to complete.55 bool emptyComplete = false; //< if the completion input is empty string. e.g "" 56 long completeType = NullCompletion; //< the Type we'd like to complete. 57 std::string completeString; //< the string to complete. 59 58 60 59 … … 119 118 120 119 this->generalComplete(input, completeString); 121 return true;122 }123 124 /**125 * @brief autocompletes a className126 * @param classBegin the Beginning of a String to autoComplete127 * @return true on success, false otherwise128 */129 bool ShellCompletion::classComplete(const std::string& classBegin)130 {131 const std::list<std::string>* clList = ClassList::getClassNames();132 if (clList != NULL)133 {134 if (!this->addToCompleteList(*clList, classBegin, ClassCompletion))135 return false;136 }137 else138 return false;139 120 return true; 140 121 } -
trunk/src/lib/shell/shell_completion.h
r7374 r7388 45 45 // Functions to produce the Complete Lists. 46 46 bool autoComplete(std::string& input); 47 bool classComplete(const std::string& classBegin);48 47 // long classMatch(const char* input, unsigned int* length); 49 48 bool objectComplete(const std::string& objectBegin, long classID); … … 60 59 bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); 61 60 bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); 61 62 62 void clearCompletionList(); 63 64 63 65 64 // Helpers. -
trunk/src/lib/shell/shell_completion_plugin.cc
r7387 r7388 27 27 namespace OrxShell 28 28 { 29 30 31 29 void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 32 30 {
Note: See TracChangeset
for help on using the changeset viewer.