void AnimationContainer::Run() { // 在更新所有元素后通知观察者. 如果所有元素在更新时都被删除, 那么我们的引用计数 // 将会变为0, 在通知观察者后也会被删除. 这里添加一次引用保证遍历所有元素后对象 // 还是合法的. scoped_refptr<AnimationContainer> this_ref(this); TimeTicks current_time = TimeTicks::Now(); last_tick_time_ = current_time; // 拷贝一份用于遍历, 这样在调用Step时移除任何元素都不会有问题. Elements elements = elements_; for(Elements::const_iterator i=elements.begin(); i!=elements.end(); ++i) { // 确保元素是合法的. if(elements_.find(*i) != elements_.end()) { (*i)->Step(current_time); } } if(observer_) { observer_->AnimationContainerProgressed(this); } }
void swap(message_impl &other) { base_type &base_ref(other), &this_ref(*this); std::swap(this_ref, base_ref); std::swap(status_, other.status_); std::swap(status_message_, other.status_message_); std::swap(version_, other.version_); }
void swap(basic_response & other) { message_impl<Tag> & base_ref(other); message_impl<Tag> & this_ref(*this); this_ref.swap(base_ref); std::swap(other.version_, version_); std::swap(other.status_, status_); std::swap(other.status_message_, status_message_); };
void swap(basic_response& other) { base_type& base_ref(other), &this_ref(*this); std::swap(this_ref, base_ref); };