Changeset 7218 for code/branches/consolecommands3/src
- Timestamp:
- Aug 25, 2010, 11:46:32 PM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries/core/command
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
r7216 r7218 93 93 bool _ConsoleCommand::isActive() const 94 94 { 95 return (this->bActive_ && this->executor_ && this->executor_->getFunctor() );95 return (this->bActive_ && this->executor_ && this->executor_->getFunctor() && (this->executor_->getFunctor()->getType() == Functor::Type::Static || this->executor_->getFunctor()->getRawObjectPointer())); 96 96 } 97 97 … … 154 154 if (this->executor_) 155 155 this->executor_->setFunctor(functor); 156 else 156 else if (functor) 157 157 this->executor_ = createExecutor(functor); 158 158 … … 208 208 if (command.executor_) 209 209 this->executor_->setFunctor(command.functor_); 210 } 211 212 void _ConsoleCommand::resetFunction() 213 { 214 if (this->executor_) 215 this->executor_->setFunctor(0); 210 216 } 211 217 … … 453 459 /* static */ void _ConsoleCommand::destroyAll() 454 460 { 455 while (!_ConsoleCommand::getCommandMap().empty() && !_ConsoleCommand::getCommandMap().begin() .empty())456 _ConsoleCommand::getCommandMap().begin().erase(_ConsoleCommand::getCommandMap().begin().begin());461 while (!_ConsoleCommand::getCommandMap().empty() && !_ConsoleCommand::getCommandMap().begin()->second.empty()) 462 delete _ConsoleCommand::getCommandMap().begin()->second.begin()->second; 457 463 } 458 464 } -
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
r7216 r7218 51 51 52 52 #define _SetConsoleCommandGeneric(group, name, functor) \ 53 orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor)))53 static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor))) 54 54 55 55 … … 64 64 65 65 #define _DeclareConsoleCommandGeneric(group, name, functor) \ 66 orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor), false)66 static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor), false)) 67 67 68 68 69 69 namespace orxonox 70 70 { 71 namespace prototype 72 { 73 inline void void__void(void) {} 74 inline void void__string(const std::string&) {} 75 } 76 77 namespace AccessLevel 78 { 79 enum Enum 80 { 81 All, 82 Standalone, 83 Master, 84 Server, 85 Client, 86 Online, 87 Offline, 88 None 89 }; 90 } 91 71 92 class _CoreExport _ConsoleCommand 72 93 { … … 77 98 ExecutorPtr executor_; 78 99 FunctorPtr functor_; 79 };80 81 struct AccessLevel82 {83 enum Enum84 {85 All,86 Standalone,87 Master,88 Server,89 Client,90 Online,91 Offline,92 None93 };94 100 }; 95 101 … … 150 156 { if (this->command_) { this->command_->popFunction(); } return *this; } 151 157 158 inline _ConsoleCommandManipulator& resetFunction() 159 { if (this->command_) { this->command_->resetFunction(); } return *this; } 160 152 161 inline _ConsoleCommandManipulator& setObject(void* object) 153 162 { if (this->command_) { this->command_->setObject(object); } return *this; } … … 184 193 { if (this->command_) { this->command_->defaultValue(index, param); } return *this; } 185 194 186 inline _ConsoleCommandManipulator& accessLevel( _ConsoleCommand::AccessLevel::Enum level)195 inline _ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level) 187 196 { if (this->command_) { this->command_->accessLevel(level); } return *this; } 188 197 … … 210 219 _ConsoleCommand& addGroup(const std::string& group, const std::string& name); 211 220 212 inline _ConsoleCommand setActive(bool bActive) 221 inline const std::string& getName() const 222 { return this->baseName_; } 223 224 const ExecutorPtr& getExecutor() const; 225 inline const ExecutorPtr& getBaseExecutor() const 226 { return this->baseExecutor_; } 227 228 inline _ConsoleCommand& setActive(bool bActive) 213 229 { this->bActive_ = bActive; return *this; } 214 inline _ConsoleCommand activate()230 inline _ConsoleCommand& activate() 215 231 { return this->setActive(true); } 216 inline _ConsoleCommand deactivate()232 inline _ConsoleCommand& deactivate() 217 233 { return this->setActive(false); } 218 234 … … 291 307 void pushFunction(); 292 308 void popFunction(); 293 const ExecutorPtr& getExecutor() const; 294 const FunctorPtr& getFunctor() const; 309 void resetFunction(); 295 310 296 311 bool setObject(void* object);
Note: See TracChangeset
for help on using the changeset viewer.