Skip to content

Commit 5596408

Browse files
committed
address comments
1 parent 2a0f48f commit 5596408

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/xml_parsing.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
645645
const auto element_name = element->Name();
646646
const auto element_ID = element->Attribute("ID");
647647

648-
// TODO: Pull out this node type logic
649648
auto node_type = convertFromString<NodeType>(element_name);
650649
// name used by the factory
651650
std::string type_ID;
@@ -690,8 +689,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
690689

691690
PortsRemapping port_remap;
692691
NonPortAttributes other_attributes;
693-
// Only relevant for subtrees
694-
bool do_autoremap = false;
695692

696693
// Parse ports and validate them where we can.
697694
for(const XMLAttribute* att = element->FirstAttribute(); att; att = att->Next())
@@ -739,16 +736,22 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
739736

740737
port_remap[port_name] = port_value;
741738
}
742-
else if(node_type == NodeType::SUBTREE && port_name == "_autoremap")
743-
{
744-
do_autoremap = convertFromString<bool>(port_value);
745-
}
746739
else if(!IsReservedAttribute(port_name))
747740
{
748741
other_attributes[port_name] = port_value;
749742
}
750743
}
751744

745+
bool do_autoremap = false;
746+
if(node_type == NodeType::SUBTREE)
747+
{
748+
const XMLAttribute* auto_remap_ptr = element->FindAttribute("_autoremap");
749+
if(auto_remap_ptr != nullptr)
750+
{
751+
do_autoremap = convertFromString<bool>(auto_remap_ptr->Value());
752+
}
753+
}
754+
752755
NodeConfig config;
753756
config.blackboard = blackboard;
754757
config.path = prefix_path + instance_name;
@@ -784,7 +787,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
784787
//---------------------------------------------
785788
TreeNode::Ptr new_node;
786789

787-
// TODO: in order to set the config at this point, we need the subtree model, which is parsed after this function call in recursivelyCreateSubtree
788790
if(node_type == NodeType::SUBTREE)
789791
{
790792
// check if this subtree has a model. If it does,
@@ -818,7 +820,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
818820
// populate the node config
819821
for(const auto& [port_name, port_value] : port_remap)
820822
{
821-
PortDirection direction = PortDirection::INPUT;
823+
auto direction = PortDirection::INPUT;
822824
if(subtree_model_it != subtree_models.end())
823825
{
824826
const PortsList& subtree_model_ports = subtree_model_it->second.ports;
@@ -1019,7 +1021,7 @@ void BT::XMLParser::PImpl::recursivelyCreateSubtree(const std::string& tree_ID,
10191021

10201022
// Populate the subtree's blackboard with it's port values.
10211023
PortsRemapping subtree_remapping = const_node->config().input_ports;
1022-
const PortsRemapping output_ports = const_node->config().output_ports;
1024+
const PortsRemapping& output_ports = const_node->config().output_ports;
10231025
subtree_remapping.insert(output_ports.begin(), output_ports.end());
10241026
for(const auto& [port_name, port_value] : subtree_remapping)
10251027
{

0 commit comments

Comments
 (0)