openbmc / sdbusplus

C++ bindings for systemd dbus APIs
Apache License 2.0
103 stars 81 forks source link

Introduce getter for asio::connection in asio::dbus_interface #83

Open jbbjarnason opened 1 year ago

jbbjarnason commented 1 year ago

Before I go through the process of making a PR on gerrit.

Do you have something against populating a getter for the shared_ptr of asio::connection within asio::dbus_interface?

mine260309 commented 1 year ago

By the getter, do you mean something like https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/64536?

jbbjarnason commented 1 year ago

@mine260309 Nope, even more simple, here is what I mean:

diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 57dcc95..a4d8ff7 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -398,6 +398,8 @@ class dbus_interface
                                        std::vector<std::string>{name_});
     }

+    auto connection() const noexcept -> std::shared_ptr<sdbusplus::asio::connection> { return conn_; }
+
     template <typename PropertyType, typename CallbackTypeGet>
     bool register_property_r(const std::string& name,
                              const PropertyType& property,
omarhogni commented 8 months ago

@williamspatrick is this something you would consider merging? can be very handy if you are writing a component to minimize the parameter count. Also sort of follows asio convention of getting a io_context. See this for reference https://live.boost.org/doc/libs/1_84_0/doc/html/boost_asio/reference/basic_stream_socket/get_executor.html

If so I can create a patch, get a CLA signed and submit to gerrit.

williamspatrick commented 8 months ago

@omarhogni - Sure.