Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9eddc31

Browse files
committed
1 parent 47be420 commit 9eddc31

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

include/behaviortree_cpp_v3/controls/switch_node.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2020-2020 Davide Faconti - All Rights Reserved
1+
/* Copyright (C) 2020 Davide Faconti - All Rights Reserved
22
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
44
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -18,7 +18,26 @@
1818
namespace BT
1919
{
2020
/**
21-
* @brief The SwitchNode
21+
* @brief The SwitchNode is equivalent to a switch statement, where a certain
22+
* branch (child) is executed according to the value of a blackboard entry.
23+
*
24+
* Note that the same behaviour can be achieved with multiple Sequences, Fallbacks and
25+
* Conditions reading the blackboard, but switch is shorter and more readable.
26+
*
27+
* Example usage:
28+
*
29+
30+
<Switch3 variable="{var}" case_1="1" case_2="42" case_3="666" >
31+
<ActionA name="action_when_var_eq_1" />
32+
<ActionB name="action_when_var_eq_42" />
33+
<ActionC name="action_when_var_eq_666" />
34+
<ActionD name="default_action" />
35+
</Switch3>
36+
37+
When the SwitchNode is executed (Switch3 is a node with 3 cases)
38+
the "variable" will be compared to the cases and execute the correct child
39+
or the default one (last).
40+
2241
*
2342
*/
2443
template <size_t NUM_CASES>

0 commit comments

Comments
 (0)