Changeset 9697 in orxonox.OLD for branches/new_class_id/src/lib/shell/shell_command_class.cc
- Timestamp:
- Aug 25, 2006, 12:03:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/shell/shell_command_class.cc
r9692 r9697 29 29 NewObjectListDefinition(ShellCommandClass); 30 30 31 CmdClassList* ShellCommandClass:: commandClassList = NULL;31 CmdClassList* ShellCommandClass::_commandClassList = NULL; 32 32 33 33 /** … … 41 41 this->setName(className); 42 42 43 this->classID = CL_NULL; 44 45 if (ShellCommandClass::commandClassList == NULL) 46 ShellCommandClass::commandClassList = new CmdClassList; 47 ShellCommandClass::commandClassList->push_back(this); 43 if (ShellCommandClass::_commandClassList == NULL) 44 ShellCommandClass::_commandClassList = new CmdClassList; 45 ShellCommandClass::_commandClassList->push_back(this); 48 46 } 49 47 … … 53 51 ShellCommandClass::~ShellCommandClass() 54 52 { 55 while(!this-> commandList.empty())56 delete this-> commandList.back();57 58 if (ShellCommandClass:: commandClassList != NULL)59 { 60 CmdClassList::iterator delClass = std::find(ShellCommandClass:: commandClassList->begin(), ShellCommandClass::commandClassList->end(), this);61 if (delClass != ShellCommandClass:: commandClassList->end())62 ShellCommandClass:: commandClassList->erase(delClass);53 while(!this->_commandList.empty()) 54 delete this->_commandList.back(); 55 56 if (ShellCommandClass::_commandClassList != NULL) 57 { 58 CmdClassList::iterator delClass = std::find(ShellCommandClass::_commandClassList->begin(), ShellCommandClass::_commandClassList->end(), this); 59 if (delClass != ShellCommandClass::_commandClassList->end()) 60 ShellCommandClass::_commandClassList->erase(delClass); 63 61 } 64 62 } … … 69 67 void ShellCommandClass::registerCommand(ShellCommand* command) 70 68 { 71 this-> commandList.push_back(command);69 this->_commandList.push_back(command); 72 70 } 73 71 … … 78 76 void ShellCommandClass::unregisterCommand(ShellCommand* command) 79 77 { 80 CmdList::iterator delC = std::find(this-> commandList.begin(), this->commandList.end(), command);81 if (delC != this-> commandList.end())82 this-> commandList.erase(delC);78 CmdList::iterator delC = std::find(this->_commandList.begin(), this->_commandList.end(), command); 79 if (delC != this->_commandList.end()) 80 this->_commandList.erase(delC); 83 81 } 84 82 … … 90 88 // unregister all commands and Classes 91 89 CmdClassList::iterator classIT; 92 if (ShellCommandClass:: commandClassList == NULL)90 if (ShellCommandClass::_commandClassList == NULL) 93 91 return; 94 92 95 while (!ShellCommandClass:: commandClassList->empty())96 delete ShellCommandClass:: commandClassList->back();97 delete ShellCommandClass:: commandClassList;98 ShellCommandClass:: commandClassList = NULL;93 while (!ShellCommandClass::_commandClassList->empty()) 94 delete ShellCommandClass::_commandClassList->back(); 95 delete ShellCommandClass::_commandClassList; 96 ShellCommandClass::_commandClassList = NULL; 99 97 } 100 98 … … 108 106 bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList) 109 107 { 110 if (ShellCommandClass:: commandClassList == NULL)108 if (ShellCommandClass::_commandClassList == NULL) 111 109 return false; 112 110 113 111 114 112 CmdClassList::const_iterator elem; 115 for(elem = ShellCommandClass:: commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++)113 for(elem = ShellCommandClass::_commandClassList->begin(); elem != ShellCommandClass::_commandClassList->end(); elem++) 116 114 { 117 115 if (className == (*elem)->getName()) 118 116 { 119 117 CmdList::iterator command; 120 for(command = (*elem)-> commandList.begin(); command != (*elem)->commandList.end(); command++)118 for(command = (*elem)->_commandList.begin(); command != (*elem)->_commandList.end(); command++) 121 119 stringList.push_back((*command)->getName()); 122 120 return true; … … 134 132 ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 135 133 { 136 if (ShellCommandClass:: commandClassList == NULL)134 if (ShellCommandClass::_commandClassList == NULL) 137 135 return false; 138 136 139 137 140 138 CmdClassList::const_iterator classIT; 141 for (classIT = ShellCommandClass:: commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)142 if (className == (*classIT)-> className)139 for (classIT = ShellCommandClass::_commandClassList->begin(); classIT != ShellCommandClass::_commandClassList->end(); classIT++) 140 if (className == (*classIT)->_className) 143 141 return (*classIT); 144 142 return NULL; … … 153 151 { 154 152 return (ShellCommandClass::getCommandClass(className) != NULL); 155 }156 157 ClassID ShellCommandClass::getClassID()158 {159 if (this->classID == CL_NULL)160 this->classID = ClassList::StringToID(this->className);161 return this->classID;162 153 } 163 154 … … 182 173 void ShellCommandClass::help(const std::string& className) 183 174 { 184 if (ShellCommandClass:: commandClassList == NULL)175 if (ShellCommandClass::_commandClassList == NULL) 185 176 { 186 177 PRINT(0)("No Commands Registered\n"); … … 188 179 } 189 180 if (className.empty()) 190 PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass:: commandClassList->size());181 PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::_commandClassList->size()); 191 182 192 183 193 184 CmdClassList::iterator classIT; 194 for (classIT = ShellCommandClass:: commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)195 { 196 if (className.empty() || className == (*classIT)-> className)185 for (classIT = ShellCommandClass::_commandClassList->begin(); classIT != ShellCommandClass::_commandClassList->end(); classIT++) 186 { 187 if (className.empty() || className == (*classIT)->_className) 197 188 { 198 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)-> className.c_str(), (*classIT)->commandList.size());189 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->_className.c_str(), (*classIT)->_commandList.size()); 199 190 CmdList::const_iterator cmdIT; 200 for (cmdIT = (*classIT)-> commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)191 for (cmdIT = (*classIT)->_commandList.begin(); cmdIT != (*classIT)->_commandList.end(); cmdIT++) 201 192 { 202 193 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getCName(), (*cmdIT)->executor->getParamCount());
Note: See TracChangeset
for help on using the changeset viewer.