[Orxonox-commit 2511] r7218 - code/branches/consolecommands3/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Wed Aug 25 23:46:33 CEST 2010
Author: landauf
Date: 2010-08-25 23:46:32 +0200 (Wed, 25 Aug 2010)
New Revision: 7218
Modified:
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
Log:
some improvements/fixes in ConsoleCommand
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-25 21:27:55 UTC (rev 7217)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-25 21:46:32 UTC (rev 7218)
@@ -92,7 +92,7 @@
bool _ConsoleCommand::isActive() const
{
- return (this->bActive_ && this->executor_ && this->executor_->getFunctor());
+ return (this->bActive_ && this->executor_ && this->executor_->getFunctor() && (this->executor_->getFunctor()->getType() == Functor::Type::Static || this->executor_->getFunctor()->getRawObjectPointer()));
}
bool _ConsoleCommand::headersMatch(const FunctorPtr& functor)
@@ -153,7 +153,7 @@
{
if (this->executor_)
this->executor_->setFunctor(functor);
- else
+ else if (functor)
this->executor_ = createExecutor(functor);
return true;
@@ -209,6 +209,12 @@
this->executor_->setFunctor(command.functor_);
}
+ void _ConsoleCommand::resetFunction()
+ {
+ if (this->executor_)
+ this->executor_->setFunctor(0);
+ }
+
const ExecutorPtr& _ConsoleCommand::getExecutor() const
{
return this->executor_;
@@ -452,7 +458,7 @@
/* static */ void _ConsoleCommand::destroyAll()
{
- while (!_ConsoleCommand::getCommandMap().empty() && !_ConsoleCommand::getCommandMap().begin().empty())
- _ConsoleCommand::getCommandMap().begin().erase(_ConsoleCommand::getCommandMap().begin().begin());
+ while (!_ConsoleCommand::getCommandMap().empty() && !_ConsoleCommand::getCommandMap().begin()->second.empty())
+ delete _ConsoleCommand::getCommandMap().begin()->second.begin()->second;
}
}
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-25 21:27:55 UTC (rev 7217)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-25 21:46:32 UTC (rev 7218)
@@ -50,7 +50,7 @@
_SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
#define _SetConsoleCommandGeneric(group, name, functor) \
- orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor)))
+ static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor)))
#define _DeclareConsoleCommand(...) \
@@ -63,11 +63,32 @@
_DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
#define _DeclareConsoleCommandGeneric(group, name, functor) \
- orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor), false)
+ static orxonox::_ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::_createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
namespace orxonox
{
+ namespace prototype
+ {
+ inline void void__void(void) {}
+ inline void void__string(const std::string&) {}
+ }
+
+ namespace AccessLevel
+ {
+ enum Enum
+ {
+ All,
+ Standalone,
+ Master,
+ Server,
+ Client,
+ Online,
+ Offline,
+ None
+ };
+ }
+
class _CoreExport _ConsoleCommand
{
friend struct _ConsoleCommandManipulator;
@@ -78,21 +99,6 @@
FunctorPtr functor_;
};
- struct AccessLevel
- {
- enum Enum
- {
- All,
- Standalone,
- Master,
- Server,
- Client,
- Online,
- Offline,
- None
- };
- };
-
public:
struct _ConsoleCommandManipulator
{
@@ -149,6 +155,9 @@
inline _ConsoleCommandManipulator& popFunction()
{ if (this->command_) { this->command_->popFunction(); } return *this; }
+ inline _ConsoleCommandManipulator& resetFunction()
+ { if (this->command_) { this->command_->resetFunction(); } return *this; }
+
inline _ConsoleCommandManipulator& setObject(void* object)
{ if (this->command_) { this->command_->setObject(object); } return *this; }
inline _ConsoleCommandManipulator& pushObject(void* object)
@@ -183,7 +192,7 @@
inline _ConsoleCommandManipulator& defaultValue(unsigned int index, const MultiType& param)
{ if (this->command_) { this->command_->defaultValue(index, param); } return *this; }
- inline _ConsoleCommandManipulator& accessLevel(_ConsoleCommand::AccessLevel::Enum level)
+ inline _ConsoleCommandManipulator& accessLevel(AccessLevel::Enum level)
{ if (this->command_) { this->command_->accessLevel(level); } return *this; }
inline _ConsoleCommandManipulator& argumentCompleter(unsigned int param, ArgumentCompleter* completer)
@@ -209,11 +218,18 @@
_ConsoleCommand& addGroup(const std::string& group);
_ConsoleCommand& addGroup(const std::string& group, const std::string& name);
- inline _ConsoleCommand setActive(bool bActive)
+ inline const std::string& getName() const
+ { return this->baseName_; }
+
+ const ExecutorPtr& getExecutor() const;
+ inline const ExecutorPtr& getBaseExecutor() const
+ { return this->baseExecutor_; }
+
+ inline _ConsoleCommand& setActive(bool bActive)
{ this->bActive_ = bActive; return *this; }
- inline _ConsoleCommand activate()
+ inline _ConsoleCommand& activate()
{ return this->setActive(true); }
- inline _ConsoleCommand deactivate()
+ inline _ConsoleCommand& deactivate()
{ return this->setActive(false); }
inline _ConsoleCommand& setHidden(bool bHidden)
@@ -290,8 +306,7 @@
void pushFunction(const FunctorPtr& functor, bool bForce = false);
void pushFunction();
void popFunction();
- const ExecutorPtr& getExecutor() const;
- const FunctorPtr& getFunctor() const;
+ void resetFunction();
bool setObject(void* object);
void pushObject(void* object);
More information about the Orxonox-commit
mailing list