@@ -65,42 +65,17 @@ class Blackboard
65
65
66
66
[[nodiscard]] const Entry* getEntry (const std::string& key) const ;
67
67
68
- [[nodiscard]] Entry* getEntry (const std::string& key)
69
- {
70
- // "Avoid Duplication in const and Non-const Member Function,"
71
- // on p. 23, in Item 3 "Use const whenever possible," in Effective C++, 3d ed
72
- return const_cast <Entry*>( static_cast <const Blackboard &>(*this ).getEntry (key));
73
- }
68
+ [[nodiscard]] Entry* getEntry (const std::string& key);
74
69
75
- [[nodiscard]] AnyPtrLocked getAnyLocked (const std::string& key)
76
- {
77
- if (auto entry = getEntry (key))
78
- {
79
- return AnyPtrLocked (&entry->value , &entry->entry_mutex );
80
- }
81
- return {};
82
- }
70
+ [[nodiscard]] AnyPtrLocked getAnyLocked (const std::string& key);
83
71
84
- [[nodiscard]] AnyPtrLocked getAnyLocked (const std::string& key) const
85
- {
86
- if (auto entry = getEntry (key))
87
- {
88
- return AnyPtrLocked (&entry->value , const_cast <std::mutex*>(&entry->entry_mutex ));
89
- }
90
- return {};
91
- }
72
+ [[nodiscard]] AnyPtrLocked getAnyLocked (const std::string& key) const ;
92
73
93
74
[[deprecated(" Use getAnyLocked instead" )]]
94
- const Any* getAny (const std::string& key) const
95
- {
96
- return getAnyLocked (key).get ();
97
- }
75
+ const Any* getAny (const std::string& key) const ;
98
76
99
77
[[deprecated(" Use getAnyLocked instead" )]]
100
- Any* getAny (const std::string& key)
101
- {
102
- return const_cast <Any*>(getAnyLocked (key).get ());
103
- }
78
+ Any* getAny (const std::string& key);
104
79
105
80
/* * Return true if the entry with the given key was found.
106
81
* Note that this method may throw an exception if the cast to T failed.
@@ -218,22 +193,12 @@ class Blackboard
218
193
219
194
[[nodiscard]] std::vector<StringView> getKeys () const ;
220
195
221
- void clear ()
222
- {
223
- std::unique_lock<std::mutex> lock (mutex_);
224
- storage_.clear ();
225
- }
196
+ void clear ();
226
197
227
198
[[deprecated(" Use getAnyLocked to access safely an Entry" )]]
228
- std::recursive_mutex& entryMutex () const
229
- {
230
- return entry_mutex_;
231
- }
199
+ std::recursive_mutex& entryMutex () const ;
232
200
233
- void createEntry (const std::string& key, const PortInfo& info)
234
- {
235
- createEntryImpl (key, info);
236
- }
201
+ void createEntry (const std::string& key, const PortInfo& info);
237
202
238
203
private:
239
204
mutable std::mutex mutex_;
0 commit comments