@@ -350,6 +350,21 @@ class TypeInfo
350350 template <typename T>
351351 static TypeInfo Create ()
352352 {
353+ // store the base class typeid if specialized
354+ if constexpr (is_shared_ptr<T>::value)
355+ {
356+ using Elem = typename T::element_type;
357+ using Base = typename any_cast_base<Elem>::type;
358+
359+ if constexpr (!std::is_same_v<Base, void >)
360+ {
361+ static_assert (std::is_polymorphic_v<Base>, " TypeInfo Base trait specialization "
362+ " must be "
363+ " polymorphic" );
364+ return TypeInfo{ typeid (std::shared_ptr<Base>),
365+ GetAnyFromStringFunctor<std::shared_ptr<Base>>() };
366+ }
367+ }
353368 return TypeInfo{ typeid (T), GetAnyFromStringFunctor<T>() };
354369 }
355370
@@ -415,7 +430,8 @@ class PortInfo : public TypeInfo
415430 default_value_str_ = BT::toStr (default_value);
416431 }
417432 catch (LogicError&)
418- {}
433+ {
434+ }
419435 }
420436
421437 [[nodiscard]] const std::string& description () const ;
@@ -452,7 +468,8 @@ template <typename T = AnyTypeAllowed>
452468 }
453469 else
454470 {
455- out = { sname, PortInfo (direction, typeid (T), GetAnyFromStringFunctor<T>()) };
471+ auto type_info = TypeInfo::Create<T>();
472+ out = { sname, PortInfo (direction, type_info.type (), type_info.converter ()) };
456473 }
457474 if (!description.empty ())
458475 {
@@ -501,7 +518,6 @@ BidirectionalPort(StringView name, StringView description = {})
501518
502519namespace details
503520{
504-
505521template <typename T = AnyTypeAllowed, typename DefaultT = T>
506522[[nodiscard]] inline std::pair<std::string, PortInfo>
507523PortWithDefault (PortDirection direction, StringView name, const DefaultT& default_value,
@@ -614,14 +630,14 @@ struct has_static_method_metadata<
614630
615631template <typename T>
616632[[nodiscard]] inline PortsList
617- getProvidedPorts (enable_if<has_static_method_providedPorts<T>> = nullptr )
633+ getProvidedPorts (enable_if<has_static_method_providedPorts<T>> = nullptr )
618634{
619635 return T::providedPorts ();
620636}
621637
622638template <typename T>
623639[[nodiscard]] inline PortsList
624- getProvidedPorts (enable_if_not<has_static_method_providedPorts<T>> = nullptr )
640+ getProvidedPorts (enable_if_not<has_static_method_providedPorts<T>> = nullptr )
625641{
626642 return {};
627643}
0 commit comments