bus: reduce forward declaration for friendship
Generally we do not want users to be able to get the underlying `sd_bus`
pointer held by the `bus_t`, but there are a number of classes inside
sdbusplus that do need the bus so that they can make appropriate sd_bus
call. Previously, we've required every one of these classes to be
forward declared inside `bus.hpp`, which is clutter. Create a new
class, with a simple static function, which can be inherited by any
internal class and allows access to the underlying `sd_bus*`.
Refactor classes which were previously friends to now inherit from
this class.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ide0e7147801d01dc45b255261ba2cafefabddbb1
diff --git a/src/server/interface.cpp b/src/server/interface.cpp
index 653e6d6..e47f6ef 100644
--- a/src/server/interface.cpp
+++ b/src/server/interface.cpp
@@ -12,13 +12,13 @@
interface::interface(sdbusplus::bus_t& bus, const char* path,
const char* interf, const sdbusplus::vtable_t* vtable,
void* context) :
- _bus(bus.get(), bus.getInterface()),
+ _bus(get_busp(bus), bus.getInterface()),
_path(path), _interf(interf), _intf(bus.getInterface()),
_interface_added(false)
{
sd_bus_slot* slot = nullptr;
- int r = _intf->sd_bus_add_object_vtable(_bus.get(), &slot, _path.c_str(),
- _interf.c_str(), vtable, context);
+ int r = _intf->sd_bus_add_object_vtable(
+ get_busp(_bus), &slot, _path.c_str(), _interf.c_str(), vtable, context);
if (r < 0)
{
throw exception::SdBusError(-r, "sd_bus_add_object_vtable");
@@ -38,7 +38,7 @@
// Note: Converting to use _strv version, could also mock two pointer
// use-case explicitly.
- _intf->sd_bus_emit_properties_changed_strv(_bus.get(), _path.c_str(),
+ _intf->sd_bus_emit_properties_changed_strv(get_busp(_bus), _path.c_str(),
_interf.c_str(), values.data());
}