From 5a5fefba28a52feffadf2b810b2f935934aa7b0b Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 26 Jul 2026 11:37:52 +0200 Subject: kapi/device: allow removing devices from busses --- kapi/kapi/devices/bus.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'kapi') diff --git a/kapi/kapi/devices/bus.hpp b/kapi/kapi/devices/bus.hpp index 26b46830..13951e46 100644 --- a/kapi/kapi/devices/bus.hpp +++ b/kapi/kapi/devices/bus.hpp @@ -37,6 +37,9 @@ namespace kapi::devices //! @param protocol The bus protocol to use. bus(kstd::string const & name, bus_protocol & protocol); + //! Tear down this bus recursively. + ~bus() override; + //! Attach a child device to this bus. //! //! Whenever a device is attached to a bus, the bus takes sole ownership of the device. @@ -44,6 +47,12 @@ namespace kapi::devices //! @param child The child device to attach. auto add_child(kstd::shared_ptr child) -> void; + //! Detach a child device from this bus and tear it down. + //! + //! @param child The device to detach. + //! @return true iff. the child was found an removed, false otherwise. + auto remove_child(device & child) -> bool; + //! Get the children attached to this bus. //! //! @return A vector of all children attached to this bus. @@ -54,6 +63,8 @@ namespace kapi::devices auto query_facet(kapi::capabilities::facet_id facet) -> void * override; private: + auto do_remove_child(device & child) -> void; + bus_protocol * m_protocol{}; kstd::vector> m_devices{}; }; -- cgit v1.2.3