[Orxonox-commit 6167] r10825 - in code/branches/cpp11_v2: src/libraries/core src/libraries/core/command src/libraries/core/input src/libraries/core/object test/core/command
landauf at orxonox.net
landauf at orxonox.net
Sun Nov 22 16:55:02 CET 2015
Author: landauf
Date: 2015-11-22 16:55:02 +0100 (Sun, 22 Nov 2015)
New Revision: 10825
Modified:
code/branches/cpp11_v2/src/libraries/core/EventIncludes.h
code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.cc
code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc
code/branches/cpp11_v2/src/libraries/core/command/Executor.h
code/branches/cpp11_v2/src/libraries/core/command/ExecutorPtr.h
code/branches/cpp11_v2/src/libraries/core/command/Functor.h
code/branches/cpp11_v2/src/libraries/core/command/FunctorPtr.h
code/branches/cpp11_v2/src/libraries/core/input/KeyBinderManager.h
code/branches/cpp11_v2/src/libraries/core/object/Listable.h
code/branches/cpp11_v2/test/core/command/ExecutorPtrTest.cc
code/branches/cpp11_v2/test/core/command/FunctorPtrTest.cc
Log:
use std::shared_ptr instead of orxonox::SharedPtr for FunctorPtr and ExecutorPtr
Modified: code/branches/cpp11_v2/src/libraries/core/EventIncludes.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/EventIncludes.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/EventIncludes.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -85,8 +85,10 @@
XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
- static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname>>(); \
- static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname>>(); \
+ static orxonox::ExecutorPtr xmlsetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')'); \
+ static orxonox::ExecutorPtr xmlgetfunctorbase##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')'); \
+ static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlsetfunctorbase##name); \
+ static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = std::static_pointer_cast<orxonox::ExecutorMember<classname>>(xmlgetfunctorbase##name); \
xmlsetfunctor##name->setDefaultValue(1, statename); \
xmlgetfunctor##name->setDefaultValue(1, statename); \
XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
Modified: code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.cc 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/CommandExecutor.cc 2015-11-22 15:55:02 UTC (rev 10825)
@@ -274,7 +274,7 @@
if (evaluation.isValid())
{
// it is valid - copy the executor of this command
- ExecutorPtr executor = new Executor(*evaluation.getConsoleCommand()->getExecutor().get());
+ ExecutorPtr executor = std::make_shared<Executor>(*evaluation.getConsoleCommand()->getExecutor().get());
// evaluate the arguments and if this returns no error, store them as default values
if (!evaluation.evaluateArguments())
Modified: code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc 2015-11-22 15:55:02 UTC (rev 10825)
@@ -319,7 +319,7 @@
void ConsoleCommand::pushFunction()
{
if (this->executor_)
- this->pushFunction(new Executor(*this->executor_.get()));
+ this->pushFunction(std::make_shared<Executor>(*this->executor_.get()));
else
orxout(internal_error, context::commands) << "Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << endl;
}
Modified: code/branches/cpp11_v2/src/libraries/core/command/Executor.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/Executor.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/Executor.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -266,20 +266,20 @@
/// Creates a new Executor that wraps a given Functor.
inline ExecutorPtr createExecutor(const FunctorPtr& functor, const std::string& name = "")
{
- return new Executor(functor, name);
+ return std::make_shared<Executor>(functor, name);
}
/// Creates a new ExecutorMember that wraps a given FunctorMember.
template <class T>
inline ExecutorMemberPtr<T> createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
{
- return new ExecutorMember<T>(functor, name);
+ return std::make_shared<ExecutorMember<T>>(functor, name);
}
/// Creates a new ExecutorStatic that wraps a given FunctorStatic.
inline ExecutorStaticPtr createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
{
- return new ExecutorStatic(functor, name);
+ return std::make_shared<ExecutorStatic>(functor, name);
}
}
Modified: code/branches/cpp11_v2/src/libraries/core/command/ExecutorPtr.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/ExecutorPtr.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/ExecutorPtr.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -48,14 +48,14 @@
#define _ExecutorPtr_H__
#include "core/CorePrereqs.h"
-#include "util/SharedPtr.h"
+#include <memory>
namespace orxonox
{
- using ExecutorPtr = SharedPtr<Executor>;
- using ExecutorStaticPtr = SharedChildPtr<ExecutorStatic, ExecutorPtr>;
+ using ExecutorPtr = std::shared_ptr<Executor>;
+ using ExecutorStaticPtr = std::shared_ptr<ExecutorStatic>;
template <class T>
- using ExecutorMemberPtr = SharedChildPtr<ExecutorMember<T>, ExecutorPtr>;
+ using ExecutorMemberPtr = std::shared_ptr<ExecutorMember<T>>;
}
#endif /* _ExecutorPtr_H__ */
Modified: code/branches/cpp11_v2/src/libraries/core/command/Functor.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/Functor.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/Functor.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -504,7 +504,7 @@
// see Functor::clone()
FunctorPtr clone()
{
- return new FunctorTemplate(*this);
+ return std::make_shared<FunctorTemplate>(*this);
}
// see Functor::evaluateArgument()
@@ -573,38 +573,38 @@
}
};
- template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, P1, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(), OO* object) { return std::make_shared<FunctorTemplate<R, O, false, void, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, P1, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
+ template <class R, class O, class OO> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const, OO* object) { return std::make_shared<FunctorTemplate<R, O, true, void, void, void, void, void>>(functionPointer, object); } ///< Creates a new FunctorMember with the given function-pointer and an assigned object
- template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2)) { return std::make_shared<FunctorTemplate<R, O, false, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1)) { return std::make_shared<FunctorTemplate<R, O, false, P1, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)()) { return std::make_shared<FunctorTemplate<R, O, false, void, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3, class P4, class P5> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3, class P4> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2, class P3> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2, P3) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1, class P2> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1, P2) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O, class P1> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)(P1) const) { return std::make_shared<FunctorTemplate<R, O, true, P1, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
+ template <class R, class O> inline FunctorMemberPtr<O> createFunctor(R (O::*functionPointer)() const) { return std::make_shared<FunctorTemplate<R, O, true, void, void, void, void, void>>(functionPointer); } ///< Creates a new FunctorMember with the given function-pointer
- template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); } ///< Creates a new Functor with the given function-pointer
- template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer
- template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer
- template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer
- template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer
- template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R, class P1, class P2, class P3, class P4, class P5> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R, class P1, class P2, class P3, class P4> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3, P4)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, P4, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R, class P1, class P2, class P3> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2, P3)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, P3, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R, class P1, class P2> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1, P2)) { return std::make_shared<FunctorTemplate<R, void, false, P1, P2, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R, class P1> inline FunctorStaticPtr createFunctor(R (*functionPointer)(P1)) { return std::make_shared<FunctorTemplate<R, void, false, P1, void, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
+ template <class R> inline FunctorStaticPtr createFunctor(R (*functionPointer)()) { return std::make_shared<FunctorTemplate<R, void, false, void, void, void, void, void>>(functionPointer); } ///< Creates a new Functor with the given function-pointer
}
#endif /* _Functor_H__ */
Modified: code/branches/cpp11_v2/src/libraries/core/command/FunctorPtr.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/command/FunctorPtr.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/command/FunctorPtr.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -50,16 +50,16 @@
#define _FunctorPtr_H__
#include "core/CorePrereqs.h"
-#include "util/SharedPtr.h"
+#include <memory>
namespace orxonox
{
- using FunctorPtr = SharedPtr<Functor>;
+ using FunctorPtr = std::shared_ptr<Functor>;
template <class T>
- using FunctorMemberPtr = SharedChildPtr<FunctorMember<T>, FunctorPtr>;
- using FunctorStaticPtr = FunctorMemberPtr<void>;
+ using FunctorMemberPtr = std::shared_ptr<FunctorMember<T>>;
+ using FunctorStaticPtr = std::shared_ptr<FunctorMember<void>>;
template <class F, class T>
- using FunctorPointerPtr = SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>;
+ using FunctorPointerPtr = std::shared_ptr<FunctorPointer<F, T>>;
}
#endif /* _FunctorPtr_H__ */
Modified: code/branches/cpp11_v2/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/input/KeyBinderManager.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/input/KeyBinderManager.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -35,6 +35,7 @@
#include <string>
#include "util/Singleton.h"
+#include "util/SharedPtr.h"
#include "core/config/Configurable.h"
namespace orxonox //tolua_export
Modified: code/branches/cpp11_v2/src/libraries/core/object/Listable.h
===================================================================
--- code/branches/cpp11_v2/src/libraries/core/object/Listable.h 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/src/libraries/core/object/Listable.h 2015-11-22 15:55:02 UTC (rev 10825)
@@ -39,6 +39,7 @@
#include <vector>
+#include "util/SmallObjectAllocator.h"
#include "core/class/Identifiable.h"
namespace orxonox
Modified: code/branches/cpp11_v2/test/core/command/ExecutorPtrTest.cc
===================================================================
--- code/branches/cpp11_v2/test/core/command/ExecutorPtrTest.cc 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/test/core/command/ExecutorPtrTest.cc 2015-11-22 15:55:02 UTC (rev 10825)
@@ -12,6 +12,10 @@
static void testStatic() {}
};
+ class Subclass : public Testclass
+ {
+ };
+
// Fixture
class ExecutorPtrTest : public ::testing::Test
{
@@ -70,4 +74,11 @@
ExecutorPtr ptr2 = ptr1;
ASSERT_TRUE(static_cast<bool>(ptr2));
}
+
+ TEST_F(ExecutorPtrTest, canCastToExecutorMemberOfSubclass)
+ {
+ ExecutorPtr ptr1 = createExecutor(createFunctor(&Subclass::testMember));
+ ExecutorMemberPtr<Subclass> ptr2 = std::static_pointer_cast<ExecutorMember<Subclass>>(ptr1);
+ ASSERT_TRUE(static_cast<bool>(ptr2));
+ }
}
Modified: code/branches/cpp11_v2/test/core/command/FunctorPtrTest.cc
===================================================================
--- code/branches/cpp11_v2/test/core/command/FunctorPtrTest.cc 2015-11-22 14:09:51 UTC (rev 10824)
+++ code/branches/cpp11_v2/test/core/command/FunctorPtrTest.cc 2015-11-22 15:55:02 UTC (rev 10825)
@@ -12,6 +12,10 @@
static void testStatic() {}
};
+ class Subclass : public Testclass
+ {
+ };
+
// Fixture
class FunctorPtrTest : public ::testing::Test
{
@@ -70,4 +74,11 @@
FunctorPtr ptr2 = ptr1;
ASSERT_TRUE(static_cast<bool>(ptr2));
}
+
+ TEST_F(FunctorPtrTest, canCastToFunctorMemberOfSubclass)
+ {
+ FunctorPtr ptr1 = createFunctor(&Subclass::testMember);
+ FunctorMemberPtr<Subclass> ptr2 = std::static_pointer_cast<FunctorMember<Subclass>>(ptr1);
+ ASSERT_TRUE(static_cast<bool>(ptr2));
+ }
}
More information about the Orxonox-commit
mailing list