2 #include <unordered_set>
10 return str.size() >= 1 && str.data()[0] ==
'_';
46 const std::shared_ptr<Blackboard::Entry>
55 std::unique_lock<std::mutex> lock(
mutex_);
67 auto const& new_key = remap_it->second;
68 return parent->getEntry(new_key);
72 return parent->getEntry(key);
86 return (!entry) ? nullptr : &(entry->info);
92 {
static_cast<std::string
>(
internal),
static_cast<std::string
>(external) });
97 for(
const auto& [key, entry] :
storage_)
99 auto port_type = entry->info.type();
100 if(port_type ==
typeid(
void))
102 port_type = entry->value.type();
105 std::cout << key <<
" (" <<
BT::demangle(port_type) <<
")" << std::endl;
110 std::cout <<
"[" << from <<
"] remapped to port of parent tree [" << to <<
"]"
122 std::vector<StringView> out;
124 for(
const auto& entry_it :
storage_)
126 out.push_back(entry_it.first);
133 std::unique_lock<std::mutex> lock(
mutex_);
156 std::unique_lock lk1(
mutex_);
157 std::unique_lock lk2(dst.
mutex_);
160 std::unordered_set<std::string> keys_to_remove;
162 for(
const auto& [key,
_] : dst_storage)
164 keys_to_remove.insert(key);
168 for(
const auto& [src_key, src_entry] :
storage_)
170 keys_to_remove.erase(src_key);
172 auto it = dst_storage.find(src_key);
173 if(it != dst_storage.end())
176 auto& dst_entry = it->second;
177 dst_entry->string_converter = src_entry->string_converter;
178 dst_entry->value = src_entry->value;
179 dst_entry->info = src_entry->info;
180 dst_entry->sequence_id++;
181 dst_entry->stamp = std::chrono::steady_clock::now().time_since_epoch();
186 auto new_entry = std::make_shared<Entry>(src_entry->info);
187 new_entry->value = src_entry->value;
188 new_entry->string_converter = src_entry->string_converter;
189 dst_storage.insert({ src_key, new_entry });
193 for(
const auto& key : keys_to_remove)
195 dst_storage.erase(key);
211 std::unique_lock<std::mutex> lock(
mutex_);
216 auto storage_it =
storage_.find(key);
219 const auto& prev_info = storage_it->second->info;
220 if(prev_info.type() != info.type() && prev_info.isStronglyTyped() &&
221 info.isStronglyTyped())
223 auto msg =
StrCat(
"Blackboard entry [", key,
224 "]: once declared, the type of a port"
225 " shall not change. Previously declared type [",
231 return storage_it->second;
238 const auto& remapped_key = remapping_it->second;
241 return parent->createEntryImpl(remapped_key, info);
250 return parent->createEntryImpl(key, info);
256 auto entry = std::make_shared<Entry>(info);
258 entry->value =
Any(info.type());
266 for(
auto entry_name : blackboard.
getKeys())
268 std::string name(entry_name);
282 for(
auto it =
json.begin(); it !=
json.end(); ++it)
286 auto entry = blackboard.
getEntry(it.key());
290 entry = blackboard.
getEntry(it.key());
292 entry->value = res->first;