14
14
#include < list>
15
15
16
16
#if defined(__linux) || defined(__linux__)
17
- #pragma GCC diagnostic push
18
- #pragma GCC diagnostic ignored "-Wattributes"
19
- #endif
17
+ #pragma GCC diagnostic push
18
+ #pragma GCC diagnostic ignored "-Wattributes"
19
+ #endif
20
20
21
21
#ifdef _MSC_VER
22
22
#pragma warning(disable : 4996) // do not complain about sprintf
@@ -352,7 +352,7 @@ void VerifyXML(const std::string& xml_text,
352
352
}
353
353
// recursion
354
354
if (StrEqual (name, " SubTree" ) == false )
355
- {
355
+ {
356
356
for (auto child = node->FirstChildElement (); child != nullptr ;
357
357
child = child->NextSiblingElement ())
358
358
{
@@ -462,23 +462,22 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement *element,
462
462
instance_name = ID;
463
463
}
464
464
465
+ PortsRemapping port_remap;
466
+
465
467
if (element_name == " SubTree" ||
466
- element_name == " SubTreePlus" )
468
+ element_name == " SubTreePlus" ||
469
+ element_name == " RemappedSubTree" )
467
470
{
468
471
instance_name = element->Attribute (" ID" );
469
472
}
470
-
471
- PortsRemapping parameters_map;
472
-
473
- // in Subtree attributes have different meaning...
474
- if (element_name != " SubTree" && element_name != " SubTreePlus" )
475
- {
473
+ else {
474
+ // do this only if it NOT a Subtree
476
475
for (const XMLAttribute* att = element->FirstAttribute (); att; att = att->Next ())
477
476
{
478
477
const std::string attribute_name = att->Name ();
479
478
if (attribute_name != " ID" && attribute_name != " name" )
480
479
{
481
- parameters_map [attribute_name] = att->Value ();
480
+ port_remap [attribute_name] = att->Value ();
482
481
}
483
482
}
484
483
}
@@ -493,12 +492,12 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement *element,
493
492
const auto & manifest = factory.manifests ().at (ID);
494
493
495
494
// Check that name in remapping can be found in the manifest
496
- for (const auto & param_it: parameters_map )
495
+ for (const auto & remap_it: port_remap )
497
496
{
498
- if ( manifest.ports .count ( param_it .first ) == 0 )
497
+ if ( manifest.ports .count ( remap_it .first ) == 0 )
499
498
{
500
499
throw RuntimeError (" Possible typo? In the XML, you tried to remap port \" " ,
501
- param_it .first , " \" in node [" , ID," / " , instance_name,
500
+ remap_it .first , " \" in node [" , ID," / " , instance_name,
502
501
" ], but the manifest of this node does not contain a port with this name." );
503
502
}
504
503
}
@@ -509,8 +508,8 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement *element,
509
508
const std::string& port_name = port_it.first ;
510
509
const auto & port_info = port_it.second ;
511
510
512
- auto remap_it = parameters_map .find (port_name);
513
- if ( remap_it == parameters_map .end ())
511
+ auto remap_it = port_remap .find (port_name);
512
+ if ( remap_it == port_remap .end ())
514
513
{
515
514
continue ;
516
515
}
@@ -543,20 +542,20 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement *element,
543
542
}
544
543
545
544
// use manifest to initialize NodeConfiguration
546
- for (const auto & param_it: parameters_map )
545
+ for (const auto & remap_it: port_remap )
547
546
{
548
- const auto & port_name = param_it .first ;
547
+ const auto & port_name = remap_it .first ;
549
548
auto port_it = manifest.ports .find ( port_name );
550
549
if ( port_it != manifest.ports .end () )
551
550
{
552
551
auto direction = port_it->second .direction ();
553
552
if ( direction != PortDirection::OUTPUT )
554
553
{
555
- config.input_ports .insert ( param_it );
554
+ config.input_ports .insert ( remap_it );
556
555
}
557
556
if ( direction != PortDirection::INPUT )
558
557
{
559
- config.output_ports .insert ( param_it );
558
+ config.output_ports .insert ( remap_it );
560
559
}
561
560
}
562
561
}
@@ -612,7 +611,11 @@ void BT::XMLParser::Pimpl::recursivelyCreateTree(const std::string& tree_ID,
612
611
613
612
if ( node->type () == NodeType::SUBTREE )
614
613
{
615
- if ( dynamic_cast <const SubtreeNode*>(node.get ()) )
614
+ if ( dynamic_cast <const RemappedSubtreeNode*>(node.get ()) )
615
+ {
616
+ recursivelyCreateTree ( node->name (), output_tree, blackboard, node );
617
+ }
618
+ else if ( dynamic_cast <const SubtreeNode*>(node.get ()) )
616
619
{
617
620
// This is the former SubTree with manual remapping
618
621
auto new_bb = Blackboard::create (blackboard);
@@ -630,7 +633,7 @@ void BT::XMLParser::Pimpl::recursivelyCreateTree(const std::string& tree_ID,
630
633
}
631
634
else if ( dynamic_cast <const SubtreePlusNode*>(node.get ()) )
632
635
{
633
- auto new_bb = Blackboard::create (blackboard);
636
+ auto new_bb = Blackboard::create (blackboard);
634
637
output_tree.blackboard_stack .emplace_back (new_bb);
635
638
std::set<StringView> mapped_keys;
636
639
0 commit comments