Changeset 1341 for code/branches/console
- Timestamp:
- May 21, 2008, 1:33:42 AM (17 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 4 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CMakeLists.txt
r1313 r1341 17 17 OutputBuffer.cc 18 18 InputBuffer.cc 19 Shell.cc 19 20 CommandExecutor.cc 20 Shell.cc 21 CommandEvaluation.cc 22 ConsoleCommandCompilation.cc 21 23 Language.cc 22 24 ClassTreeMask.cc -
code/branches/console/src/core/CommandExecutor.cc
r1276 r1341 44 44 namespace orxonox 45 45 { 46 ConsoleCommandShortcutGeneric(keyword1, createExecutor((FunctorStatic*)0, "set", AccessLevel::User)); 47 ConsoleCommandShortcutGeneric(keyword2, createExecutor((FunctorStatic*)0, "tset", AccessLevel::User)); 48 ConsoleCommandShortcutGeneric(keyword3, createExecutor((FunctorStatic*)0, "bind", AccessLevel::User)); 49 50 ConsoleCommandShortcutExtern(source, AccessLevel::None); 51 ConsoleCommandShortcutExtern(echo, AccessLevel::None); 52 ConsoleCommandShortcutExtern(puts, AccessLevel::None); 53 54 ConsoleCommandShortcutExtern(read, AccessLevel::None); 55 ConsoleCommandShortcutExtern(append, AccessLevel::None); 56 ConsoleCommandShortcutExtern(write, AccessLevel::None); 57 58 void source(const std::string& filename) 59 { 60 static std::set<std::string> executingFiles; 61 62 std::set<std::string>::const_iterator it = executingFiles.find(filename); 63 if (it != executingFiles.end()) 64 { 65 COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl; 66 return; 67 } 68 69 // Open the file 70 std::ifstream file; 71 file.open(filename.c_str(), std::fstream::in); 72 73 if (!file.is_open()) 74 { 75 COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl; 76 return; 77 } 78 79 executingFiles.insert(filename); 80 81 // Iterate through the file and put the lines into the CommandExecutor 82 char line[1024]; 83 while (file.good() && !file.eof()) 84 { 85 file.getline(line, 1024); 86 CommandExecutor::execute(line); 87 } 88 89 executingFiles.erase(filename); 90 file.close(); 91 } 92 93 std::string echo(const std::string& text) 94 { 95 std::cout << text << std::endl; 96 return text; 97 } 98 99 void puts(bool newline, const std::string& text) 100 { 101 if (newline) 102 COUT(0) << text << std::endl; 103 else 104 COUT(0) << text; 105 } 106 107 void write(const std::string& filename, const std::string& text) 108 { 109 std::ofstream file; 110 file.open(filename.c_str(), std::fstream::out); 111 112 if (!file.is_open()) 113 { 114 COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl; 115 return; 116 } 117 118 file << text << std::endl; 119 file.close(); 120 } 121 122 void append(const std::string& filename, const std::string& text) 123 { 124 std::ofstream file; 125 file.open(filename.c_str(), std::fstream::app); 126 127 if (!file.is_open()) 128 { 129 COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl; 130 return; 131 } 132 133 file << text << std::endl; 134 file.close(); 135 } 136 137 std::string read(const std::string& filename) 138 { 139 std::ifstream file; 140 file.open(filename.c_str(), std::fstream::in); 141 142 if (!file.is_open()) 143 { 144 COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl; 145 return ""; 146 } 147 148 std::string output = ""; 149 char line[1024]; 150 while (file.good() && !file.eof()) 151 { 152 file.getline(line, 1024); 153 output += line; 154 output += "\n"; 155 } 156 157 file.close(); 158 159 return output; 160 } 161 162 163 /////////////////////// 164 // CommandEvaluation // 165 /////////////////////// 166 CommandEvaluation::CommandEvaluation() 167 { 168 this->processedCommand_ = ""; 169 this->additionalParameter_ = ""; 170 171 this->functionclass_ = 0; 172 this->configvalueclass_ = 0; 173 this->shortcut_ = 0; 174 this->function_ = 0; 175 this->configvalue_ = 0; 176 this->key_ = 0; 177 178 this->errorMessage_ = ""; 179 this->state_ = CS_Uninitialized; 180 181 this->bEvaluatedParams_ = false; 182 this->evaluatedExecutor_ = 0; 183 } 184 185 KeybindMode CommandEvaluation::getKeybindMode() 186 { 187 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 188 { 189 // if (this->shortcut_ != 0) 190 // return this->shortcut_->getKeybindMode(); 191 } 192 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 193 { 194 // if (this->function_ != 0) 195 // return this->function_->getKeybindMode(); 196 } 197 else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished) 198 { 199 // return KeybindMode::onPress; 200 } 201 else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished) 202 { 203 // return KeybindMode::onPress; 204 } 205 else 206 { 207 // return KeybindMode::onPress; 208 } 209 // FIXME: Had to insert a return statement 210 return (KeybindMode)0; 211 } 212 213 bool CommandEvaluation::isValid() const 214 { 215 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 216 { 217 return this->shortcut_; 218 } 219 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 220 { 221 return (this->functionclass_ && this->function_); 222 } 223 else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished) 224 { 225 return (this->configvalueclass_ && this->configvalue_); 226 } 227 else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished) 228 { 229 return this->key_; 230 } 231 else 232 { 233 return false; 234 } 235 } 236 237 void CommandEvaluation::evaluateParams() 238 { 239 this->bEvaluatedParams_ = false; 240 this->evaluatedExecutor_ = 0; 241 242 for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++) 243 this->param_[i] = MT_null; 244 245 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 246 { 247 if (this->shortcut_) 248 { 249 if (this->tokens_.size() <= 1) 250 { 251 if (this->shortcut_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 252 { 253 this->bEvaluatedParams_ = true; 254 this->evaluatedExecutor_ = this->shortcut_; 255 } 256 } 257 else if (this->tokens_.size() > 1) 258 { 259 if (this->shortcut_->evaluate(this->tokens_.subSet(1).join() + this->getAdditionalParameter(), this->param_, " ")) 260 { 261 this->bEvaluatedParams_ = true; 262 this->evaluatedExecutor_ = this->shortcut_; 263 } 264 } 265 } 266 } 267 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 268 { 269 if (this->function_) 270 { 271 if (this->tokens_.size() <= 2) 272 { 273 if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " ")) 274 { 275 this->bEvaluatedParams_ = true; 276 this->evaluatedExecutor_ = this->function_; 277 } 278 } 279 else if (this->tokens_.size() > 2) 280 { 281 if (this->function_->evaluate(this->tokens_.subSet(2).join() + this->getAdditionalParameter(), this->param_, " ")) 282 { 283 this->bEvaluatedParams_ = true; 284 this->evaluatedExecutor_ = this->function_; 285 } 286 } 287 } 288 } 289 } 290 291 void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiTypeMath param) 292 { 293 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) 294 this->param_[index] = param; 295 } 296 297 MultiTypeMath CommandEvaluation::getEvaluatedParameter(unsigned int index) const 298 { 299 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) 300 return this->param_[index]; 301 302 return MT_null; 303 } 304 305 bool CommandEvaluation::hasReturnvalue() const 306 { 307 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 308 { 309 if (this->shortcut_) 310 return this->shortcut_->hasReturnvalue(); 311 } 312 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 313 { 314 if (this->function_) 315 return this->function_->hasReturnvalue(); 316 } 317 318 return MT_null; 319 } 320 321 MultiTypeMath CommandEvaluation::getReturnvalue() const 322 { 323 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 324 { 325 if (this->shortcut_) 326 return this->shortcut_->getReturnvalue(); 327 } 328 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 329 { 330 if (this->function_) 331 return this->function_->getReturnvalue(); 332 } 333 334 return MT_null; 335 } 336 337 338 ///////////////////// 339 // CommandExecutor // 340 ///////////////////// 46 SetConsoleCommandShortcutGeneric(keyword1, createExecutor((FunctorStatic*)0, "set")).setAccessLevel(AccessLevel::User); 47 SetConsoleCommandShortcutGeneric(keyword2, createExecutor((FunctorStatic*)0, "tset")).setAccessLevel(AccessLevel::User); 48 SetConsoleCommandShortcutGeneric(keyword3, createExecutor((FunctorStatic*)0, "bind")).setAccessLevel(AccessLevel::User); 49 341 50 CommandExecutor& CommandExecutor::getInstance() 342 51 { … … 355 64 } 356 65 357 Executor& CommandExecutor::addConsoleCommandShortcut(ExecutorStatic* executor)358 { 359 CommandExecutor::getInstance().consoleCommandShortcuts_[ executor->getName()] = executor;360 CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase( executor->getName())] = executor;361 return (* executor);66 ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command) 67 { 68 CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command; 69 CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(command->getName())] = command; 70 return (*command); 362 71 } 363 72 … … 367 76 @return The executor of the requested console command shortcut 368 77 */ 369 ExecutorStatic* CommandExecutor::getConsoleCommandShortcut(const std::string& name)370 { 371 std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);78 ConsoleCommand* CommandExecutor::getConsoleCommandShortcut(const std::string& name) 79 { 80 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name); 372 81 if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end()) 373 82 return (*it).second; … … 381 90 @return The executor of the requested console command shortcut 382 91 */ 383 ExecutorStatic* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name)384 { 385 std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);92 ConsoleCommand* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name) 93 { 94 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name); 386 95 if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end()) 387 96 return (*it).second; … … 1187 896 void CommandExecutor::createListOfPossibleShortcuts(const std::string& fragment) 1188 897 { 1189 for (std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)898 for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it) 1190 899 { 1191 900 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") … … 1200 909 void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier) 1201 910 { 1202 for (std::map<std::string, ExecutorStatic*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)911 for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it) 1203 912 { 1204 913 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") … … 1261 970 } 1262 971 1263 ExecutorStatic* CommandExecutor::getExecutorOfPossibleShortcut(const std::string& name)1264 { 1265 std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(getLowercase(name));972 ConsoleCommand* CommandExecutor::getExecutorOfPossibleShortcut(const std::string& name) 973 { 974 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(getLowercase(name)); 1266 975 if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd()) 1267 976 return (*it).second; … … 1270 979 } 1271 980 1272 ExecutorStatic* CommandExecutor::getExecutorOfPossibleFunction(const std::string& name, Identifier* identifier)1273 { 1274 std::map<std::string, ExecutorStatic*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(getLowercase(name));981 ConsoleCommand* CommandExecutor::getExecutorOfPossibleFunction(const std::string& name, Identifier* identifier) 982 { 983 std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(getLowercase(name)); 1275 984 if (it != identifier->getLowercaseConsoleCommandMapEnd()) 1276 985 return (*it).second; … … 1319 1028 } 1320 1029 1321 std::string CommandExecutor::dump(const ExecutorStatic* executor)1030 std::string CommandExecutor::dump(const ConsoleCommand* command) 1322 1031 { 1323 1032 std::string output = ""; 1324 for (unsigned int i = 0; i < executor->getParamCount(); i++)1033 for (unsigned int i = 0; i < command->getParamCount(); i++) 1325 1034 { 1326 1035 if (i != 0) 1327 1036 output += " "; 1328 1037 1329 if ( executor->defaultValueSet(i))1038 if (command->defaultValueSet(i)) 1330 1039 output += "["; 1331 1040 else 1332 1041 output += "{"; 1333 1042 1334 output += executor->getTypenameParam(i);1335 1336 if ( executor->defaultValueSet(i))1337 output += "=" + executor->getDefaultValue(i).toString() + "]";1043 output += command->getTypenameParam(i); 1044 1045 if (command->defaultValueSet(i)) 1046 output += "=" + command->getDefaultValue(i).toString() + "]"; 1338 1047 else 1339 1048 output += "}"; -
code/branches/console/src/core/CommandExecutor.h
r1255 r1341 32 32 #include "CorePrereqs.h" 33 33 34 #include <string>35 34 #include <map> 36 #include <list>37 35 38 #include "util/SubString.h" 39 #include "util/MultiTypeMath.h" 36 #include "CommandEvaluation.h" 40 37 41 38 #define COMMAND_EXECUTOR_CURSOR "$" … … 43 40 namespace orxonox 44 41 { 45 enum CommandState46 {47 CS_Uninitialized,48 CS_Empty,49 CS_FunctionClass_Or_Shortcut_Or_Keyword,50 CS_Shortcut_Params,51 CS_Shortcut_Finished,52 CS_Function,53 CS_Function_Params,54 CS_Function_Finished,55 CS_ConfigValueClass,56 CS_ConfigValue,57 CS_ConfigValueType,58 CS_ConfigValueFinished,59 CS_KeybindKey,60 CS_KeybindCommand,61 CS_KeybindFinished,62 CS_Error63 };64 65 void source(const std::string& filename);66 std::string echo(const std::string& text);67 void puts(bool newline, const std::string& test);68 69 void write(const std::string& filename, const std::string& text);70 void append(const std::string& filename, const std::string& text);71 std::string read(const std::string& filename);72 73 enum KeybindMode {}; // temporary74 75 ///////////////////////76 // CommandEvaluation //77 ///////////////////////78 class _CoreExport CommandEvaluation79 {80 friend class CommandExecutor;81 82 public:83 CommandEvaluation();84 85 KeybindMode getKeybindMode();86 bool isValid() const;87 88 inline void setAdditionalParameter(const std::string& param)89 { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }90 inline std::string getAdditionalParameter() const91 { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }92 93 void setEvaluatedParameter(unsigned int index, MultiTypeMath param);94 MultiTypeMath getEvaluatedParameter(unsigned int index) const;95 96 void evaluateParams();97 98 bool hasReturnvalue() const;99 MultiTypeMath getReturnvalue() const;100 101 private:102 std::string processedCommand_;103 SubString tokens_;104 std::string additionalParameter_;105 106 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctionClasses_;107 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleShortcuts_;108 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;109 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValueClasses_;110 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValues_;111 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleKeys_;112 113 Identifier* functionclass_;114 Identifier* configvalueclass_;115 ExecutorStatic* shortcut_;116 ExecutorStatic* function_;117 ConfigValueContainer* configvalue_;118 ConfigValueContainer* key_;119 120 std::string errorMessage_;121 CommandState state_;122 123 bool bEvaluatedParams_;124 MultiTypeMath param_[5];125 ExecutorStatic* evaluatedExecutor_;126 };127 128 /////////////////////129 // CommandExecutor //130 /////////////////////131 42 class _CoreExport CommandExecutor 132 43 { … … 145 56 static const CommandEvaluation& getLastEvaluation(); 146 57 147 static Executor& addConsoleCommandShortcut(ExecutorStatic* executor);148 static ExecutorStatic* getConsoleCommandShortcut(const std::string& name);149 static ExecutorStatic* getLowercaseConsoleCommandShortcut(const std::string& name);58 static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command); 59 static ConsoleCommand* getConsoleCommandShortcut(const std::string& name); 60 static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name); 150 61 151 62 /** @brief Returns the map that stores all console commands. @return The const_iterator */ 152 static inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }63 static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; } 153 64 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */ 154 static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }65 static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); } 155 66 /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */ 156 static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }67 static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); } 157 68 158 69 /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */ 159 static inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }70 static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; } 160 71 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 161 static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }72 static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); } 162 73 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 163 static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }74 static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); } 164 75 165 76 private: … … 191 102 192 103 static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list); 193 static std::string dump(const ExecutorStatic* executor);104 static std::string dump(const ConsoleCommand* command); 194 105 static std::string dump(const ConfigValueContainer* container); 195 106 … … 197 108 198 109 static Identifier* getIdentifierOfPossibleFunctionClass(const std::string& name); 199 static ExecutorStatic* getExecutorOfPossibleShortcut(const std::string& name);200 static ExecutorStatic* getExecutorOfPossibleFunction(const std::string& name, Identifier* identifier);110 static ConsoleCommand* getExecutorOfPossibleShortcut(const std::string& name); 111 static ConsoleCommand* getExecutorOfPossibleFunction(const std::string& name, Identifier* identifier); 201 112 static Identifier* getIdentifierOfPossibleConfigValueClass(const std::string& name); 202 113 static ConfigValueContainer* getContainerOfPossibleConfigValue(const std::string& name, Identifier* identifier); … … 205 116 CommandEvaluation evaluation_; 206 117 207 std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_;208 std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_LC_;118 std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_; 119 std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_; 209 120 }; 210 121 } -
code/branches/console/src/core/ConfigFileManager.cc
r1056 r1341 38 38 namespace orxonox 39 39 { 40 ConsoleCommandShortcutExtern(reloadConfig, AccessLevel::None);41 ConsoleCommandShortcutExtern(cleanConfig, AccessLevel::None);42 ConsoleCommandShortcutExtern(loadSettings, AccessLevel::None);43 ConsoleCommandShortcutExtern(loadKeybindings, AccessLevel::None);40 SetConsoleCommandShortcutExtern(reloadConfig); 41 SetConsoleCommandShortcutExtern(cleanConfig); 42 SetConsoleCommandShortcutExtern(loadSettings); 43 SetConsoleCommandShortcutExtern(loadKeybindings); 44 44 45 45 void reloadConfig() -
code/branches/console/src/core/ConsoleCommand.h
r1062 r1341 38 38 39 39 40 #define SetConsoleCommand(classname, function, bCreateShortcut) \ 41 SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut) 40 42 41 #define ConsoleCommand(classname, function, accesslevel, bCreateShortcut) \ 42 ConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createExecutor(orxonox::createFunctor(&classname::function), #function, accesslevel), bCreateShortcut) 43 44 #define ConsoleCommandGeneric(fakevariable, classname, executor, bCreateShortcut) \ 45 Executor& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ExecutorStatic*)executor, bCreateShortcut) 43 #define SetConsoleCommandGeneric(fakevariable, classname, executor, bCreateShortcut) \ 44 Executor& fakevariable = ClassManager<classname>::getIdentifier()->addConsoleCommand((ConsoleCommand*)executor, bCreateShortcut) 46 45 47 46 48 #define ConsoleCommandShortcut(classname, function, accesslevel) \49 ConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createExecutor(orxonox::createFunctor(&classname::function), #function, accesslevel))47 #define SetConsoleCommandShortcut(classname, function) \ 48 SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function)) 50 49 51 #define ConsoleCommandShortcutExtern(function, accesslevel) \52 ConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createExecutor(orxonox::createFunctor(&function), #function, accesslevel))50 #define SetConsoleCommandShortcutExtern(function) \ 51 SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function)) 53 52 54 #define ConsoleCommandShortcutGeneric(fakevariable, executor) \55 Executor& fakevariable = CommandExecutor::addConsoleCommandShortcut(( ExecutorStatic*)executor)53 #define SetConsoleCommandShortcutGeneric(fakevariable, executor) \ 54 Executor& fakevariable = CommandExecutor::addConsoleCommandShortcut((ConsoleCommand*)executor) 56 55 57 56 57 namespace orxonox 58 { 59 namespace AccessLevel 60 { 61 enum Level 62 { 63 None, 64 User, 65 Admin, 66 Offline, 67 Debug, 68 Disabled 69 }; 70 } 71 72 class _CoreExport ConsoleCommand : public ExecutorStatic 73 { 74 public: 75 ConsoleCommand(FunctorStatic* functor, const std::string& name = "") : ExecutorStatic(functor, name), accessLevel_(AccessLevel::None) {} 76 77 inline ConsoleCommand& setDescription(const std::string& description) 78 { this->ExecutorStatic::setDescription(description); return (*this); } 79 inline ConsoleCommand& setDescriptionParam(int param, const std::string& description) 80 { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); } 81 inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description) 82 { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); } 83 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1) 84 { this->ExecutorStatic::setDefaultValues(param1); return (*this); } 85 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 86 { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); } 87 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 88 { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); } 89 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 90 { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); } 91 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 92 { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); } 93 inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param) 94 { this->ExecutorStatic::setDefaultValue(index, param); return (*this); } 95 96 inline ConsoleCommand& setAccessLevel(AccessLevel::Level level) 97 { this->accessLevel_ = level; return (*this); } 98 inline AccessLevel::Level getAccessLevel() const 99 { return this->accessLevel_; } 100 101 private: 102 AccessLevel::Level accessLevel_; 103 }; 104 105 inline ConsoleCommand* createConsoleCommand(FunctorStatic* functor, const std::string& name = "") 106 { 107 return new ConsoleCommand(functor, name); 108 } 109 } 110 58 111 #endif /* _ConsoleCommand_H__ */ -
code/branches/console/src/core/CorePrereqs.h
r1313 r1341 66 66 namespace orxonox 67 67 { 68 #ifndef _XMLPort_Mode__69 #define _XMLPort_Mode__70 68 namespace XMLPort 71 69 { … … 76 74 }; 77 75 } 78 #endif79 76 80 77 typedef std::string LanguageEntryLabel; … … 101 98 class ConfigFileSection; 102 99 class ConfigValueContainer; 100 class ConsoleCommand; 103 101 class CoreSettings; 104 102 class Error; -
code/branches/console/src/core/Executor.cc
r1062 r1341 34 34 namespace orxonox 35 35 { 36 Executor::Executor(Functor* functor, const std::string& name , AccessLevel::Level level)36 Executor::Executor(Functor* functor, const std::string& name) 37 37 { 38 38 this->functor_ = functor; 39 39 this->name_ = name; 40 this->accessLevel_ = level;41 40 42 41 this->bAddedDescription_ = false; -
code/branches/console/src/core/Executor.h
r1247 r1341 135 135 return true 136 136 137 namespace AccessLevel138 {139 enum Level140 {141 None,142 User,143 Admin,144 Offline,145 Debug,146 Disabled147 };148 }149 150 137 namespace orxonox 151 138 { … … 153 140 { 154 141 public: 155 Executor(Functor* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None);142 Executor(Functor* functor, const std::string& name = ""); 156 143 virtual ~Executor(); 157 144 … … 182 169 const std::string& getDescriptionReturnvalue(int param) const; 183 170 171 inline Functor* getFunctor() const 172 { return this->functor_; } 184 173 inline unsigned int getParamCount() const 185 174 { return this->functor_->getParamCount(); } … … 200 189 { return this->name_; } 201 190 202 inline void setAccessLevel(AccessLevel::Level level)203 { this->accessLevel_ = level; }204 inline AccessLevel::Level getAccessLevel() const205 { return this->accessLevel_; }206 207 191 Executor& setDefaultValues(const MultiTypeMath& param1); 208 192 Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2); … … 243 227 bool bAddedDescriptionReturnvalue_; 244 228 bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS]; 245 246 AccessLevel::Level accessLevel_;247 229 }; 248 230 … … 250 232 { 251 233 public: 252 ExecutorStatic(FunctorStatic* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {}234 ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {} 253 235 virtual ~ExecutorStatic() {} 254 236 }; … … 258 240 { 259 241 public: 260 ExecutorMember(FunctorMember<T>* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {}242 ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {} 261 243 virtual ~ExecutorMember() {} 262 244 … … 304 286 }; 305 287 306 inline Executor* createExecutor(Functor* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None)307 { 308 return new Executor(functor, name , level);288 inline Executor* createExecutor(Functor* functor, const std::string& name = "") 289 { 290 return new Executor(functor, name); 309 291 } 310 292 311 293 template <class T> 312 inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None)313 { 314 return new ExecutorMember<T>(functor, name , level);294 inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "") 295 { 296 return new ExecutorMember<T>(functor, name); 315 297 } 316 298 317 inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "" , AccessLevel::Level level = AccessLevel::None)318 { 319 return new ExecutorStatic(functor, name , level);299 inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "") 300 { 301 return new ExecutorStatic(functor, name); 320 302 } 321 303 } -
code/branches/console/src/core/IRC.cc
r1276 r1341 39 39 namespace orxonox 40 40 { 41 ConsoleCommand(IRC, say, AccessLevel::User, true);42 ConsoleCommand(IRC, msg, AccessLevel::User, false);43 ConsoleCommand(IRC, nick, AccessLevel::User, false);41 SetConsoleCommand(IRC, say, true).setAccessLevel(AccessLevel::User); 42 SetConsoleCommand(IRC, msg, false).setAccessLevel(AccessLevel::User); 43 SetConsoleCommand(IRC, nick, false).setAccessLevel(AccessLevel::User); 44 44 45 45 IRC* instance_irc = &IRC::getInstance(); -
code/branches/console/src/core/Identifier.cc
r1062 r1341 37 37 38 38 #include "Factory.h" 39 #include " Executor.h"39 #include "ConsoleCommand.h" 40 40 #include "CommandExecutor.h" 41 41 … … 270 270 @return The executor of the command 271 271 */ 272 ExecutorStatic& Identifier::addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut)272 ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut) 273 273 { 274 274 this->bHasConsoleCommands_ = true; 275 this->consoleCommands_[ executor->getName()] = executor;276 this->consoleCommands_LC_[getLowercase( executor->getName())] = executor;275 this->consoleCommands_[command->getName()] = command; 276 this->consoleCommands_LC_[getLowercase(command->getName())] = command; 277 277 278 278 if (bCreateShortcut) 279 CommandExecutor::addConsoleCommandShortcut( executor);280 281 return (* executor);279 CommandExecutor::addConsoleCommandShortcut(command); 280 281 return (*command); 282 282 } 283 283 … … 287 287 @return The executor of the requested console command 288 288 */ 289 ExecutorStatic* Identifier::getConsoleCommand(const std::string& name) const290 { 291 std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_.find(name);289 ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const 290 { 291 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name); 292 292 if (it != this->consoleCommands_.end()) 293 293 return (*it).second; … … 301 301 @return The executor of the requested console command 302 302 */ 303 ExecutorStatic* Identifier::getLowercaseConsoleCommand(const std::string& name) const304 { 305 std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_LC_.find(name);303 ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const 304 { 305 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name); 306 306 if (it != this->consoleCommands_LC_.end()) 307 307 return (*it).second; -
code/branches/console/src/core/Identifier.h
r1313 r1341 176 176 177 177 /** @brief Returns the map that stores all console commands. @return The const_iterator */ 178 inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandMap() const { return this->consoleCommands_; }178 inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; } 179 179 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */ 180 inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }180 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); } 181 181 /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */ 182 inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }182 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); } 183 183 184 184 /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */ 185 inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }185 inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; } 186 186 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 187 inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }187 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); } 188 188 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 189 inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }189 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); } 190 190 191 191 … … 214 214 virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0; 215 215 216 ExecutorStatic& addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut);217 ExecutorStatic* getConsoleCommand(const std::string& name) const;218 ExecutorStatic* getLowercaseConsoleCommand(const std::string& name) const;216 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut); 217 ConsoleCommand* getConsoleCommand(const std::string& name) const; 218 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const; 219 219 220 220 protected: … … 271 271 272 272 bool bHasConsoleCommands_; //!< True if this class has at least one assigned console command 273 std::map<std::string, ExecutorStatic*> consoleCommands_; //!< All console commands of this class274 std::map<std::string, ExecutorStatic*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase273 std::map<std::string, ConsoleCommand*> consoleCommands_; //!< All console commands of this class 274 std::map<std::string, ConsoleCommand*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase 275 275 }; 276 276 -
code/branches/console/src/core/InputManager.cc
r1322 r1341 43 43 namespace orxonox 44 44 { 45 ConsoleCommand(InputManager, setInputMode, AccessLevel::Admin, true).setDefaultValue(0, IM_INGAME);45 SetConsoleCommand(InputManager, setInputMode, true).setDefaultValue(0, IM_INGAME); 46 46 47 47 /** -
code/branches/console/src/core/OutputHandler.cc
r1322 r1341 38 38 namespace orxonox 39 39 { 40 ConsoleCommandShortcutGeneric(log, createExecutor(createFunctor(&OutputHandler::log), "log", AccessLevel::None));41 ConsoleCommandShortcutGeneric(error, createExecutor(createFunctor(&OutputHandler::error), "error", AccessLevel::None));42 ConsoleCommandShortcutGeneric(warning, createExecutor(createFunctor(&OutputHandler::warning), "warning", AccessLevel::None));43 ConsoleCommandShortcutGeneric(info, createExecutor(createFunctor(&OutputHandler::info), "info", AccessLevel::None));44 ConsoleCommandShortcutGeneric(debug, createExecutor(createFunctor(&OutputHandler::debug), "debug", AccessLevel::None));40 SetConsoleCommandShortcutGeneric(log, createExecutor(createFunctor(&OutputHandler::log), "log" )); 41 SetConsoleCommandShortcutGeneric(error, createExecutor(createFunctor(&OutputHandler::error), "error" )); 42 SetConsoleCommandShortcutGeneric(warning, createExecutor(createFunctor(&OutputHandler::warning), "warning")); 43 SetConsoleCommandShortcutGeneric(info, createExecutor(createFunctor(&OutputHandler::info), "info" )); 44 SetConsoleCommandShortcutGeneric(debug, createExecutor(createFunctor(&OutputHandler::debug), "debug" )); 45 45 46 46 /** -
code/branches/console/src/core/TclBind.cc
r1276 r1341 39 39 namespace orxonox 40 40 { 41 ConsoleCommandShortcutGeneric(tcl, createExecutor(createFunctor(&TclBind::tcl), "tcl", AccessLevel::None));42 ConsoleCommandShortcutGeneric(bgerror, createExecutor(createFunctor(&TclBind::bgerror), "bgerror", AccessLevel::None));41 SetConsoleCommandShortcutGeneric(tcl, createExecutor(createFunctor(&TclBind::tcl), "tcl")); 42 SetConsoleCommandShortcutGeneric(bgerror, createExecutor(createFunctor(&TclBind::bgerror), "bgerror")); 43 43 44 44 TclBind::TclBind() -
code/branches/console/src/core/TclThreadManager.cc
r1337 r1341 48 48 namespace orxonox 49 49 { 50 ConsoleCommandShortcutGeneric(tclexecute, createExecutor(createFunctor(&TclThreadManager::execute), "tclexecute", AccessLevel::None));51 ConsoleCommandShortcutGeneric(tclquery, createExecutor(createFunctor(&TclThreadManager::query), "tclquery", AccessLevel::None));52 ConsoleCommand(TclThreadManager, create, AccessLevel::None,false);53 ConsoleCommand(TclThreadManager, destroy, AccessLevel::None, false);54 ConsoleCommand(TclThreadManager, execute, AccessLevel::None, false);55 ConsoleCommand(TclThreadManager, query, AccessLevel::None,false);56 ConsoleCommand(TclThreadManager, status, AccessLevel::None,false);57 ConsoleCommand(TclThreadManager, dump, AccessLevel::None,false);58 ConsoleCommand(TclThreadManager, flush, AccessLevel::None,false);50 SetConsoleCommandShortcutGeneric(tclexecute, createExecutor(createFunctor(&TclThreadManager::execute), "tclexecute")); 51 SetConsoleCommandShortcutGeneric(tclquery, createExecutor(createFunctor(&TclThreadManager::query), "tclquery" )); 52 SetConsoleCommand(TclThreadManager, create, false); 53 SetConsoleCommand(TclThreadManager, destroy, false); 54 SetConsoleCommand(TclThreadManager, execute, false); 55 SetConsoleCommand(TclThreadManager, query, false); 56 SetConsoleCommand(TclThreadManager, status, false); 57 SetConsoleCommand(TclThreadManager, dump, false); 58 SetConsoleCommand(TclThreadManager, flush, false); 59 59 60 60 TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance(); -
code/branches/console/src/core/XMLPort.h
r1062 r1341 78 78 namespace orxonox 79 79 { 80 81 #ifndef _XMLPort_Mode__82 #define _XMLPort_Mode__83 namespace XMLPort84 {85 enum Mode86 {87 LoadObject,88 SaveObject89 };90 }91 #endif92 93 80 // ############################### 94 81 // ### XMLPortParamContainer ### -
code/branches/console/src/orxonox/Orxonox.cc
r1334 r1341 54 54 //#include "util/Sleep.h" 55 55 #include "util/ArgReader.h" 56 #include "util/ExprParser.h"57 56 58 57 // core … … 60 59 #include "core/ConsoleCommand.h" 61 60 #include "core/Debug.h" 62 #include "core/Factory.h"63 61 #include "core/Loader.h" 64 62 #include "core/Tickable.h" 65 #include "core/InputBuffer.h"66 63 #include "core/InputManager.h" 67 64 … … 74 71 75 72 // objects and tools 76 #include "tools/Timer.h"77 73 #include "hud/HUD.h" 78 74 //#include "console/InGameConsole.h" … … 85 81 namespace orxonox 86 82 { 87 ConsoleCommand(Orxonox, exit, AccessLevel::None, true); 88 ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0); 89 ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0); 90 91 class Calculator 92 { 93 public: 94 static float calculate(const std::string& calculation) 95 { 96 ExprParser expr(calculation); 97 if (expr.getSuccess()) 98 { 99 if (expr.getResult() == 42.0) 100 std::cout << "Greetings from the restaurant at the end of the universe." << std::endl; 101 // FIXME: insert modifier to display in full precision 102 std::cout << "Result is: " << expr.getResult() << std::endl; 103 if (expr.getRemains() != "") 104 std::cout << "Warning: Expression could not be parsed to the end! Remains: '" 105 << expr.getRemains() << "'" << std::endl; 106 return expr.getResult(); 107 } 108 else 109 { 110 std::cout << "Cannot calculate expression: Parse error" << std::endl; 111 return 0; 112 } 113 } 114 }; 115 ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None); 83 SetConsoleCommand(Orxonox, exit, true); 84 SetConsoleCommand(Orxonox, slomo, true).setDefaultValue(0, 1.0).setAccessLevel(AccessLevel::Offline); 85 SetConsoleCommand(Orxonox, setTimeFactor, false).setDefaultValue(0, 1.0).setAccessLevel(AccessLevel::Offline); 116 86 117 87 /** -
code/branches/console/src/orxonox/console/InGameConsole.cc
r1338 r1341 49 49 namespace orxonox 50 50 { 51 ConsoleCommand(InGameConsole, openConsole, AccessLevel::None, true);52 ConsoleCommand(InGameConsole, closeConsole, AccessLevel::None, true);51 SetConsoleCommand(InGameConsole, openConsole, true); 52 SetConsoleCommand(InGameConsole, closeConsole, true); 53 53 54 54 using namespace Ogre; -
code/branches/console/src/orxonox/objects/Ambient.cc
r1064 r1341 47 47 namespace orxonox 48 48 { 49 ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1));49 SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline); 50 50 51 51 CreateFactory(Ambient); -
code/branches/console/src/orxonox/objects/SpaceShip.cc
r1064 r1341 53 53 namespace orxonox 54 54 { 55 ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false);56 ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false);57 ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false);58 ConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl", AccessLevel::Debug), false);55 SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug); 56 SetConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug); 57 SetConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug); 58 SetConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug); 59 59 60 60 CreateFactory(SpaceShip); -
code/branches/console/src/orxonox/tools/Timer.cc
r1063 r1341 27 27 */ 28 28 29 #include <set> 30 29 31 #include "OrxonoxStableHeaders.h" 30 32 #include "Timer.h" … … 37 39 namespace orxonox 38 40 { 39 ConsoleCommandShortcutExtern(delay, AccessLevel::None); 41 SetConsoleCommandShortcutExtern(delay); 42 SetConsoleCommandShortcutExtern(killdelays); 43 44 static std::set<StaticTimer*> delaytimerset; 40 45 41 46 /** … … 47 52 { 48 53 StaticTimer *delaytimer = new StaticTimer(); 54 delaytimerset.insert(delaytimer); 55 49 56 ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand)); 50 57 delayexecutor->setDefaultValues(delaytimer, command); … … 61 68 CommandExecutor::execute(command); 62 69 delete timer; 70 delaytimerset.erase(timer); 71 } 72 73 /** 74 @brief Kills all delayed commands. 75 */ 76 void killdelays() 77 { 78 for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it) 79 delete (*it); 80 81 delaytimerset.clear(); 63 82 } 64 83 -
code/branches/console/src/orxonox/tools/Timer.h
r1056 r1341 69 69 class StaticTimer; 70 70 void delay(float delay, const std::string& command); 71 void killdelays(); 71 72 void executeDelayedCommand(StaticTimer* timer, const std::string& command); 72 73
Note: See TracChangeset
for help on using the changeset viewer.