42 template <
size_t NUM_CASES>
63 ports.insert(BT::InputPort<std::string>(
"variable"));
64 for (
unsigned i = 0; i < NUM_CASES; i++)
67 sprintf(case_str,
"case_%d", i + 1);
68 ports.insert(BT::InputPort<std::string>(case_str));
78 template <
size_t NUM_CASES>
83 throw LogicError(
"Wrong number of children in SwitchNode; " 84 "must be (num_cases + default)");
89 int match_index = int(NUM_CASES);
94 for (
int index = 0; index < int(NUM_CASES); ++index)
97 sprintf(case_key,
"case_%d",
int(index + 1));
98 bool found =
static_cast<bool>(
getInput(case_key, value));
100 if (found && variable == value)
115 NodeStatus ret = selected_child->executeTick();
std::vector< TreeNode * > children_nodes_
virtual void halt() override
const NodeConfiguration & config() const
SwitchNode(const std::string &name, const BT::NodeConfiguration &config)
size_t childrenCount() const
const std::string & name() const
Name of the instance, not the type.
The SwitchNode is equivalent to a switch statement, where a certain branch (child) is executed accord...
Result getInput(const std::string &key, T &destination) const
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
std::unordered_map< std::string, PortInfo > PortsList
static PortsList providedPorts()
virtual ~SwitchNode() override=default
void setRegistrationID(StringView ID)