15 : name_(name), id_(id), obj_(obj)
30 lock->unregisterVariable(
id_);
34 : last_id_(0), names_version_(0), buffer_size_(internal_buffer_capacity), all_enabled_(true), registrations_changed_(true)
41 for (
size_t i = 0; i <
ids_.size(); ++i)
54 for (
size_t i = 0; i <
ids_.size(); ++i)
67 size_t count =
name_id_.left.count(name);
71 "You asked to unregister "
73 <<
" but there are multiple variables registered with that name. This can have undefined behaviour, unregistering all");
77 ROS_ERROR_STREAM(
"Tried to unregister variable " << name <<
" but it is not registered.");
94 auto &last_values = last_values_stamped.first;
96 assert(last_values.names.capacity() >=
ids_.size());
97 assert(last_values.values.capacity() >=
ids_.size());
102 last_values.names =
ids_;
104 for (
size_t i = 0; i < ref_size; ++i)
110 last_values.values.resize(ref_size);
114 last_values.names.clear();
115 last_values.values.clear();
117 size_t id_size =
ids_.size();
118 for (
size_t i = 0; i < id_size; ++i)
124 last_values.names.emplace_back(
ids_[i]);
125 last_values.values.emplace_back(
references_[i].getValue());
140 names.names[i] =
name_id_.right.find(
id)->second;;
143 value.header = names.header;
145 value.names_version = names.names_version;
162 for (
size_t i = 0; i <
enabled_.size(); ++i)
195 ROS_ERROR_STREAM(
"Didn't find index " << index <<
" in <name, index> multimap");
203 std::swap(
ids_[index],
ids_.back());
223 bool needs_more_capacity = (
names_.size() ==
names_.capacity());
225 name_id_.left.insert(std::make_pair(name,
id));
231 if (needs_more_capacity )
246 if ((*it).name_ == name)
251 throw std::runtime_error(
"Unable to find registration with name " + name);
263 throw std::runtime_error(
"Unable to find registration with id " + std::to_string(
id));
274 boost::unique_lock<boost::mutex> guard(
mutex_);
280 boost::unique_lock<boost::mutex> guard(
mutex_);
295 boost::unique_lock<boost::mutex> guard(
mutex_);
315 return reg.
obj_.lock()->enable(reg.
id_);
321 return reg.
obj_.lock()->enable(reg.
id_);
329 result &= (*it).obj_.lock()->enable((*it).id_);
337 return reg.
obj_.lock()->disable(reg.
id_);
343 return reg.
obj_.lock()->disable(reg.
id_);
351 result |= (*it).obj_.lock()->disable((*it).id_);