| 156 | |
| 157 | template<typename Sample, typename TypedDataReader> |
| 158 | void |
| 159 | MultiTopicDataReader_T<Sample, TypedDataReader>::combine( |
| 160 | SampleVec& resulting, const SampleVec& other, |
| 161 | const std::vector<OPENDDS_STRING>& key_names, const TopicSet& other_topics) |
| 162 | { |
| 163 | const MetaStruct& meta = getResultingMeta(); |
| 164 | SampleVec new_data; |
| 165 | for (typename SampleVec::iterator it_res = resulting.begin(); |
| 166 | it_res != resulting.end(); /*incremented in loop*/) { |
| 167 | bool found_one_match = false; |
| 168 | for (typename SampleVec::const_iterator it_other = other.begin(); |
| 169 | it_other != other.end(); ++it_other) { |
| 170 | bool match = true; |
| 171 | for (size_t i = 0; match && i < key_names.size(); ++i) { |
| 172 | if (!meta.compare(&*it_res, &*it_other, key_names[i].c_str())) { |
| 173 | match = false; |
| 174 | } |
| 175 | } |
| 176 | if (!match) { |
| 177 | continue; |
| 178 | } |
| 179 | if (found_one_match) { |
| 180 | new_data.push_back(*it_res); |
| 181 | new_data.back().combine(*it_other); |
| 182 | assign_resulting_fields(new_data.back().sample_, it_other->sample_, other_topics); |
| 183 | } else { |
| 184 | found_one_match = true; |
| 185 | it_res->combine(*it_other); |
| 186 | assign_resulting_fields(it_res->sample_, it_other->sample_, other_topics); |
| 187 | } |
| 188 | } |
| 189 | if (found_one_match) { |
| 190 | ++it_res; |
| 191 | } else { |
| 192 | // no match found in 'other' so data must not appear in result set |
| 193 | it_res = resulting.erase(it_res); |
| 194 | } |
| 195 | } |
| 196 | resulting.insert(resulting.end(), new_data.begin(), new_data.end()); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Two constituent topics are joinable directly if they have some common join keys, |