Cleaned up dependencies on controller manager (#964)

* Cleaned up dependencies on controller manager

* Removed global fields

* Simplified setting up RascsiResponse and RascsiExecutor

* Got rid of remaining raw pointers

* Use references instead of pointers

* Improved encapsulation
This commit is contained in:
Uwe Seimet
2022-11-04 08:22:32 +01:00
committed by GitHub
parent 921ba7d2ed
commit c98c52ffb8
44 changed files with 1071 additions and 965 deletions
+4 -4
View File
@@ -21,26 +21,26 @@ class BUS;
class AbstractController;
class PrimaryDevice;
class ControllerManager
class ControllerManager : public enable_shared_from_this<ControllerManager>
{
shared_ptr<BUS> bus;
BUS& bus;
unordered_map<int, shared_ptr<AbstractController>> controllers;
public:
explicit ControllerManager(shared_ptr<BUS> bus) : bus(bus) {}
explicit ControllerManager(BUS& bus) : bus(bus) {}
~ControllerManager() = default;
// Maximum number of controller devices
static const int DEVICE_MAX = 8;
inline BUS& GetBus() const { return bus; }
bool AttachToScsiController(int, shared_ptr<PrimaryDevice>);
bool DeleteController(shared_ptr<AbstractController>);
shared_ptr<AbstractController> IdentifyController(int) const;
shared_ptr<AbstractController> FindController(int) const;
unordered_set<shared_ptr<PrimaryDevice>> GetAllDevices() const;
void DeleteAllControllers();
void ResetAllControllers() const;
shared_ptr<PrimaryDevice> GetDeviceByIdAndLun(int, int) const;
};