49 template <
size_t NUM_CASES>
70 template <
size_t NUM_CASES>
76 for(
unsigned i = 1; i <= NUM_CASES; i++)
82 template <
size_t NUM_CASES>
89 template <
size_t NUM_CASES>
94 ports.insert(BT::InputPort<std::string>(
"variable"));
95 for(
unsigned i = 1; i <= NUM_CASES; i++)
98 ports.insert(BT::InputPort<std::string>(key));
103 return provided_ports;
106 template <
size_t NUM_CASES>
109 if(childrenCount() != NUM_CASES + 1)
111 throw LogicError(
"Wrong number of children in SwitchNode; "
112 "must be (num_cases + default)");
115 std::string variable;
117 int match_index = int(NUM_CASES);
120 if(getInput(
"variable", variable))
123 for(
int index = 0; index < int(NUM_CASES); ++index)
125 const std::string& case_key = case_keys_[index];
126 if(getInput(case_key, value))
138 if(running_child_ != -1 && running_child_ != match_index)
140 haltChild(running_child_);
143 auto& selected_child = children_nodes_[match_index];
144 NodeStatus ret = selected_child->executeTick();
154 running_child_ = match_index;