Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36e614e

Browse files
committed
adding TreeNode::modifyPortsRemapping that might be useful in the future
1 parent e96865d commit 36e614e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

include/behaviortree_cpp/tree_node.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TreeNode
5959
* @brief TreeNode main constructor.
6060
*
6161
* @param name name of the instance, not the type.
62-
* @param config information about input/outpu ports. See NodeConfiguration
62+
* @param config information about input/output ports. See NodeConfiguration
6363
*
6464
* Note: If your custom node has ports, the derived class must implement:
6565
*
@@ -160,6 +160,8 @@ class TreeNode
160160
registration_ID_.assign(ID.data(), ID.size());
161161
}
162162

163+
void modifyPortsRemapping(const PortsRemapping& new_remapping);
164+
163165
private:
164166
const std::string name_;
165167

@@ -173,7 +175,7 @@ class TreeNode
173175

174176
const uint16_t uid_;
175177

176-
const NodeConfiguration config_;
178+
NodeConfiguration config_;
177179

178180
std::string registration_ID_;
179181
};

src/tree_node.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,21 @@ Optional<StringView> TreeNode::getRemappedKey(StringView port_name, StringView r
144144
return nonstd::make_unexpected("Not a blackboard pointer");
145145
}
146146

147+
void TreeNode::modifyPortsRemapping(const PortsRemapping &new_remapping)
148+
{
149+
for (const auto& new_it: new_remapping)
150+
{
151+
auto it = config_.input_ports.find( new_it.first );
152+
if( it != config_.input_ports.end() )
153+
{
154+
it->second = new_it.second;
155+
}
156+
it = config_.output_ports.find( new_it.first );
157+
if( it != config_.output_ports.end() )
158+
{
159+
it->second = new_it.second;
160+
}
161+
}
162+
}
163+
147164
} // end namespace

0 commit comments

Comments
 (0)