[Orxonox-commit 2562] r7267 - code/branches/consolecommands3/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Mon Aug 30 18:27:59 CEST 2010
Author: landauf
Date: 2010-08-30 18:27:59 +0200 (Mon, 30 Aug 2010)
New Revision: 7267
Modified:
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
Log:
use a base-functor instead of a base-executor in ConsoleCommand because the functor of a static executor changes if new functions are assigned to the command.
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-30 15:04:12 UTC (rev 7266)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-30 16:27:59 UTC (rev 7267)
@@ -42,7 +42,7 @@
this->accessLevel_ = AccessLevel::All;
this->baseName_ = name;
- this->baseExecutor_ = executor;
+ this->baseFunctor_ = executor->getFunctor();
this->argumentCompleter_[0] = 0;
this->argumentCompleter_[1] = 0;
@@ -111,19 +111,24 @@
bool ConsoleCommand::headersMatch(const FunctorPtr& functor)
{
- unsigned int minparams = std::min(this->baseExecutor_->getParamCount(), functor->getParamCount());
+ unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), functor->getParamCount());
- if (this->baseExecutor_->getFunctor()->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams))
+ if (this->baseFunctor_->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams))
return false;
- else if (functor->getParamCount() <= this->baseExecutor_->getParamCount())
+ else if (functor->getParamCount() <= this->baseFunctor_->getParamCount())
return true;
else if (!this->executor_)
return false;
else
{
- for (unsigned int i = this->baseExecutor_->getParamCount(); i < functor->getParamCount(); ++i)
+ for (unsigned int i = this->baseFunctor_->getParamCount(); i < functor->getParamCount(); ++i)
+ {
if (!this->executor_->defaultValueSet(i))
+ {
+ COUT(2) << "Default value " << i << " is missing" << std::endl;
return false;
+ }
+ }
return true;
}
@@ -131,17 +136,22 @@
bool ConsoleCommand::headersMatch(const ExecutorPtr& executor)
{
- unsigned int minparams = std::min(this->baseExecutor_->getParamCount(), executor->getParamCount());
+ unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), executor->getParamCount());
- if (this->baseExecutor_->getFunctor()->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams))
+ if (this->baseFunctor_->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams))
return false;
- else if (executor->getParamCount() <= this->baseExecutor_->getParamCount())
+ else if (executor->getParamCount() <= this->baseFunctor_->getParamCount())
return true;
else
{
- for (unsigned int i = this->baseExecutor_->getParamCount(); i < executor->getParamCount(); ++i)
+ for (unsigned int i = this->baseFunctor_->getParamCount(); i < executor->getParamCount(); ++i)
+ {
if (!executor->defaultValueSet(i))
+ {
+ COUT(2) << "Default value " << i << " is missing" << std::endl;
return false;
+ }
+ }
return true;
}
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-30 15:04:12 UTC (rev 7266)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-30 16:27:59 UTC (rev 7267)
@@ -222,8 +222,8 @@
{ return this->baseName_; }
const ExecutorPtr& getExecutor() const;
- inline const ExecutorPtr& getBaseExecutor() const
- { return this->baseExecutor_; }
+ inline const FunctorPtr& getBaseFunctor() const
+ { return this->baseFunctor_; }
inline ConsoleCommand& setActive(bool bActive)
{ this->bActive_ = bActive; return *this; }
@@ -310,7 +310,7 @@
bool bHidden_;
AccessLevel::Enum accessLevel_;
std::string baseName_;
- ExecutorPtr baseExecutor_;
+ FunctorPtr baseFunctor_;
ExecutorPtr executor_;
std::stack<Command> commandStack_;
More information about the Orxonox-commit
mailing list