MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / combine

Method combine

dds/DCPS/MultiTopicDataReader_T.cpp:158–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157template<typename Sample, typename TypedDataReader>
158void
159MultiTopicDataReader_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,

Callers 1

joinMethod · 0.45

Calls 6

beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
compareMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected