@@ -350,6 +350,21 @@ class TypeInfo
350
350
template <typename T>
351
351
static TypeInfo Create ()
352
352
{
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
+ }
353
368
return TypeInfo{ typeid (T), GetAnyFromStringFunctor<T>() };
354
369
}
355
370
@@ -415,7 +430,8 @@ class PortInfo : public TypeInfo
415
430
default_value_str_ = BT::toStr (default_value);
416
431
}
417
432
catch (LogicError&)
418
- {}
433
+ {
434
+ }
419
435
}
420
436
421
437
[[nodiscard]] const std::string& description () const ;
@@ -452,7 +468,8 @@ template <typename T = AnyTypeAllowed>
452
468
}
453
469
else
454
470
{
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 ()) };
456
473
}
457
474
if (!description.empty ())
458
475
{
@@ -501,7 +518,6 @@ BidirectionalPort(StringView name, StringView description = {})
501
518
502
519
namespace details
503
520
{
504
-
505
521
template <typename T = AnyTypeAllowed, typename DefaultT = T>
506
522
[[nodiscard]] inline std::pair<std::string, PortInfo>
507
523
PortWithDefault (PortDirection direction, StringView name, const DefaultT& default_value,
@@ -614,14 +630,14 @@ struct has_static_method_metadata<
614
630
615
631
template <typename T>
616
632
[[nodiscard]] inline PortsList
617
- getProvidedPorts (enable_if<has_static_method_providedPorts<T>> = nullptr )
633
+ getProvidedPorts (enable_if<has_static_method_providedPorts<T>> = nullptr )
618
634
{
619
635
return T::providedPorts ();
620
636
}
621
637
622
638
template <typename T>
623
639
[[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 )
625
641
{
626
642
return {};
627
643
}
0 commit comments