In embedded systems, hardware components must shut down in a strict order.
If the shutdown sequence is incorrect, peripherals may hang, buses may lock, or clocks may remain enabled unnecessarily.
You are given three system components:
Your task is to design a system where:
main() does not manually start or stop any componentThis must be achieved only using composition and destructors (RAII), without explicit cleanup calls.
What You Must Do
SystemControllerSystemController must own:ClockBusDriverBus uses ClockDriver uses Busmain()Program Flow
SystemController object inside a local scopeInput
Two integers provided via standard input:
Output
The output must match exactly, including order and formatting:
Clock enabled
Bus initialized
Driver started
Bus write: <addr> <value>
Driver stopped
Bus stopped
Clock disabled
Constraints
Clock, Bus, and Driver must NOT be created in main()SystemController must be the only owner of all components
Input
5 10
Expected Output
Clock enabled Bus initialized Driver started Bus write: 5 10 Driver stopped Bus stopped Clock disabled