Changeset 7394 in orxonox.OLD for trunk/src/lib/shell/shell_command_class.cc
- Timestamp:
- Apr 27, 2006, 1:33:23 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command_class.cc
r7390 r7394 26 26 namespace OrxShell 27 27 { 28 std:: list<ShellCommandClass*>* ShellCommandClass::commandClassList = NULL;28 std::vector<ShellCommandClass*> ShellCommandClass::commandClassList; 29 29 30 30 /** … … 40 40 this->classID = CL_NULL; 41 41 42 ShellCommandClass::commandClassList ->push_back(this);42 ShellCommandClass::commandClassList.push_back(this); 43 43 } 44 44 … … 79 79 void ShellCommandClass::unregisterAllCommands() 80 80 { 81 if (ShellCommandClass::commandClassList != NULL) 82 { 83 // unregister all commands and Classes 84 std::list<ShellCommandClass*>::iterator classIT; 85 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 86 delete (*classIT); 87 delete ShellCommandClass::commandClassList; 88 ShellCommandClass::commandClassList = NULL; 89 } 90 81 // unregister all commands and Classes 82 std::vector<ShellCommandClass*>::iterator classIT; 83 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 84 delete (*classIT); 91 85 } 92 86 … … 100 94 bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList) 101 95 { 102 std:: list<ShellCommandClass*>::iterator elem;103 for(elem = ShellCommandClass::commandClassList ->begin(); elem != ShellCommandClass::commandClassList->end(); elem++)96 std::vector<ShellCommandClass*>::iterator elem; 97 for(elem = ShellCommandClass::commandClassList.begin(); elem != ShellCommandClass::commandClassList.end(); elem++) 104 98 { 105 99 if (className == (*elem)->getName()) … … 121 115 const ShellCommandClass* ShellCommandClass::isRegistered(const std::string& className) 122 116 { 123 if (ShellCommandClass::commandClassList == NULL) 124 initCommandClassList(); 125 126 std::list<ShellCommandClass*>::const_iterator classIT; 127 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 117 std::vector<ShellCommandClass*>::const_iterator classIT; 118 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 128 119 { 129 120 if (className == (*classIT)->className) … … 145 136 ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 146 137 { 147 if (ShellCommandClass::commandClassList == NULL) 148 initCommandClassList(); 149 150 std::list<ShellCommandClass*>::iterator classIT; 151 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 152 { 138 std::vector<ShellCommandClass*>::iterator classIT; 139 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 153 140 if (className == (*classIT)->className) 154 {155 141 return (*classIT); 156 }157 }158 142 return new ShellCommandClass(className); 159 }160 161 /**162 * @brief initializes the CommandList (if it is NULL)163 */164 void ShellCommandClass::initCommandClassList()165 {166 if (ShellCommandClass::commandClassList == NULL)167 {168 ShellCommandClass::commandClassList = new std::list<ShellCommandClass*>;169 ShellCommand::registerCommand("debug", "ShellCommand", ExecutorStatic<ShellCommand>(ShellCommand::debug));170 }171 143 } 172 144 … … 177 149 void ShellCommandClass::help(const std::string& className) 178 150 { 179 if (likely(ShellCommandClass::commandClassList != NULL)) 151 std::vector<ShellCommandClass*>::iterator classIT; 152 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 180 153 { 181 std::list<ShellCommandClass*>::iterator classIT; 182 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 154 if (className == (*classIT)->className) 183 155 { 184 if (className == (*classIT)->className) 156 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 157 std::vector<ShellCommand*>::const_iterator cmdIT; 158 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 185 159 { 186 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 187 std::vector<ShellCommand*>::const_iterator cmdIT; 188 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 189 { 190 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount()); 191 /// FIXME 192 /* for (unsigned int i = 0; i< elem->paramCount; i++) 193 PRINT(0)("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 194 if (!(*cmdIT)->description.empty()) 195 PRINT(0)("- %s", (*cmdIT)->description.c_str()); 196 PRINT(0)("\n"); 197 } 198 return; 160 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount()); 161 /// FIXME 162 /* for (unsigned int i = 0; i< elem->paramCount; i++) 163 PRINT(0)("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 164 if (!(*cmdIT)->description.empty()) 165 PRINT(0)("- %s", (*cmdIT)->description.c_str()); 166 PRINT(0)("\n"); 199 167 } 168 return; 200 169 } 201 PRINTF(3)("Class %s not found in Command's classes\n", className.c_str());202 170 } 203 else 204 { 205 PRINTF(1)("List of commandClasses does not exist"); 206 } 171 PRINTF(3)("Class %s not found in Command's classes\n", className.c_str()); 207 172 } 208 173
Note: See TracChangeset
for help on using the changeset viewer.