File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ class Blackboard
56
56
/* * Return true if the entry with the given key was found.
57
57
* Note that this method may throw an exception if the cast to T failed.
58
58
*
59
- * return true is succesful
59
+ * return true if succesful
60
60
*/
61
61
template <typename T>
62
62
bool get (const std::string& key, T& value) const
@@ -75,20 +75,13 @@ class Blackboard
75
75
return true ;
76
76
}
77
77
78
- template <typename T>
79
- bool get (const std::string& key, const SafeAny::Any* value) const
78
+ const SafeAny::Any* getAny (const std::string& key) const
80
79
{
81
80
if (!impl_)
82
81
{
83
- return false ;
84
- }
85
- const SafeAny::Any* val = impl_->get (key);
86
- if (!val)
87
- {
88
- return false ;
82
+ return nullptr ;
89
83
}
90
- value = val;
91
- return true ;
84
+ return impl_->get (key);
92
85
}
93
86
94
87
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class TreeNode
138
138
bool bb_pattern = isBlackboardPattern (str);
139
139
if ( bb_pattern && just_constructed_)
140
140
{
141
- std::cerr << " you are calling getParam inside a constructor, but this is not allowed "
141
+ std::cerr << " You are calling getParam inside a constructor, but this is not allowed "
142
142
" when the parameter contains a blackboard.\n "
143
143
" You should call getParam inside your tick() method" << std::endl;
144
144
std::logic_error (" Calling getParam inside a constructor" );
@@ -147,9 +147,9 @@ class TreeNode
147
147
if ( bb_ && bb_pattern)
148
148
{
149
149
const std::string stripped_key (&str[2 ], str.size () - 3 );
150
- const SafeAny::Any* val;
151
- bool found = bb_-> get (stripped_key, val);
152
- if ( found )
150
+ const SafeAny::Any* val = bb_-> getAny (stripped_key) ;
151
+
152
+ if ( val )
153
153
{
154
154
if ( std::is_same<T,std::string>::value == false &&
155
155
(val->type () == typeid (std::string) ||
@@ -161,7 +161,7 @@ class TreeNode
161
161
destination = val->cast <T>();
162
162
}
163
163
}
164
- return found ;
164
+ return val != nullptr ;
165
165
}
166
166
else {
167
167
destination = convertFromString<T>(str.c_str ());
You can’t perform that action at this time.
0 commit comments