Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/behaviortree_cpp/blackboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Blackboard

void debugMessage() const;

[[nodiscard]] std::vector<StringView> getKeys() const;
[[nodiscard]] std::vector<std::string> getKeys() const;

[[deprecated("This command is unsafe. Consider using Backup/Restore instead")]] void
clear();
Expand Down
10 changes: 5 additions & 5 deletions src/blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ void Blackboard::debugMessage() const
}
}

std::vector<StringView> Blackboard::getKeys() const
std::vector<std::string> Blackboard::getKeys() const
{
std::unique_lock<std::mutex> lock(mutex_);
if(storage_.empty())
{
return {};
}
std::vector<StringView> out;
std::vector<std::string> out;
out.reserve(storage_.size());
for(const auto& entry_it : storage_)
{
Expand Down Expand Up @@ -272,10 +273,9 @@ std::shared_ptr<Blackboard::Entry> Blackboard::createEntryImpl(const std::string
nlohmann::json ExportBlackboardToJSON(const Blackboard& blackboard)
{
nlohmann::json dest;
for(auto entry_name : blackboard.getKeys())
for(const std::string& name : blackboard.getKeys())
{
std::string name(entry_name);
if(auto any_ref = blackboard.getAnyLocked(name))
if(AnyPtrLocked any_ref = blackboard.getAnyLocked(name))
{
if(auto any_ptr = any_ref.get())
{
Expand Down
4 changes: 2 additions & 2 deletions tests/gtest_blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ TEST(BlackboardTest, BlackboardBackup)
for(const auto& sub : tree.subtrees)
{
std::vector<std::string> keys;
for(const auto& str_view : sub->blackboard->getKeys())
for(const std::string& str : sub->blackboard->getKeys())
{
keys.push_back(std::string(str_view));
keys.push_back(str);
}
expected_keys.push_back(keys);
}
Expand Down
Loading