Changeset 11071 for code/trunk/src/libraries/core/command/FunctorPtr.h
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/command/FunctorPtr.h
r7401 r11071 32 32 @brief Typedefs and definitions of FunctorPtr, FunctorMemberPtr, FunctorStaticPtr, and FunctorPointerPtr 33 33 34 Instances of orxonox::Functor are usually managed by an orxonox::SharedPtr. This ensures34 Instances of orxonox::Functor are usually managed by an std::shared_ptr. This ensures 35 35 that Functors will be destroyed after usage. To make things easier, there's a typedef 36 that defines FunctorPtr as SharedPtr<Functor>.36 that defines FunctorPtr as std::shared_ptr<Functor>. 37 37 38 38 Because there's not only orxonox::Functor, but also orxonox::FunctorStatic, and … … 51 51 52 52 #include "core/CorePrereqs.h" 53 #include "util/SharedPtr.h"53 #include <memory> 54 54 55 55 namespace orxonox 56 56 { 57 /// FunctorPtr is just a typedef of SharedPtr 58 typedef SharedPtr<Functor> FunctorPtr; 59 60 /// It's not possible to use a typedef for FunctorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 57 using FunctorPtr = std::shared_ptr<Functor>; 61 58 template <class T> 62 class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr> 63 { 64 public: 65 inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {} 66 inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {} 67 inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {} 68 }; 69 70 /// FunctorStaticPtr is just FunctorMemberPtr with @a T = void 71 typedef FunctorMemberPtr<void> FunctorStaticPtr; 72 73 /// It's not possible to use a typedef for FunctorPointerPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors. 59 using FunctorMemberPtr = std::shared_ptr<FunctorMember<T>>; 60 using FunctorStaticPtr = std::shared_ptr<FunctorMember<void>>; 74 61 template <class F, class T> 75 class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> > 76 { 77 public: 78 inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >() {} 79 inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(pointer) {} 80 inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T> >& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(other) {} 81 }; 62 using FunctorPointerPtr = std::shared_ptr<FunctorPointer<F, T>>; 82 63 } 83 64
Note: See TracChangeset
for help on using the changeset viewer.