@@ -1064,8 +1064,32 @@ void addNodeModelToXML(const TreeNodeManifest& model, XMLDocument& doc,
10641064 XMLElement* element = doc.NewElement (toStr (model.type ).c_str ());
10651065 element->SetAttribute (" ID" , model.registration_ID .c_str ());
10661066
1067- for (const auto & [port_name, port_info] : model.ports )
1067+ std::vector<std::string> ordered_ports;
1068+ PortDirection const directions[3 ] = {PortDirection::INPUT,
1069+ PortDirection::OUTPUT,
1070+ PortDirection::INOUT};
1071+ for (PortDirection direction: directions)
10681072 {
1073+ std::set<std::string> port_names;
1074+ for (auto & port : model.ports )
1075+ {
1076+ const auto & port_name = port.first ;
1077+ const auto & port_info = port.second ;
1078+ if (port_info.direction () == direction)
1079+ {
1080+ port_names.insert (port_name);
1081+ }
1082+ }
1083+ for (auto & port : port_names)
1084+ {
1085+ ordered_ports.push_back (port);
1086+ }
1087+ }
1088+
1089+ for (const auto & port_name : ordered_ports)
1090+ {
1091+ const auto & port_info = model.ports .at (port_name);
1092+
10691093 XMLElement* port_element = nullptr ;
10701094 switch (port_info.direction ())
10711095 {
@@ -1544,4 +1568,4 @@ std::string WriteTreeToXML(const Tree& tree, bool add_metadata, bool add_builtin
15441568 return std::string (printer.CStr (), size_t (printer.CStrSize () - 1 ));
15451569}
15461570
1547- } // namespace BT
1571+ } // namespace BT
0 commit comments