| 22 | } |
| 23 | |
| 24 | bool ControllerManager::AttachToController(BUS& bus, int id, shared_ptr<PrimaryDevice> device) |
| 25 | { |
| 26 | if (auto controller = FindController(id); controller != nullptr) { |
| 27 | if (controller->HasDeviceForLun(device->GetLun())) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | return controller->AddDevice(device); |
| 32 | } |
| 33 | |
| 34 | // If this is LUN 0 create a new controller |
| 35 | if (!device->GetLun()) { |
| 36 | if (auto controller = CreateScsiController(bus, id); controller->AddDevice(device)) { |
| 37 | controllers[id] = controller; |
| 38 | |
| 39 | return true; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | bool ControllerManager::DeleteController(const AbstractController& controller) |
| 47 | { |