@@ -45,71 +45,51 @@ Any* Blackboard::getAny(const std::string& key)
4545const std::shared_ptr<Blackboard::Entry>
4646Blackboard::getEntry (const std::string& key) const
4747{
48- std::unique_lock<std::mutex> lock (mutex_);
49- auto it = storage_.find (key);
50- if (it != storage_.end ())
48+ // special syntax: "@" will always refer to the root BB
49+ if (StartWith (key, ' @' ))
5150 {
52- return it->second ;
53- }
54- // not found. Try autoremapping
55- if (auto parent = parent_bb_.lock ())
56- {
57- auto remap_it = internal_to_external_.find (key);
58- if (remap_it != internal_to_external_.cend ())
51+ if (auto parent = parent_bb_.lock ())
5952 {
60- auto const & new_key = remap_it->second ;
61- return parent->getEntry (new_key);
53+ return parent->getEntry (key);
6254 }
63- if (autoremapping_ && ! IsPrivateKey (key))
55+ else
6456 {
65- return parent-> getEntry (key);
57+ return getEntry (key. substr ( 1 , key. size () - 1 ) );
6658 }
6759 }
68- return {};
69- }
7060
71- std::shared_ptr<Blackboard::Entry> Blackboard::getEntry (const std::string& key)
72- {
7361 std::unique_lock<std::mutex> lock (mutex_);
7462 auto it = storage_.find (key);
7563 if (it != storage_.end ())
7664 {
7765 return it->second ;
7866 }
79-
8067 // not found. Try autoremapping
8168 if (auto parent = parent_bb_.lock ())
8269 {
8370 auto remap_it = internal_to_external_.find (key);
8471 if (remap_it != internal_to_external_.cend ())
8572 {
8673 auto const & new_key = remap_it->second ;
87- auto entry = parent->getEntry (new_key);
88- if (entry)
89- {
90- storage_.insert ({ key, entry });
91- }
92- return entry;
74+ return parent->getEntry (new_key);
9375 }
9476 if (autoremapping_ && !IsPrivateKey (key))
9577 {
96- auto entry = parent->getEntry (key);
97- if (entry)
98- {
99- storage_.insert ({ key, entry });
100- }
101- return entry;
78+ return parent->getEntry (key);
10279 }
10380 }
10481 return {};
10582}
10683
107- const TypeInfo* Blackboard::entryInfo (const std::string& key)
84+ std::shared_ptr<Blackboard::Entry> Blackboard::getEntry (const std::string& key)
10885{
109- std::unique_lock<std::mutex> lock (mutex_);
86+ return static_cast <const Blackboard&>(*this ).getEntry (key);
87+ }
11088
111- auto it = storage_.find (key);
112- return (it == storage_.end ()) ? nullptr : &(it->second ->info );
89+ const TypeInfo* Blackboard::entryInfo (const std::string& key)
90+ {
91+ auto entry = getEntry (key);
92+ return (!entry) ? nullptr : &(entry->info );
11393}
11494
11595void Blackboard::addSubtreeRemapping (StringView internal, StringView external)
@@ -167,7 +147,21 @@ std::recursive_mutex& Blackboard::entryMutex() const
167147
168148void Blackboard::createEntry (const std::string& key, const TypeInfo& info)
169149{
170- createEntryImpl (key, info);
150+ if (StartWith (key, ' @' ))
151+ {
152+ if (auto parent = parent_bb_.lock ())
153+ {
154+ parent->createEntry (key, info);
155+ }
156+ else
157+ {
158+ createEntryImpl (key.substr (1 , key.size () - 1 ), info);
159+ }
160+ }
161+ else
162+ {
163+ createEntryImpl (key, info);
164+ }
171165}
172166
173167void Blackboard::cloneInto (Blackboard& dst) const
0 commit comments