MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / parseSubtreeModelPorts

Function parseSubtreeModelPorts

src/xml_parsing.cpp:191–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189};
190
191void parseSubtreeModelPorts(const XMLElement* sub_node, SubtreeModel& subtree_model)
192{
193 const std::pair<const char*, PortDirection> port_types[3] = {
194 { "input_port", PortDirection::INPUT },
195 { "output_port", PortDirection::OUTPUT },
196 { "inout_port", PortDirection::INOUT }
197 };
198
199 for(const auto& [name, direction] : port_types)
200 {
201 for(auto port_node = sub_node->FirstChildElement(name); port_node != nullptr;
202 port_node = port_node->NextSiblingElement(name))
203 {
204 PortInfo port(direction);
205 auto port_name = port_node->Attribute("name");
206 if(port_name == nullptr)
207 {
208 throw RuntimeError("Missing attribute [name] in port (SubTree model)");
209 }
210 validatePortName(port_name, port_node->GetLineNum());
211 if(auto default_value = port_node->Attribute("default"))
212 {
213 port.setDefaultValue(default_value);
214 }
215 if(auto description = port_node->Attribute("description"))
216 {
217 port.setDescription(description);
218 }
219 subtree_model.ports[port_name] = std::move(port);
220 }
221 }
222}
223
224} // namespace
225

Callers 1

loadSubtreeModelMethod · 0.85

Calls 8

RuntimeErrorClass · 0.85
validatePortNameFunction · 0.85
moveFunction · 0.85
FirstChildElementMethod · 0.80
NextSiblingElementMethod · 0.80
AttributeMethod · 0.80
setDefaultValueMethod · 0.80
setDescriptionMethod · 0.80

Tested by

no test coverage detected