Skip to content

Commit

Permalink
simplify srv template to allow vector<bool>
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Kermorgant <[email protected]>
  • Loading branch information
oKermorgant committed Jul 27, 2023
1 parent e310440 commit f29f80d
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions resource/interface_factories.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -306,26 +306,18 @@ void ServiceFactory<
@[ for field in service["fields"][type.lower()]]@
@[ if field["array"]]@
req@(to).@(field["ros" + to]["name"]).resize(req@(frm).@(field["ros" + frm]["name"]).size());
auto @(field["ros1"]["name"])1_it = req1.@(field["ros1"]["name"]).begin();
auto @(field["ros2"]["name"])2_it = req2.@(field["ros2"]["name"]).begin();
while (
@(field["ros1"]["name"])1_it != req1.@(field["ros1"]["name"]).end() &&
@(field["ros2"]["name"])2_it != req2.@(field["ros2"]["name"]).end()
) {
auto & @(field["ros1"]["name"])1 = *(@(field["ros1"]["name"])1_it++);
auto & @(field["ros2"]["name"])2 = *(@(field["ros2"]["name"])2_it++);
@[ else]@
auto & @(field["ros1"]["name"])1 = req1.@(field["ros1"]["name"]);
auto & @(field["ros2"]["name"])2 = req2.@(field["ros2"]["name"]);
@[ end if]@
@[ if field["basic"]]@
@(field["ros2"]["name"])@(to) = @(field["ros1"]["name"])@(frm);
for ( size_t i = 0; i < req1.@(field["ros1"]["name"]).size(); ++i)
@[ if field["basic"]]@
req@(to).@(field["ros" + to]["name"])[i] = req@(frm).@(field["ros" + frm]["name"])[i];
@[ else]@
Factory<@(field["ros1"]["cpptype"]),@(field["ros2"]["cpptype"])>::convert_@(frm)_to_@(to)(@
req@(frm).@(field["ros" + frm]["name"])[i], req@(to).@(field["ros" + to]["name"])[i]);
@[ end if]@
@[ elif field["basic"]]@
req@(to).@(field["ros" + to]["name"]) = req@(frm).@(field["ros" + frm]["name"]);
@[ else]@
Factory<@(field["ros1"]["cpptype"]),@(field["ros2"]["cpptype"])>::convert_@(frm)_to_@(to)(@
@(field["ros2"]["name"])@(frm), @(field["ros1"]["name"])@(to));
@[ end if]@
@[ if field["array"]]@
}
req@(frm).@(field["ros" + frm]["name"]), req@(to).@(field["ros" + to]["name"]));
@[ end if]@
@[ end for]@
}
Expand Down

0 comments on commit f29f80d

Please sign in to comment.