Skip to content

Commit 0aa9cda

Browse files
committed
Add PortInfo constructors that accept TypeInfo for cleaner initialization
Simplifies PortInfo creation by directly accepting TypeInfo objects, allowing reuse of TypeInfo::Create<T>() without redundant field extraction.
1 parent 24fdf21 commit 0aa9cda

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/behaviortree_cpp/basic_types.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ class PortInfo : public TypeInfo
442442
: TypeInfo(type_info, conv), direction_(direction)
443443
{}
444444

445+
PortInfo(PortDirection direction, const TypeInfo& type_info)
446+
: TypeInfo(type_info), direction_(direction)
447+
{}
448+
449+
PortInfo(PortDirection direction, TypeInfo&& type_info)
450+
: TypeInfo(std::move(type_info)), direction_(direction)
451+
{}
452+
445453
[[nodiscard]] PortDirection direction() const;
446454

447455
void setDescription(StringView description);
@@ -493,7 +501,7 @@ template <typename T = AnyTypeAllowed>
493501
else
494502
{
495503
auto type_info = TypeInfo::Create<T>();
496-
out = { sname, PortInfo(direction, type_info.type(), type_info.converter()) };
504+
out = { sname, PortInfo(direction, std::move(type_info)) };
497505
}
498506
if(!description.empty())
499507
{

0 commit comments

Comments
 (0)