Changeset 7408 in orxonox.OLD for trunk/src/lib/shell/shell_command.cc
- Timestamp:
- Apr 27, 2006, 9:09:55 PM (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.