Skip to content

Commit c28e462

Browse files
committedJan 17, 2024
fix issue #748 : static error messages
1 parent c3a04cf commit c28e462

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed
 

‎include/behaviortree_cpp/action_node.h

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class SyncActionNode : public ActionNodeBase
7575
*
7676
* Using lambdas or std::bind it is easy to pass a pointer to a method.
7777
* SimpleActionNode is executed synchronously and does not support halting.
78-
* NodeParameters aren't supported.
7978
*/
8079
class SimpleActionNode : public SyncActionNode
8180
{

‎include/behaviortree_cpp/bt_factory.h

+21-16
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,27 @@ class BehaviorTreeFactory
358358
template <typename T, typename... ExtraArgs>
359359
void registerNodeType(const std::string& ID, ExtraArgs... args)
360360
{
361-
// check first if the given class is abstract
362-
static_assert(!std::is_abstract_v<T>, "The given type can't be abstract");
363-
364-
constexpr bool param_constructable =
365-
std::is_constructible<T, const std::string&, const NodeConfig&, ExtraArgs...>::value;
366-
constexpr bool has_static_ports_list = has_static_method_providedPorts<T>::value;
367-
368-
// clang-format off
369-
static_assert(!(param_constructable && !has_static_ports_list),
370-
"[registerNode]: you MUST implement the static method:\n"
371-
" PortsList providedPorts();\n");
372-
373-
static_assert(!(has_static_ports_list && !param_constructable),
374-
"[registerNode]: since you have a static method providedPorts(),\n"
375-
"you MUST add a constructor with signature:\n"
376-
"(const std::string&, const NodeParameters&)\n");
361+
if constexpr(std::is_abstract_v<T>) {
362+
// check first if the given class is abstract
363+
static_assert(!std::is_abstract_v<T>, "The Node type can't be abstract. "
364+
"Did you forget to implement an abstract "
365+
"method in the derived class?");
366+
}
367+
else {
368+
constexpr bool param_constructable =
369+
std::is_constructible<T, const std::string&, const NodeConfig&, ExtraArgs...>::value;
370+
constexpr bool has_static_ports_list = has_static_method_providedPorts<T>::value;
371+
372+
// clang-format off
373+
static_assert(!(param_constructable && !has_static_ports_list),
374+
"[registerNode]: you MUST implement the static method:\n"
375+
" PortsList providedPorts();\n");
376+
377+
static_assert(!(has_static_ports_list && !param_constructable),
378+
"[registerNode]: since you have a static method providedPorts(),\n"
379+
"you MUST add a constructor with signature:\n"
380+
"(const std::string&, const NodeConfig&)\n");
381+
}
377382
// clang-format on
378383
registerNodeType<T>(ID, getProvidedPorts<T>(), args...);
379384
}

‎include/behaviortree_cpp/condition_node.h

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ConditionNode : public LeafNode
4646
* This avoids the hassle of inheriting from a ActionNode.
4747
*
4848
* Using lambdas or std::bind it is easy to pass a pointer to a method.
49-
* SimpleConditionNode does not support halting, NodeParameters, nor Blackboards.
5049
*/
5150
class SimpleConditionNode : public ConditionNode
5251
{

‎include/behaviortree_cpp/decorator_node.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class DecoratorNode : public TreeNode
4848
* This avoids the hassle of inheriting from a DecoratorNode.
4949
*
5050
* Using lambdas or std::bind it is easy to pass a pointer to a method.
51-
* SimpleDecoratorNode does not support halting, NodeParameters, nor Blackboards.
5251
*/
5352
class SimpleDecoratorNode : public DecoratorNode
5453
{

‎src/xml_parsing.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
711711
{
712712
throw RuntimeError("Possible typo? In the XML, you tried to remap port \"",
713713
name_in_subtree, "\" in node [", config.path, "(type ", type_ID,
714-
")], but the manifest of this node does not contain a port "
714+
")], but the manifest/model of this node does not contain a port "
715715
"with this name.");
716716
}
717717
}

‎tools/bt_plugin_manifest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(int argc, char* argv[])
3333
auto& params = manifest.ports;
3434
std::cout << "---------------\n"
3535
<< manifest.registration_ID << " [" << manifest.type
36-
<< "]\n NodeParameters: " << params.size();
36+
<< "]\n NodeConfig: " << params.size();
3737

3838
if (params.size() > 0)
3939
{

0 commit comments

Comments
 (0)