Skip to content

Commit 66bd8a1

Browse files
committed
Pass the entire binding name instead of just a suffix for the Behavior class bindings
1 parent 584563d commit 66bd8a1

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/arbitration_graphs/internal/behavior_py.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class PyBehavior : public Behavior<CommandT> {
5353
};
5454

5555
template <typename CommandT>
56-
void bindBehavior(py::module& module, const std::string& suffix = "") {
56+
void bindBehavior(py::module& module, const std::string& bindingName = "Behavior") {
5757
using BehaviorT = Behavior<CommandT>;
5858
using PyBehaviorT = PyBehavior<CommandT>;
5959

60-
py::class_<BehaviorT, PyBehaviorT, std::shared_ptr<BehaviorT>>(module, ("Behavior" + suffix).c_str())
60+
py::class_<BehaviorT, PyBehaviorT, std::shared_ptr<BehaviorT>>(module, bindingName.c_str())
6161
.def(py::init<const std::string&>(), py::arg("name") = "Behavior")
6262
.def("get_command", &BehaviorT::getCommand, py::arg("time"))
6363
.def("check_invocation_condition", &BehaviorT::checkInvocationCondition, py::arg("time"))

include/arbitration_graphs/python_bindings.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ template <typename CommandT,
2121
typename VerifierT = verification::PlaceboVerifier<SubCommandT>,
2222
typename VerificationResultT = typename decltype(std::function{VerifierT::analyze})::result_type>
2323
void bindArbitrationGraphs(py::module& module,
24-
const std::string& behaviorCommandSuffix = "",
25-
const std::string& behaviorSubCommandSuffix = "") {
24+
const std::string& behaviorBindingName = "Behavior",
25+
const std::string& behaviorSubCommandBindingName = "BehaviorSubCommand") {
2626
bindExceptions(module);
2727
bindPlaceboVerifier<SubCommandT>(module);
2828

29-
bindBehavior<CommandT>(module, behaviorCommandSuffix);
30-
// Only bind behavior for SubCommandT if it is different from CommandT
29+
bindBehavior<CommandT>(module, behaviorBindingName);
30+
// Bind the behavior for the SubCommandT only if it is different from the CommandT
3131
if constexpr (!std::is_same_v<CommandT, SubCommandT>) {
32-
bindBehavior<SubCommandT>(module, behaviorSubCommandSuffix);
32+
bindBehavior<SubCommandT>(module, behaviorSubCommandBindingName);
3333
}
3434

3535
bindArbitrator<CommandT, SubCommandT, VerifierT, VerificationResultT>(module);

test/python_bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ PYBIND11_MODULE(arbitration_graphs_py, mainModule) {
101101
}
102102

103103
PYBIND11_MODULE(arbitration_graphs_py_with_subcommand, mainModule) {
104-
python_api::bindArbitrationGraphs<DummyCommandInt, DummyCommand>(mainModule, "Int");
104+
python_api::bindArbitrationGraphs<DummyCommandInt, DummyCommand>(mainModule, "BehaviorInt", "Behavior");
105105

106106
py::module testingModule = mainModule.def_submodule("testing_types");
107107
bindTestingTypes(testingModule);

0 commit comments

Comments
 (0)