Changeset 7742 in orxonox.OLD for trunk/src/lib
- Timestamp:
- May 20, 2006, 3:53:37 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text.cc
r7726 r7742 36 36 this->font = NULL; 37 37 this->size = textSize; 38 this->blending = TEXT_DEFAULT_BLENDING; 39 this->color = TEXT_DEFAULT_COLOR; 38 40 39 41 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 40 42 41 this->blending = TEXT_DEFAULT_BLENDING;42 this->color = TEXT_DEFAULT_COLOR;43 43 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 44 this->setSize(TEXT_DEFAULT_SIZE);45 44 } 46 45 -
trunk/src/lib/shell/shell.cc
r7738 r7742 248 248 void Shell::applyTextSettings(Text* text) 249 249 { 250 text->setSize(this->textSize); 250 251 text->setFont(this->fontFile, this->textSize); 251 text->setSize(this->textSize);252 252 text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 253 253 text->setBlending(this->textColor[3]); -
trunk/src/lib/shell/shell_command.cc
r7722 r7742 27 27 namespace OrxShell 28 28 { 29 SHELL_COMMAND _STATIC(debug, ShellCommand, ShellCommand::debug);29 SHELL_COMMAND(debug, ShellCommandClass, help); 30 30 31 31 … … 98 98 if (cmdClass != NULL) 99 99 { 100 std::vector<ShellCommand*>::iterator cmd;101 for (cmd = cmdClass->commandList.begin(); cmd <cmdClass->commandList.end(); cmd++)100 CmdList::iterator cmd; 101 for (cmd = cmdClass->commandList.begin(); cmd != cmdClass->commandList.end(); cmd++) 102 102 if (commandName == (*cmd)->getName()) 103 103 { … … 118 118 assert(cmdClass != NULL); 119 119 120 std::vector<ShellCommand*>::const_iterator elem;120 CmdList::const_iterator elem; 121 121 for (elem = cmdClass->commandList.begin(); elem != cmdClass->commandList.end(); elem++) 122 122 if (commandName == (*elem)->getName()) … … 379 379 } 380 380 381 382 /** 383 * @brief prints out nice information about the Shells Commands 384 */ 385 void ShellCommand::debug() 386 { 387 std::vector<ShellCommandClass*>::iterator classIT; 388 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 389 { 390 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 391 392 std::vector<ShellCommand*>::iterator cmdIT; 393 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 394 { 395 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount()); 396 /// FIXME 397 /* for (unsigned int i = 0; i< elem->paramCount; i++) 398 printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 399 if (!(*cmdIT)->description.empty()) 400 printf("- %s", (*cmdIT)->description.c_str()); 401 printf("\n"); 402 403 } 404 } 381 /** 382 * @brief prints a Help string from this Command 383 */ 384 void ShellCommand::help() const 385 { 386 PRINT(0)("%s ", this->getName()); 405 387 } 406 388 -
trunk/src/lib/shell/shell_command.h
r7722 r7742 84 84 const CompletorPlugin* const getCompletorPlugin(unsigned int i) const { return this->completors[i]; }; 85 85 86 static void debug();86 void help() const; 87 87 88 88 protected: -
trunk/src/lib/shell/shell_command_class.cc
r7411 r7742 24 24 #include "compiler.h" 25 25 26 27 26 28 namespace OrxShell 27 29 { 28 std::vector<ShellCommandClass*>ShellCommandClass::commandClassList;30 CmdClassList ShellCommandClass::commandClassList; 29 31 30 32 /** … … 40 42 this->classID = CL_NULL; 41 43 44 printf("::: %d\n", commandClassList.size()); 42 45 ShellCommandClass::commandClassList.push_back(this); 46 printf("::: %d\n", commandClassList.size()); 43 47 } 44 48 … … 50 54 while(!this->commandList.empty()) 51 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); 52 59 } 53 60 … … 57 64 void ShellCommandClass::registerCommand(ShellCommand* command) 58 65 { 66 printf("::::::::::: ADDED COMMAND:: '%s'\n", command->getName()); 59 67 this->commandList.push_back(command); 60 } 61 62 /** 63 * @brief unregister command. 68 this->help(); 69 } 70 71 /** 72 * @brief Unregisters a command. 64 73 * @param command the Command to unregister. 65 74 */ 66 75 void ShellCommandClass::unregisterCommand(ShellCommand* command) 67 76 { 68 std::vector<ShellCommand*>::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command);77 CmdList::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command); 69 78 if (delC != this->commandList.end()) 70 79 this->commandList.erase(delC); … … 77 86 { 78 87 // unregister all commands and Classes 79 std::vector<ShellCommandClass*>::iterator classIT; 80 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 81 delete (*classIT); 88 CmdClassList::iterator classIT; 89 90 while (!ShellCommandClass::commandClassList.empty()) 91 delete ShellCommandClass::commandClassList.back(); 82 92 } 83 93 … … 91 101 bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList) 92 102 { 93 std::vector<ShellCommandClass*>::iterator elem;103 CmdClassList::const_iterator elem; 94 104 for(elem = ShellCommandClass::commandClassList.begin(); elem != ShellCommandClass::commandClassList.end(); elem++) 95 105 { 96 106 if (className == (*elem)->getName()) 97 107 { 98 std::vector<ShellCommand*>::iterator command;108 CmdList::iterator command; 99 109 for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++) 100 110 stringList.push_back((*command)->getName()); 111 return true; 101 112 } 102 113 } 103 return true;114 return false; 104 115 } 105 116 … … 110 121 * @returns the CommandClass if found, NULL otherwise 111 122 */ 112 constShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)113 { 114 std::vector<ShellCommandClass*>::const_iterator classIT;123 ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 124 { 125 CmdClassList::const_iterator classIT; 115 126 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 116 127 if (className == (*classIT)->className) … … 144 155 ShellCommandClass* ShellCommandClass::acquireCommandClass(const std::string& className) 145 156 { 146 std::vector<ShellCommandClass*>::iterator classIT; 147 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 148 if (className == (*classIT)->className) 149 return (*classIT); 157 ShellCommandClass* cmdClass = ShellCommandClass::getCommandClass(className); 158 if (cmdClass != NULL) 159 return (cmdClass); 150 160 return new ShellCommandClass(className); 151 161 } … … 157 167 void ShellCommandClass::help(const std::string& className) 158 168 { 159 std::vector<ShellCommandClass*>::iterator classIT; 169 if (className.empty()) 170 PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList.size()); 171 172 173 CmdClassList::iterator classIT; 160 174 for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++) 161 175 { 162 if (className == (*classIT)->className)176 if (className.empty() || className == (*classIT)->className) 163 177 { 164 178 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 165 std::vector<ShellCommand*>::const_iterator cmdIT;179 CmdList::const_iterator cmdIT; 166 180 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 167 181 { … … 174 188 PRINT(0)("\n"); 175 189 } 176 return; 190 if (likely(!className.empty())) 191 return; 177 192 } 178 193 } 179 PRINTF(3)("Class %s not found in Command's classes\n", className.c_str()); 180 } 181 194 PRINTF(3)("Class '%s' not found in Command's classes\n", className.c_str()); 195 } 182 196 } 183 197 -
trunk/src/lib/shell/shell_command_class.h
r7411 r7742 10 10 #include <vector> 11 11 12 13 12 namespace OrxShell 14 13 { … … 16 15 class ShellCommand; 17 16 class ShellCommandAlias; 17 class ShellCommandClass; 18 19 typedef std::vector<ShellCommand*> CmdList; 20 typedef std::vector<ShellCommandClass*> CmdClassList; 21 18 22 19 23 //! A class to hold all Classes that have (once) registered Commands. … … 21 25 { 22 26 friend class ShellCommand; 23 24 27 public: 25 28 /** @returns the CommandClassList */ 26 static const std::vector<ShellCommandClass*>& getCommandClassList() { return ShellCommandClass::commandClassList; };29 static const CmdClassList& getCommandClassList() { return ShellCommandClass::commandClassList; }; 27 30 28 31 static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); 29 32 30 33 static void unregisterAllCommands(); 31 static constShellCommandClass* getCommandClass(const std::string& className);34 static ShellCommandClass* getCommandClass(const std::string& className); 32 35 ClassID getClassID(); 33 36 static bool exists(const std::string& className); 34 37 35 static void help (const std::string& className); 38 static void help (const std::string& className = ""); 39 40 static void debug(); 36 41 37 42 private: … … 47 52 const std::string className; //!< The Name of the Class. This should match the ClassName of the Commands Class. 48 53 ClassID classID; //!< The classID of this Class 49 std::vector<ShellCommand*>commandList; //!< A list of Commands from this Class54 CmdList commandList; //!< A list of Commands from this Class 50 55 51 static std::vector<ShellCommandClass*>commandClassList; //!< A list of Classes56 static CmdClassList commandClassList; //!< A list of Classes 52 57 }; 53 58 -
trunk/src/lib/util/executor/executor.cc
r7721 r7742 106 106 107 107 /** 108 * prints out nice information about the Executor108 * @brief prints out nice information about the Executor 109 109 */ 110 110 void Executor::debug() 111 111 { 112 /* tIterator<ExecutorClass>* iteratorCL = ExecutorClass::commandClassList->getIterator();113 ExecutorClass* elemCL = iteratorCL->firstElement();114 while(elemCL != NULL)115 {116 PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());117 tIterator<Executor>* iterator = elemCL->commandList->getIterator();118 const Executor* elem = iterator->firstElement();119 while(elem != NULL)120 {121 PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->paramCount);122 for (unsigned int i = 0; i< elem->paramCount; i++)123 printf("%s ", Executor::paramToString(elem->parameters[i]));124 if (elem->description != NULL)125 printf("- %s", elem->description);126 printf("\n");127 112 128 elem = iterator->nextElement();129 }130 delete iterator;131 elemCL = iteratorCL->nextElement();132 }133 delete iteratorCL;*/134 113 }
Note: See TracChangeset
for help on using the changeset viewer.