aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kapi/include/kapi/devices/bus.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/kapi/include/kapi/devices/bus.hpp b/kapi/include/kapi/devices/bus.hpp
new file mode 100644
index 0000000..cf8d090
--- /dev/null
+++ b/kapi/include/kapi/devices/bus.hpp
@@ -0,0 +1,40 @@
+#ifndef TEACHOS_KAPI_DEVICES_BUS_HPP
+#define TEACHOS_KAPI_DEVICES_BUS_HPP
+
+#include "kapi/devices/device.hpp"
+
+#include <kstd/memory>
+#include <kstd/string>
+#include <kstd/vector>
+
+#include <cstddef>
+
+namespace kapi::devices
+{
+ //! A bus device that represents a logical/physical tree of devices and busses.
+ struct bus : device
+ {
+ //! Construct a bus with the given major number, minor number, and name.
+ //!
+ //! @param major The major number of the bus.
+ //! @param minor The minor number of the bus.
+ //! @param name The name of the bus.
+ bus(std::size_t major, std::size_t minor, kstd::string const & name)
+ : device(major, minor, name)
+ {}
+
+ //! Attach a child device to this bus.
+ //!
+ //! Whenever a device is attached to a bus, the bus takes sole ownership of the device.
+ //!
+ //! @param child The child device to attach.
+ virtual auto add_child(kstd::unique_ptr<device> child) -> void = 0;
+
+ //! Get a list of all child devices attached to this bus.
+ //!
+ //! @return A reference to list of child devices of this bus.
+ [[nodiscard]] virtual auto children() const -> kstd::vector<device *> const & = 0;
+ };
+} // namespace kapi::devices
+
+#endif \ No newline at end of file