You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add polymorphic shared_ptr port support (Issue #943) (#1107)
Enable passing shared_ptr<Derived> to ports expecting shared_ptr<Base>
without breaking ABI compatibility. Users register inheritance
relationships at runtime via BehaviorTreeFactory::registerPolymorphicCast,
and the system handles upcasting/downcasting transparently.
Key components:
- PolymorphicCastRegistry: thread-safe registry for inheritance
relationships with transitive cast support (e.g. Sphynx->Cat->Animal)
- BehaviorTreeFactory owns the registry, shares it with Blackboards
- Blackboard::tryCastWithPolymorphicFallback: public Expected-returning
API used by both Blackboard::get and TreeNode::getInputStamped
- XML parser validates port compatibility including polymorphic types
- Downcasts allowed at parse-time, checked at runtime via
dynamic_pointer_cast
Design decisions:
- Registry uses shared_mutex for read-heavy workload
- Error propagation via nonstd::expected<T, std::string>
- No circular includes: safe_any.hpp includes registry directly
- All polymorphic tests consolidated in gtest_polymorphic_ports.cpp
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
0 commit comments