Changeset 7177 for code/trunk/src/libraries/core/Functor.h
- Timestamp:
- Aug 18, 2010, 1:52:55 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/Functor.h
r6417 r7177 135 135 FunctorMember() 136 136 { 137 constObject_ = 0; 138 object_ = 0; 139 bConstObject_ = false; 137 this->object_ = 0; 138 this->constObject_ = 0; 140 139 } 141 140 virtual ~FunctorMember() {} … … 146 145 virtual void 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) 147 146 { 148 if (this->bConstObject_) 149 { 150 if (this->constObject_) 151 (*this)(this->constObject_, param1, param2, param3, param4, param5); 152 else 153 { 154 COUT(1) << "An error occurred in Functor.h:" << std::endl; 155 COUT(1) << "Error: No const object set." << std::endl; 156 } 157 } 147 if (this->object_) 148 (*this)(this->object_, param1, param2, param3, param4, param5); 149 else if (this->constObject_) 150 (*this)(this->constObject_, param1, param2, param3, param4, param5); 158 151 else 159 152 { 160 if (this->object_) 161 (*this)(this->object_, param1, param2, param3, param4, param5); 162 else 163 { 164 COUT(1) << "An error occurred in Functor.h:" << std::endl; 165 COUT(1) << "Error: No object set." << std::endl; 166 } 153 COUT(1) << "An error occurred in Functor.h:" << std::endl; 154 COUT(1) << "Error: No object set." << std::endl; 167 155 } 168 156 } 169 157 170 FunctorMember<T>* setObject(T* object)158 inline FunctorMember<T>* setObject(T* object) 171 159 { 172 this->bConstObject_ = false;173 160 this->object_ = object; 161 this->constObject_ = 0; 174 162 return this; 175 163 } 176 164 177 FunctorMember<T>* setObject(const T* object)165 inline FunctorMember<T>* setObject(const T* object) 178 166 { 179 this-> bConstObject_ = true;167 this->object_ = 0; 180 168 this->constObject_ = object; 181 169 return this; 182 170 } 183 171 172 typedef std::pair<T*, const T*> Objects; 173 174 inline Objects getObjects() const 175 { 176 return Objects(this->object_, this->constObject_); 177 } 178 179 inline void setObjects(const Objects& objects) 180 { 181 this->object_ = objects.first; 182 this->constObject_ = objects.second; 183 } 184 184 185 private: 186 T* object_; 185 187 const T* constObject_; 186 T* object_;187 bool bConstObject_;188 188 }; 189 189
Note: See TracChangeset
for help on using the changeset viewer.