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

Method insert

tools/rtpsrelay/GuidPartitionTable.cpp:16–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16GuidPartitionTable::Result GuidPartitionTable::insert(const OpenDDS::DCPS::GUID_t& guid,
17 const DDS::StringSeq& partitions)
18{
19 Result result;
20 std::vector<RelayPartitions> relay_partitions;
21
22 {
23 ACE_GUARD_RETURN(ACE_Thread_Mutex, g, mutex_, NO_CHANGE);
24
25 StringSet parts;
26 for (CORBA::ULong idx = 0; idx != partitions.length(); ++idx) {
27 parts.insert(partitions[idx].in());
28 }
29 if (parts.empty()) {
30 // Special case for empty list of partitions.
31 parts.insert("");
32 }
33
34 const auto r = guid_to_partitions_.insert(std::make_pair(guid, StringSet()));
35 result = r.second ? ADDED : UPDATED;
36 auto& x = r.first->second;
37
38 std::vector<std::string> to_add;
39 std::set_difference(parts.begin(), parts.end(), x.begin(), x.end(), std::back_inserter(to_add));
40
41 std::vector<std::string> to_remove;
42 std::set_difference(x.begin(), x.end(), parts.begin(), parts.end(), std::back_inserter(to_remove));
43
44 if (to_add.empty() && to_remove.empty()) {
45 if (result == ADDED) {
46 relay_stats_reporter_.partition_guids(guid_to_partitions_.size(), guid_to_partitions_cache_.size());
47 }
48 return NO_CHANGE;
49 }
50
51 remove_from_cache(guid);
52
53 StringSet globally_new;
54 x.insert(to_add.begin(), to_add.end());
55 for (const auto& part : to_add) {
56 const auto q = partition_to_guid_.insert(std::make_pair(part, OrderedGuidSet()));
57 q.first->second.insert(guid);
58 partition_index_.insert(part, guid);
59 if (q.second) {
60 globally_new.insert(part);
61 }
62 }
63 for (const auto& part : to_remove) {
64 x.erase(part);
65 partition_to_guid_[part].erase(guid);
66 partition_index_.remove(part, guid);
67 if (partition_to_guid_[part].empty()) {
68 partition_to_guid_.erase(part);
69 }
70 }
71 if (x.empty()) {
72 guid_to_partitions_.erase(r.first);
73 }

Callers 15

add_participantMethod · 0.45
upsert_addressMethod · 0.45
find_or_createMethod · 0.45
record_activityMethod · 0.45
reject_addressMethod · 0.45
on_data_availableMethod · 0.45
on_data_availableMethod · 0.45
on_data_availableMethod · 0.45
add_newMethod · 0.45
remove_defunctMethod · 0.45
add_to_slotMethod · 0.45
parse_messageMethod · 0.45

Calls 13

back_inserterFunction · 0.85
partition_guidsMethod · 0.80
partition_index_nodesMethod · 0.80
partition_index_cacheMethod · 0.80
cache_sizeMethod · 0.80
lengthMethod · 0.45
inMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected