8 #include <unordered_map> 23 virtual const SafeAny::Any*
get(
const std::string& key)
const = 0;
24 virtual void set(
const std::string& key,
const SafeAny::Any& value) = 0;
25 virtual bool contains(
const std::string& key)
const = 0;
35 Blackboard(std::unique_ptr<BlackboardImpl> base) : impl_(
std::move(base))
40 typedef std::shared_ptr<Blackboard>
Ptr;
47 template <
typename ImplClass,
typename... Args>
50 std::unique_ptr<BlackboardImpl> base(
new ImplClass(args...));
51 return std::shared_ptr<Blackboard>(
new Blackboard(std::move(base)));
62 bool get(
const std::string& key, T& value)
const 74 value = val->
cast<T>();
84 return impl_->get(key);
89 T
get(
const std::string& key)
const 92 bool found =
get(key, value);
95 throw std::runtime_error(
"Missing key");
101 template <
typename T>
102 void set(
const std::string& key,
const T& value)
112 return (impl_ && impl_->contains(key));
116 std::unique_ptr<BlackboardImpl>
impl_;
120 #endif // BLACKBOARD_H
std::shared_ptr< Blackboard > Ptr
bool contains(const std::string &key) const
virtual bool contains(const std::string &key) const =0
static Blackboard::Ptr create(Args...args)
const SafeAny::Any * getAny(const std::string &key) const
Blackboard(std::unique_ptr< BlackboardImpl > base)
std::unique_ptr< BlackboardImpl > impl_
virtual ~BlackboardImpl()=default