From c1703f113b662fd260694184f1d78931410008cc Mon Sep 17 00:00:00 2001 From: RhysMcK Date: Mon, 29 Jul 2024 16:26:32 +1000 Subject: [PATCH] revert ordering logic in writeToXml() --- src/xml_parsing.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp index c91d2a4b8..972b6498e 100644 --- a/src/xml_parsing.cpp +++ b/src/xml_parsing.cpp @@ -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 ordered_ports; + PortDirection const directions[3] = {PortDirection::INPUT, + PortDirection::OUTPUT, + PortDirection::INOUT}; + for (PortDirection direction: directions) { + std::set 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()) { @@ -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 \ No newline at end of file