Skip to content

Commit 033789a

Browse files
committed
method added to BlackBoard
1 parent 0402b7b commit 033789a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/behaviortree_cpp/blackboard/blackboard.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class BlackboardImpl
2525

2626
virtual const SafeAny::Any* get(const std::string& key) const = 0;
2727
virtual void set(const std::string& key, const SafeAny::Any& value) = 0;
28+
virtual bool contains(const std::string& key) const = 0;
2829
};
2930

3031
// This is the "frontend" to be used by the developer.
@@ -107,6 +108,11 @@ class Blackboard
107108
}
108109
}
109110

111+
bool contains(const std::string& key) const
112+
{
113+
return (impl_ && impl_->contains(key));
114+
}
115+
110116
private:
111117
std::unique_ptr<BlackboardImpl> impl_;
112118
};

include/behaviortree_cpp/blackboard/blackboard_local.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class BlackboardLocal : public BlackboardImpl
2727
storage_[key] = value;
2828
}
2929

30+
virtual bool contains(const std::string& key) const override
31+
{
32+
return storage_.find(key) != storage_.end();
33+
}
34+
3035
private:
3136
std::unordered_map<std::string, SafeAny::Any> storage_;
3237
};

0 commit comments

Comments
 (0)