Changeset 1416 for code/branches/console/src/core
- Timestamp:
- May 25, 2008, 1:11:51 AM (17 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/ArgumentCompletionFunctions.cc
r1402 r1416 35 35 namespace autocompletion 36 36 { 37 const std::list<std::pair<std::string, std::string> >&fallback()37 std::list<std::pair<std::string, std::string> > fallback() 38 38 { 39 std::cout << "5_1\n"; 40 static std::list<std::pair<std::string, std::string> > list; 41 std::cout << "5_2\n"; 39 static std::list<std::pair<std::string, std::string> > list(1, std::pair<std::string, std::string>("muh", "MUH")); 42 40 return list; 43 41 } -
code/branches/console/src/core/ArgumentCompletionFunctions.h
r1390 r1416 37 37 namespace autocompletion 38 38 { 39 const std::list<std::pair<std::string, std::string> >&fallback();39 std::list<std::pair<std::string, std::string> > fallback(); 40 40 } 41 41 } -
code/branches/console/src/core/CommandEvaluation.cc
r1402 r1416 53 53 this->listOfPossibleIdentifiers_.clear(); 54 54 this->listOfPossibleFunctions_.clear(); 55 this->listOfPossibleArguments_.clear(); 55 56 56 57 this->functionclass_ = 0; … … 114 115 std::cout << "complete: function != 0" << std::endl; 115 116 if (this->commandTokens_.size() > 1) 116 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 117 { 118 if ((this->commandTokens_.size() - 1) >= this->function_->getParamCount()) 119 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join()); 120 else 121 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 122 } 117 123 else 118 124 return (this->function_->getName() + " "); … … 125 131 std::cout << "complete: function != 0" << std::endl; 126 132 if (this->commandTokens_.size() > 1) 127 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join());133 return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size()).join()); 128 134 else 129 135 return (this->function_->getName()); … … 144 150 std::cout << "complete: function und functionclass != 0" << std::endl; 145 151 if (this->commandTokens_.size() > 2) 146 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 152 { 153 if ((this->commandTokens_.size() - 2) >= this->function_->getParamCount()) 154 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join()); 155 else 156 return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size()).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_)); 157 } 147 158 else 148 159 return (this->functionclass_->getName() + " " + this->function_->getName() + " "); -
code/branches/console/src/core/CommandExecutor.cc
r1402 r1416 108 108 { 109 109 CommandExecutor::parseIfNeeded(command); 110 111 if (!CommandExecutor::getEvaluation().isNewCommand()) 112 CommandExecutor::parse(CommandExecutor::getEvaluation().getCommand(), false); 113 else 114 CommandExecutor::getEvaluation().setNewCommand(false); 115 110 116 return CommandExecutor::getEvaluation().complete(); 111 117 } … … 119 125 CommandEvaluation CommandExecutor::evaluate(const std::string& command) 120 126 { 121 CommandExecutor::parse(command , true);127 CommandExecutor::parse(command); 122 128 CommandExecutor::getEvaluation().evaluateParams(); 123 129 return CommandExecutor::getEvaluation(); … … 126 132 void CommandExecutor::parseIfNeeded(const std::string& command) 127 133 { 128 if ((CommandExecutor::getEvaluation().get Command() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized))134 if ((CommandExecutor::getEvaluation().getOriginalCommand() != command) || (CommandExecutor::getEvaluation().getState() == CS_Uninitialized)) 129 135 CommandExecutor::parse(command); 130 else if (!CommandExecutor::getEvaluation().isValid())131 {132 CommandExecutor::getEvaluation().setNewCommand(false);133 CommandExecutor::parse(command, false);134 }135 136 } 136 137 … … 301 302 if (CommandExecutor::getEvaluation().getFunction()) 302 303 { 303 std::cout << "1\n";304 304 unsigned int startindex = 0; 305 305 if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params) … … 307 307 else if (CommandExecutor::getEvaluation().getState() == CS_Function_Params) 308 308 startindex = 2; 309 std::cout << "2\n";310 309 311 310 if (CommandExecutor::argumentsGiven() >= startindex) 312 311 { 313 std::cout << "3\n"; 314 if (CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().getFunction())) 315 { 316 std::cout << "4\n"; 312 if ((CommandExecutor::argumentsGiven() == CommandExecutor::argumentsFinished() || !CommandExecutor::getEvaluation().isNewCommand()) && CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().getFunction())) 313 { 317 314 if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params) 318 315 CommandExecutor::getEvaluation().setState(CS_Shortcut_Finished); … … 324 321 else 325 322 { 326 std::cout << "5\n";327 std::cout << "last argument: " << CommandExecutor::getLastArgument() << std::endl;328 std::cout << "function: " << CommandExecutor::getEvaluation().getFunction() << std::endl;329 std::cout << "functionname: " << CommandExecutor::getEvaluation().getFunction()->getName() << std::endl;330 std::cout << "param nr: " << CommandExecutor::getEvaluation().getTokens().size() - startindex << std::endl;331 323 CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getTokens().size() - startindex); 332 std::cout << "6\n";333 324 unsigned int numArguments = CommandExecutor::getEvaluation().getListOfPossibleArguments().size(); 334 325 335 326 if (numArguments == 1) 336 327 { 337 std::cout << "7\n";338 328 // There is exactly one possible argument 339 329 const std::string* possibleArgument = (*CommandExecutor::getEvaluation().getListOfPossibleArguments().begin()).second; 340 CommandExecutor::parse(CommandExecutor::getEvaluation().getTokens().subSet(0, CommandExecutor::getEvaluation().getTokens().size() - 1 - startindex).join() + " " + (*possibleArgument) + " "); 330 if (CommandExecutor::argumentsGiven() > CommandExecutor::argumentsFinished()) 331 CommandExecutor::parse(CommandExecutor::getEvaluation().getTokens().subSet(0, CommandExecutor::getEvaluation().getTokens().size() - 1).join() + " " + (*possibleArgument) + " ", false); 332 else 333 CommandExecutor::parse(CommandExecutor::getEvaluation().getTokens().subSet(0, CommandExecutor::getEvaluation().getTokens().size()).join() + " " + (*possibleArgument) + " ", false); 334 341 335 return; 342 336 } 343 337 344 std::cout << "8\n";345 338 if ((CommandExecutor::argumentsGiven() > CommandExecutor::argumentsFinished()) && (!CommandExecutor::getEvaluation().isNewCommand())) 346 339 { 347 std::cout << "9\n";348 340 // There is more than one argument, but the user wants to use this - check if there is a perfect match 349 341 const std::string* possibleArgument = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getTokens().size() - startindex); 350 342 if (possibleArgument) 351 343 { 352 std::cout << "10\n";353 344 // There is such an argument - use it 354 345 CommandExecutor::parse(command + " ", false); 355 346 return; 356 347 } 357 std::cout << "11\n";358 348 } 359 std::cout << "12\n"; 360 } 361 std::cout << "13\n"; 349 } 362 350 363 351 // Nothing to do … … 426 414 void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment) 427 415 { 416 CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().clear(); 428 417 std::string lowercase = getLowercase(fragment); 429 418 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it) … … 437 426 void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier) 438 427 { 428 CommandExecutor::getEvaluation().getListOfPossibleFunctions().clear(); 439 429 std::string lowercase = getLowercase(fragment); 440 430 if (!identifier) … … 456 446 void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param) 457 447 { 458 std::cout << "2_1\n";448 CommandExecutor::getEvaluation().getListOfPossibleArguments().clear(); 459 449 std::string lowercase = getLowercase(fragment); 460 std::cout << "2_2\n";461 450 for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it) 462 {463 std::cout << "2_3\n";464 451 if ((*it).first.find(lowercase) == 0 || fragment == "") 465 {466 std::cout << "2_4\n";467 452 CommandExecutor::getEvaluation().getListOfPossibleArguments().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second)); 468 std::cout << "2_5\n"; 469 } 470 } 471 472 std::cout << "2_6\n"; 453 473 454 CommandExecutor::getEvaluation().getListOfPossibleArguments().sort(CommandExecutor::compareStringsInList); 474 std::cout << "2_7\n";475 455 } 476 456 -
code/branches/console/src/core/ConsoleCommand.cc
r1402 r1416 41 41 } 42 42 43 ConsoleCommand& ConsoleCommand::setArgumentCompletionList(unsigned int param, const std::list<std::pair<std::string, std::string> >&(*function) (void))43 ConsoleCommand& ConsoleCommand::setArgumentCompletionList(unsigned int param, std::list<std::pair<std::string, std::string> > (*function) (void)) 44 44 { 45 45 if (param < 5) … … 52 52 } 53 53 54 const std::list<std::pair<std::string, std::string> >& ConsoleCommand::getArgumentCompletionList(unsigned int param) const54 const std::list<std::pair<std::string, std::string> >& ConsoleCommand::getArgumentCompletionList(unsigned int param) 55 55 { 56 56 if (param < 5) 57 return(*this->autocompletionFunction_[param])();57 this->argumentList_ = (*this->autocompletionFunction_[param])(); 58 58 else 59 return autocompletion::fallback(); 59 this->argumentList_ = autocompletion::fallback(); 60 61 return this->argumentList_; 60 62 } 61 63 62 std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListBegin(unsigned int param) const64 std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListBegin(unsigned int param) 63 65 { 64 std::cout << "3_1: param: " << param << "\n";65 66 if (param < 5) 66 { 67 std::cout << "3_2: >" << this->autocompletionFunction_[param] << "<\n"; 68 return (*this->autocompletionFunction_[param])().begin(); 69 } 67 this->argumentList_ = (*this->autocompletionFunction_[param])(); 70 68 else 71 { 72 std::cout << "3_3\n"; 73 return autocompletion::fallback().begin(); 74 } 69 this->argumentList_ = autocompletion::fallback(); 70 71 return this->argumentList_.begin(); 75 72 } 76 73 77 std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListEnd(unsigned int param) const74 std::list<std::pair<std::string, std::string> >::const_iterator ConsoleCommand::getArgumentCompletionListEnd(unsigned int param) 78 75 { 79 std::cout << "4_1: param: " << param << "\n";80 76 if (param < 5) 81 { 82 std::cout << "4_2: >" << this->autocompletionFunction_[param] << "<\n"; 83 return (*this->autocompletionFunction_[param])().end(); 84 } 77 this->argumentList_ = (*this->autocompletionFunction_[param])(); 85 78 else 86 { 87 std::cout << "4_3\n"; 88 return autocompletion::fallback().end(); 89 } 79 this->argumentList_ = autocompletion::fallback(); 80 81 return this->argumentList_.end(); 90 82 } 91 83 } -
code/branches/console/src/core/ConsoleCommand.h
r1390 r1416 42 42 SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut) 43 43 44 #define SetConsoleCommandGeneric(fakevariable, classname, executor, bCreateShortcut) \45 Executor& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ConsoleCommand*)executor, bCreateShortcut)44 #define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \ 45 ConsoleCommand& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ConsoleCommand*)command, bCreateShortcut) 46 46 47 47 … … 52 52 SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function)) 53 53 54 #define SetConsoleCommandShortcutGeneric(fakevariable, executor) \55 Executor& fakevariable = CommandExecutor::addConsoleCommandShortcut((ConsoleCommand*)executor)54 #define SetConsoleCommandShortcutGeneric(fakevariable, command) \ 55 ConsoleCommand& fakevariable = CommandExecutor::addConsoleCommandShortcut((ConsoleCommand*)command) 56 56 57 57 … … 100 100 { return this->accessLevel_; } 101 101 102 ConsoleCommand& setArgumentCompletionList(unsigned int param, const std::list<std::pair<std::string, std::string> >&(*function) (void));102 ConsoleCommand& setArgumentCompletionList(unsigned int param, std::list<std::pair<std::string, std::string> > (*function) (void)); 103 103 104 const std::list<std::pair<std::string, std::string> >& getArgumentCompletionList(unsigned int param) const;105 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListBegin(unsigned int param) const;106 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListEnd(unsigned int param) const;104 const std::list<std::pair<std::string, std::string> >& getArgumentCompletionList(unsigned int param); 105 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListBegin(unsigned int param); 106 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListEnd(unsigned int param); 107 107 108 108 private: 109 109 AccessLevel::Level accessLevel_; 110 const std::list<std::pair<std::string, std::string> >& (*autocompletionFunction_[5]) (void); 110 std::list<std::pair<std::string, std::string> > (*autocompletionFunction_[5]) (void); 111 std::list<std::pair<std::string, std::string> > argumentList_; 111 112 }; 112 113 -
code/branches/console/src/core/Debug.h
r1089 r1416 206 206 COUT ## x 207 207 208 #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE 209 #define COUT0 \ 210 if (getSoftDebugLevel() >= ORX_NONE) \ 211 COUT_EXEC(0) 212 #else 213 #define COUT0 if (ORX_NONE)\ 214 COUT_EXEC(0) 215 #endif 216 208 217 #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR 209 218 #define COUT1 \ … … 256 265 #endif /* if ORX_PRINT_DEBUG_OUTPUT */ 257 266 258 #define COUT0 \259 COUT_EXEC(0)260 267 #endif /* ifndef COUT */ 261 268 … … 274 281 CCOUT ## x 275 282 283 #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE 284 #define CCOUT0 \ 285 if (getSoftDebugLevel() >= ORX_NONE) \ 286 CCOUT_EXEC(0) 287 #else 288 #define CCOUT0 if (ORX_NONE)\ 289 CCOUT_EXEC(0) 290 #endif 291 276 292 #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR 277 293 #define CCOUT1 \ … … 324 340 #endif /* if ORX_PRINT_DEBUG_OUTPUT */ 325 341 326 #define CCOUT0 \327 CCOUT_EXEC(0)328 342 #endif /* ifndef CCOUT */ 329 343 -
code/branches/console/src/core/OutputHandler.cc
r1341 r1416 38 38 namespace orxonox 39 39 { 40 SetConsoleCommandShortcutGeneric(log, create Executor(createFunctor(&OutputHandler::log), "log" ));41 SetConsoleCommandShortcutGeneric(error, create Executor(createFunctor(&OutputHandler::error), "error" ));42 SetConsoleCommandShortcutGeneric(warning, create Executor(createFunctor(&OutputHandler::warning), "warning"));43 SetConsoleCommandShortcutGeneric(info, create Executor(createFunctor(&OutputHandler::info), "info" ));44 SetConsoleCommandShortcutGeneric(debug, create Executor(createFunctor(&OutputHandler::debug), "debug" ));40 SetConsoleCommandShortcutGeneric(log, createConsoleCommand(createFunctor(&OutputHandler::log), "log" )); 41 SetConsoleCommandShortcutGeneric(error, createConsoleCommand(createFunctor(&OutputHandler::error), "error" )); 42 SetConsoleCommandShortcutGeneric(warning, createConsoleCommand(createFunctor(&OutputHandler::warning), "warning")); 43 SetConsoleCommandShortcutGeneric(info, createConsoleCommand(createFunctor(&OutputHandler::info), "info" )); 44 SetConsoleCommandShortcutGeneric(debug, createConsoleCommand(createFunctor(&OutputHandler::debug), "debug" )); 45 45 46 46 /** -
code/branches/console/src/core/TclBind.cc
r1341 r1416 39 39 namespace orxonox 40 40 { 41 SetConsoleCommandShortcutGeneric(tcl, create Executor(createFunctor(&TclBind::tcl), "tcl"));42 SetConsoleCommandShortcutGeneric(bgerror, create Executor(createFunctor(&TclBind::bgerror), "bgerror"));41 SetConsoleCommandShortcutGeneric(tcl, createConsoleCommand(createFunctor(&TclBind::tcl), "tcl")); 42 SetConsoleCommandShortcutGeneric(bgerror, createConsoleCommand(createFunctor(&TclBind::bgerror), "bgerror")); 43 43 44 44 TclBind::TclBind() -
code/branches/console/src/core/TclThreadManager.cc
r1341 r1416 48 48 namespace orxonox 49 49 { 50 SetConsoleCommandShortcutGeneric(tclexecute, create Executor(createFunctor(&TclThreadManager::execute), "tclexecute"));51 SetConsoleCommandShortcutGeneric(tclquery, create Executor(createFunctor(&TclThreadManager::query), "tclquery" ));50 SetConsoleCommandShortcutGeneric(tclexecute, createConsoleCommand(createFunctor(&TclThreadManager::execute), "tclexecute")); 51 SetConsoleCommandShortcutGeneric(tclquery, createConsoleCommand(createFunctor(&TclThreadManager::query), "tclquery" )); 52 52 SetConsoleCommand(TclThreadManager, create, false); 53 53 SetConsoleCommand(TclThreadManager, destroy, false);
Note: See TracChangeset
for help on using the changeset viewer.