Changeset 10352 for code/branches/core7/src/libraries/core/command
- Timestamp:
- Apr 8, 2015, 11:15:11 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core/command
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/command/CMakeLists.txt
r10346 r10352 4 4 ConsoleCommand.cc 5 5 ConsoleCommandCompilation.cc 6 ConsoleCommandIncludes.cc 6 7 ConsoleCommandManager.cc 7 8 Executor.cc -
code/branches/core7/src/libraries/core/command/ConsoleCommand.cc
r10348 r10352 84 84 this->executor_ = executor; 85 85 86 ConsoleCommandManager::registerCommand(group, name, this);86 this->names_.push_back(CommandName(group, name)); 87 87 } 88 88 … … 100 100 ConsoleCommand& ConsoleCommand::addShortcut() 101 101 { 102 ConsoleCommandManager::registerCommand("", this->baseName_, this);102 this->names_.push_back(CommandName("", this->baseName_)); 103 103 return *this; 104 104 } … … 109 109 ConsoleCommand& ConsoleCommand::addShortcut(const std::string& name) 110 110 { 111 ConsoleCommandManager::registerCommand("", name, this);111 this->names_.push_back(CommandName("", name)); 112 112 return *this; 113 113 } … … 118 118 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group) 119 119 { 120 ConsoleCommandManager::registerCommand(group, this->baseName_, this);120 this->names_.push_back(CommandName(group, this->baseName_)); 121 121 return *this; 122 122 } … … 127 127 ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string& name) 128 128 { 129 ConsoleCommandManager::registerCommand(group, name, this);129 this->names_.push_back(CommandName(group, name)); 130 130 return *this; 131 131 } -
code/branches/core7/src/libraries/core/command/ConsoleCommand.h
r10348 r10352 104 104 105 105 public: 106 /** 107 * @brief Defines the name of a command, consisting of an optional group ("" means no group) and the name itself. 108 */ 109 struct CommandName 110 { 111 CommandName(const std::string& group, const std::string& name) : group_(group), name_(name) {} 112 std::string group_; 113 std::string name_; 114 }; 115 106 116 /** 107 117 @brief Helper class that is used to manipulate console commands. … … 360 370 { return this; } 361 371 372 inline const std::vector<CommandName>& getNames() 373 { return this->names_; } 374 362 375 private: 363 376 void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized); … … 383 396 AccessLevel::Enum accessLevel_; ///< The access level (the state of the game in which you can access the command) 384 397 std::string baseName_; ///< The name that was first assigned to the command 398 std::vector<CommandName> names_; ///< All names and aliases of this command 385 399 FunctorPtr baseFunctor_; ///< The functor that defines the header of the command-function 386 400 -
code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
r10348 r10352 223 223 #include "ConsoleCommandManager.h" 224 224 #include "util/VA_NARGS.h" 225 #include "core/module/StaticallyInitializedInstance.h" 225 226 226 227 … … 264 265 /// Internal macro 265 266 #define SetConsoleCommandGeneric(group, name, functor) \ 266 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))) 267 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \ 268 = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))))->getCommand() 267 269 268 270 … … 299 301 /// Internal macro 300 302 #define DeclareConsoleCommandGeneric(group, name, functor) \ 301 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)) 303 static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \ 304 = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)))->getCommand() 302 305 303 306 304 307 namespace orxonox 305 308 { 309 class _CoreExport StaticallyInitializedConsoleCommand : public StaticallyInitializedInstance 310 { 311 public: 312 StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {} 313 314 virtual void load(); 315 316 inline ConsoleCommand& getCommand() 317 { return *this->command_; } 318 319 private: 320 ConsoleCommand* command_; 321 }; 322 323 typedef StaticallyInitializedConsoleCommand SI_CC; 324 306 325 /** 307 326 @brief Returns a manipulator for a command with the given name.
Note: See TracChangeset
for help on using the changeset viewer.