Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,32 @@ void addNodeModelToXML(const TreeNodeManifest& model,
XMLElement* element = doc.NewElement(toStr(model.type).c_str());
element->SetAttribute("ID", model.registration_ID.c_str());

for (const auto& [port_name, port_info] : model.ports)
std::vector<std::string> ordered_ports;
PortDirection const directions[3] = {PortDirection::INPUT,
PortDirection::OUTPUT,
PortDirection::INOUT};
for (PortDirection direction: directions)
{
std::set<std::string> port_names;
for (auto& port : model.ports)
{
const auto& port_name = port.first;
const auto& port_info = port.second;
if (port_info.direction() == direction)
{
port_names.insert(port_name);
}
}
for (auto& port : port_names)
{
ordered_ports.push_back(port);
}
}

for (const auto& port_name : ordered_ports)
{
const auto& port_info = model.ports.at(port_name);

XMLElement* port_element = nullptr;
switch (port_info.direction())
{
Expand Down Expand Up @@ -1464,4 +1488,4 @@ std::string WriteTreeToXML(const Tree &tree, bool add_metadata, bool add_builtin
return std::string(printer.CStr(), size_t(printer.CStrSize() - 1));
}

} // namespace BT
} // namespace BT