- Timestamp:
- May 20, 2006, 4:03:16 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command_class.cc
r7742 r7743 28 28 namespace OrxShell 29 29 { 30 CmdClassList ShellCommandClass::commandClassList;30 CmdClassList* ShellCommandClass::commandClassList = NULL; 31 31 32 32 /** … … 42 42 this->classID = CL_NULL; 43 43 44 printf("::: %d\n", commandClassList.size());45 ShellCommandClass::commandClassList.push_back(this);46 printf("::: %d\n", commandClassList.size());44 if (ShellCommandClass::commandClassList == NULL) 45 ShellCommandClass::commandClassList = new CmdClassList; 46 ShellCommandClass::commandClassList->push_back(this); 47 47 } 48 48 … … 54 54 while(!this->commandList.empty()) 55 55 delete this->commandList.back(); 56 CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList.begin(), ShellCommandClass::commandClassList.end(), this); 57 if (delClass != ShellCommandClass::commandClassList.end()) 58 ShellCommandClass::commandClassList.erase(delClass); 56 57 if (ShellCommandClass::commandClassList != NULL) 58 { 59 CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList->begin(), ShellCommandClass::commandClassList->end(), this); 60 if (delClass != ShellCommandClass::commandClassList->end()) 61 ShellCommandClass::commandClassList->erase(delClass); 62 } 59 63 } 60 64 … … 64 68 void ShellCommandClass::registerCommand(ShellCommand* command) 65 69 { 66 printf("::::::::::: ADDED COMMAND:: '%s'\n", command->getName());67 70 this->commandList.push_back(command); 68 this->help();69 71 } 70 72 … … 87 89 // unregister all commands and Classes 88 90 CmdClassList::iterator classIT; 89 90 while (!ShellCommandClass::commandClassList.empty()) 91 delete ShellCommandClass::commandClassList.back(); 91 if (ShellCommandClass::commandClassList == NULL) 92 return; 93 94 while (!ShellCommandClass::commandClassList->empty()) 95 delete ShellCommandClass::commandClassList->back(); 96 delete ShellCommandClass::commandClassList; 97 ShellCommandClass::commandClassList = NULL; 92 98 } 93 99 … … 101 107 bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList) 102 108 { 109 if (ShellCommandClass::commandClassList == NULL) 110 return false; 111 112 103 113 CmdClassList::const_iterator elem; 104 for(elem = ShellCommandClass::commandClassList .begin(); elem != ShellCommandClass::commandClassList.end(); elem++)114 for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++) 105 115 { 106 116 if (className == (*elem)->getName()) … … 123 133 ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 124 134 { 135 if (ShellCommandClass::commandClassList == NULL) 136 return false; 137 138 125 139 CmdClassList::const_iterator classIT; 126 for (classIT = ShellCommandClass::commandClassList .begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)140 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 127 141 if (className == (*classIT)->className) 128 142 return (*classIT); … … 167 181 void ShellCommandClass::help(const std::string& className) 168 182 { 183 if (ShellCommandClass::commandClassList == NULL) 184 { 185 PRINT(0)("No Commands Registered\n"); 186 return; 187 } 169 188 if (className.empty()) 170 PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList .size());189 PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList->size()); 171 190 172 191 173 192 CmdClassList::iterator classIT; 174 for (classIT = ShellCommandClass::commandClassList .begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)193 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 175 194 { 176 195 if (className.empty() || className == (*classIT)->className) -
trunk/src/lib/shell/shell_command_class.h
r7742 r7743 27 27 public: 28 28 /** @returns the CommandClassList */ 29 static const CmdClassList& getCommandClassList() { return ShellCommandClass::commandClassList; };29 static const CmdClassList& getCommandClassList() { return *ShellCommandClass::commandClassList; }; 30 30 31 31 static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); … … 54 54 CmdList commandList; //!< A list of Commands from this Class 55 55 56 static CmdClassList 56 static CmdClassList* commandClassList; //!< A list of Classes 57 57 }; 58 59 58 } 60 59
Note: See TracChangeset
for help on using the changeset viewer.