- Timestamp:
- Apr 27, 2006, 9:09:55 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7407 r7408 51 51 52 52 // this->classID = classID; 53 this->shellClass = ShellCommandClass:: getCommandClass(className);53 this->shellClass = ShellCommandClass::acquireCommandClass(className); 54 54 assert (this->shellClass != NULL); 55 55 this->shellClass->registerCommand(this); … … 92 92 { 93 93 94 ShellCommandClass* cmdClass = ShellCommandClass:: getCommandClass(className);94 ShellCommandClass* cmdClass = ShellCommandClass::acquireCommandClass(className); 95 95 if (cmdClass != NULL) 96 96 { … … 100 100 delete (*cmd); 101 101 } 102 } 103 104 105 /** 106 * @brief gets a command if it has already been registered. 107 * @param commandName the name of the Command 108 * @param className the name of the Class the command should apply to. 109 * @returns The Registered Command, or NULL if it does not exist. 110 */ 111 const ShellCommand* const ShellCommand::getCommand(const std::string& commandName, const std::string& className) 112 { 113 const ShellCommandClass* checkClass = ShellCommandClass::getCommandClass(className); 114 if (likely(checkClass != NULL)) 115 { 116 std::vector<ShellCommand*>::const_iterator elem; 117 for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++) 118 { 119 if (commandName == (*elem)->getName()) 120 { 121 PRINTF(2)("Command '%s::%s' already registered\n", className.c_str(), commandName.c_str()); 122 return (*elem); 123 } 124 } 125 return NULL; 126 } 127 else 128 return NULL; 102 129 } 103 130 … … 113 140 bool ShellCommand::exists(const std::string& commandName, const std::string& className) 114 141 { 115 const ShellCommandClass* checkClass = ShellCommandClass::exists(className); 116 if (likely(checkClass != NULL)) 117 { 118 std::vector<ShellCommand*>::const_iterator elem; 119 for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++) 120 { 121 if (commandName == (*elem)->getName()) 122 { 123 PRINTF(2)("Command '%s::%s' already registered\n", className.c_str(), commandName.c_str()); 124 return true; 125 } 126 } 127 return false; 128 } 129 else 130 return false; 142 return (ShellCommand::getCommand(commandName, className) != NULL); 131 143 } 132 144 -
trunk/src/lib/shell/shell_command.h
r7407 r7408 72 72 static ShellCommand* registerCommand(const std::string& commandName, const std::string& className, const Executor& executor); 73 73 static void unregisterCommand(const std::string& commandName, const std::string& className); 74 static const ShellCommand* const getCommand(const std::string& commandName, const std::string& className); 74 75 static bool exists(const std::string& commandName, const std::string& className); 75 76 -
trunk/src/lib/shell/shell_command_class.cc
r7407 r7408 110 110 * @returns the CommandClass if found, NULL otherwise 111 111 */ 112 const ShellCommandClass* ShellCommandClass:: exists(const std::string& className)112 const ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 113 113 { 114 114 std::vector<ShellCommandClass*>::const_iterator classIT; … … 127 127 128 128 /** 129 * @brief checks if a Class is already registered to the Commands' class-stack 130 * @param className the Name of the Class to check for 131 * @returns the CommandClass if found, NULL otherwise 132 */ 133 /* bool ShellCommandClass::exists(const std::string& className) 134 { 135 136 }*/ 137 138 /** 129 139 * @brief searches for a CommandClass 130 140 * @param className the name of the CommandClass 131 141 * @returns the CommandClass if found, or a new CommandClass if not 132 142 */ 133 ShellCommandClass* ShellCommandClass:: getCommandClass(const std::string& className)143 ShellCommandClass* ShellCommandClass::acquireCommandClass(const std::string& className) 134 144 { 135 145 std::vector<ShellCommandClass*>::iterator classIT; -
trunk/src/lib/shell/shell_command_class.h
r7403 r7408 28 28 static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); 29 29 30 static ShellCommandClass* getCommandClass(const std::string& className);31 30 static void unregisterAllCommands(); 32 static const ShellCommandClass* exists(const std::string& className); 31 static const ShellCommandClass* getCommandClass(const std::string& className); 32 static bool exists(const std::string& className); 33 33 34 34 static void help (const std::string& className); … … 36 36 private: 37 37 ShellCommandClass(const std::string& className); 38 static ShellCommandClass* acquireCommandClass(const std::string& className); 38 39 virtual ~ShellCommandClass(); 39 40 -
trunk/src/lib/shell/shell_completion.cc
r7406 r7408 56 56 long completeType = NullCompletion; //< the Type we'd like to complete. 57 57 std::string completeString = ""; //< the string to complete. 58 unsigned int parameterBegin = 0; //< The SubString-entry, the Parameters begin. 58 59 59 60 … … 96 97 completeType |= FunctionCompletion; 97 98 } 99 100 // Looking for ParameterCompletions. 98 101 99 102 if (completeType & ClassCompletion) … … 105 108 if (completeType & AliasCompletion) 106 109 this->aliasComplete(completeString); 110 111 if (completeType == NullCompletion) 112 { 113 printf("Completing a Parameter\n"); 114 // ShellCommand:: 115 } 107 116 108 117
Note: See TracChangeset
for help on using the changeset viewer.