35 std::vector<MemoryID> bos;
43 std::stringstream error;
45 for (
const auto& [subscription, subCallbacks] : this->
callbacks)
47 std::vector<MemoryID> matchingSnapshotIDs;
49 for (
const MemoryID& updatedSnapshotID : updatedSnapshotIDs)
53 if (
contains(subscription, updatedSnapshotID))
56 matchingSnapshotIDs.push_back(updatedSnapshotID);
66 error <<
"Error when comparing subscribed ID " << subscription
67 <<
" with updated ID " << updatedSnapshotID <<
":\n"
68 << e.what() <<
"\n\n";
72 if (not matchingSnapshotIDs.empty())
74 ARMARX_DEBUG <<
"Calling " << subCallbacks.size() <<
" callbacks"
75 <<
" subscribing " << subscription <<
" with "
76 << matchingSnapshotIDs.size() <<
" snapshot IDs ...";
77 for (
auto& managedCallback : subCallbacks)
81 managedCallback.callback(subscription, matchingSnapshotIDs);
83 catch (
const armarx::LocalException& e)
85 error <<
"Calling callback subscribing " << subscription <<
" failed."
86 <<
"\nCaught armarx::LocalException:"
88 << e.getReason() <<
"\n Stacktrace: \n"
89 << e.generateBacktrace() <<
"\n";
91 catch (
const std::exception& e)
93 error <<
"Calling callback subscribing " << subscription <<
" failed."
94 <<
"\nCaught armarx::Exception:"
100 error <<
"Calling callback subscribing " << subscription <<
" failed."
101 <<
"\nCaught unknown exception."
107 if (error.str().size() > 0)
109 ARMARX_WARNING <<
"The following issues were encountered during MemoryListener::"
110 << __FUNCTION__ <<
"(): \n\n"
119 <<
"The memoryName must be specified to subscribe";
139 [callback](
const MemoryID&,
const std::vector<MemoryID>& updatedSnapshotIDs)
140 { callback(updatedSnapshotIDs); });
146 if (not handle.valid)
150 handle.valid =
false;
153 auto it = std::find_if(
callbacks[handle.memoryID].begin(),
157 std::iter_swap(it,
callbacks[handle.memoryID].end() - 1);