Changeset 1610 for code/branches/core3/src/core/ConfigValueContainer.h
- Timestamp:
- Jun 19, 2008, 4:10:27 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ConfigValueContainer.h
r1596 r1610 103 103 ConfigValueContainer& getValue(T* value, C* object) 104 104 { 105 if (this->callback_ && object) 106 { 105 std::cout << "start: " << this->getName() << std::endl; 106 if ((this->callback_ && object) || this->bContainerIsNew_) 107 { 108 if (this->bContainerIsNew_) 109 this->bContainerIsNew_ = false; 110 107 111 T temp = *value; 108 112 this->value_.getValue(value); 109 113 if ((*value) != temp) 110 this->callback_->call(object); 114 { 115 if (this->callback_ && object) 116 this->callback_->call(object); 117 else 118 this->bDoInitialCallback_ = true; 119 } 111 120 } 112 121 else … … 114 123 this->value_.getValue(value); 115 124 } 125 std::cout << "end" << std::endl; 116 126 return *this; 117 127 } … … 121 131 ConfigValueContainer& getValue(std::vector<T>* value, C* object) 122 132 { 123 if (this->callback_ && object) 124 { 133 if ((this->callback_ && object) || this->bContainerIsNew_) 134 { 135 if (this->bContainerIsNew_) 136 this->bContainerIsNew_ = false; 137 125 138 std::vector<T> temp = *value; 126 127 139 value->clear(); 128 140 for (unsigned int i = 0; i < this->valueVector_.size(); ++i) … … 131 143 if (value->size() != temp.size()) 132 144 { 133 this->callback_->call(object); 145 if (this->callback_ && object) 146 this->callback_->call(object); 147 else 148 this->bDoInitialCallback_ = true; 134 149 } 135 150 else … … 139 154 if ((*value)[i] != temp[i]) 140 155 { 141 this->callback_->call(object); 156 if (this->callback_ && object) 157 this->callback_->call(object); 158 else 159 this->bDoInitialCallback_ = true; 142 160 break; 143 161 } … … 172 190 173 191 template <class T> 174 inline ConfigValueContainer& callback( void (T::*function) (void))192 inline ConfigValueContainer& callback(T* object, void (T::*function) (void)) 175 193 { 176 194 if (!this->callback_) 195 { 177 196 this->callback_ = new ConfigValueCallback<T>(function); 197 198 if (this->bDoInitialCallback_) 199 { 200 this->bDoInitialCallback_ = false; 201 this->callback_->call(object); 202 } 203 } 204 178 205 return (*this); 179 206 } … … 215 242 LanguageEntryLabel description_; //!< The description 216 243 ConfigValueCallbackBase* callback_; //!< A callback function to call after getValue if the value changed 244 245 bool bContainerIsNew_; //!< True if it's the first time getValue() gets called 246 bool bDoInitialCallback_; //!< True if the callback should be called as soon as it gets created 217 247 }; 218 248 }
Note: See TracChangeset
for help on using the changeset viewer.