Changeset 7177 for code/trunk/src/libraries/core
- Timestamp:
- Aug 18, 2010, 1:52:55 AM (14 years ago)
- Location:
- code/trunk/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/Executor.h
r7163 r7177 183 183 bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const 184 184 { 185 static_cast<FunctorMember<T>*>(this->functor_)->setObject(object); 186 if (Executor::parse(params, delimiter)) 187 return true; 188 else 189 { 190 static_cast<FunctorMember<T>*>(this->functor_)->setObject((T*)NULL); 191 return false; 192 } 185 FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_); 186 187 const typename FunctorMember<T>::Objects& objects = functorMember->getObjects(); 188 189 functorMember->setObject(object); 190 bool result = Executor::parse(params, delimiter); 191 functorMember->setObjects(objects); 192 193 return result; 193 194 } 194 195 195 196 bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const 196 197 { 197 static_cast<FunctorMember<T>*>(this->functor_)->setObject(object); 198 if (Executor::parse(params, delimiter)) 199 return true; 200 else 201 { 202 static_cast<FunctorMember<T>*>(this->functor_)->setObject((T*)NULL); 203 return false; 204 } 198 FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_); 199 200 const typename FunctorMember<T>::Objects& objects = functorMember->getObjects(); 201 202 functorMember->setObject(object); 203 bool result = Executor::parse(params, delimiter); 204 functorMember->setObjects(objects); 205 206 return result; 205 207 } 206 208 }; -
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.