Changeset 7192 for code/branches/consolecommands3/src/libraries/core
- Timestamp:
- Aug 20, 2010, 2:59:20 AM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries/core
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/Executor.cc
r7189 r7192 39 39 namespace orxonox 40 40 { 41 int Functor::instances_s = 0; 42 int Executor::instances_s = 0; 43 41 44 Executor::Executor(Functor* functor, const std::string& name) 42 45 { 46 this->references_ = 0; 43 47 this->functor_ = functor; 44 48 this->name_ = name; 49 ++instances_s; COUT(0) << "executor ++: " << instances_s << std::endl; 45 50 } 46 51 … … 48 53 { 49 54 delete this->functor_; 55 --instances_s; COUT(0) << "executor --: " << instances_s << std::endl; 50 56 } 51 57 -
code/branches/consolecommands3/src/libraries/core/Executor.h
r7189 r7192 41 41 class _CoreExport Executor 42 42 { 43 friend class SharedPtr<Executor>; 44 43 45 public: 44 46 Executor(Functor* functor, const std::string& name = ""); … … 108 110 std::string name_; 109 111 MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS]; 112 113 private: 114 inline void incrementReferenceCount() 115 { ++this->references_; } 116 inline void decrementReferenceCount() 117 { --this->references_; if (this->references_ == 0) delete this; } 118 119 int references_; 120 static int instances_s; 110 121 }; 111 122 … … 187 198 }; 188 199 200 201 202 typedef SharedPtr<Executor> ExecutorPtr; 203 204 typedef SharedChildPtr<ExecutorStatic, Executor> ExecutorStaticPtr; 205 206 template <class T> 207 class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, Executor> 208 { 209 public: 210 inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, Executor>() {} 211 inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, Executor>(pointer) {} 212 // inline ExecutorMemberPtr(const ExecutorMemberPtr& other) : SharedChildPtr<ExecutorMember<T>, Executor>(other) {} 213 }; 214 215 216 189 217 inline Executor* createExecutor(Functor* functor, const std::string& name = "") 190 218 { -
code/branches/consolecommands3/src/libraries/core/Functor.h
r7189 r7192 38 38 #include "util/Debug.h" 39 39 #include "util/MultiType.h" 40 #include "SharedPtr.h" 40 41 41 42 namespace orxonox … … 88 89 class _CoreExport Functor 89 90 { 91 friend class SharedPtr<Functor>; 92 90 93 public: 91 94 struct Type … … 101 104 102 105 public: 103 Functor() {}104 virtual ~Functor() { }106 Functor() : references_(0) { ++instances_s; COUT(0) << "functor ++: " << instances_s << std::endl; } 107 virtual ~Functor() { --instances_s; COUT(0) << "functor --: " << instances_s << std::endl; } 105 108 106 109 virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; … … 119 122 120 123 virtual const std::type_info& getHeaderIdentifier() const = 0; 124 125 private: 126 inline void incrementReferenceCount() 127 { ++this->references_; } 128 inline void decrementReferenceCount() 129 { --this->references_; if (this->references_ == 0) delete this; } 130 131 int references_; 132 static int instances_s; 121 133 }; 122 134 … … 200 212 T* object_; 201 213 const T* constObject_; 214 }; 215 216 217 218 typedef SharedPtr<Functor> FunctorPtr; 219 220 typedef SharedChildPtr<FunctorStatic, Functor> FunctorStaticPtr; 221 222 template <class T> 223 class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, Functor> 224 { 225 public: 226 inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, Functor>() {} 227 inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, Functor>(pointer) {} 228 // inline FunctorMemberPtr(const FunctorMemberPtr& other) : SharedChildPtr<FunctorMember<T>, Functor>(other) {} 202 229 }; 203 230
Note: See TracChangeset
for help on using the changeset viewer.