IDEDeviceFactory.cc 651 B

1234567891011121314151617181920212223242526
  1. #include "IDEDeviceFactory.hh"
  2. #include "DummyIDEDevice.hh"
  3. #include "IDEHD.hh"
  4. #include "IDECDROM.hh"
  5. #include "DeviceConfig.hh"
  6. #include "MSXException.hh"
  7. #include <memory>
  8. namespace openmsx::IDEDeviceFactory {
  9. std::unique_ptr<IDEDevice> create(const DeviceConfig& config)
  10. {
  11. if (!config.getXML()) {
  12. return std::make_unique<DummyIDEDevice>();
  13. }
  14. const std::string& type = config.getChildData("type");
  15. if (type == "IDEHD") {
  16. return std::make_unique<IDEHD>(config);
  17. } else if (type == "IDECDROM") {
  18. return std::make_unique<IDECDROM>(config);
  19. }
  20. throw MSXException("Unknown IDE device: ", type);
  21. }
  22. } // namespace openmsx::IDEDeviceFactory