openMSX
IDEDeviceFactory.cc
Go to the documentation of this file.
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 
10 
11 std::unique_ptr<IDEDevice> create(const DeviceConfig& config)
12 {
13  if (!config.getXML()) {
14  return std::make_unique<DummyIDEDevice>();
15  }
16  const auto& type = config.getChildData("type");
17  if (type == "IDEHD") {
18  return std::make_unique<IDEHD>(config);
19  } else if (type == "IDECDROM") {
20  return std::make_unique<IDECDROM>(config);
21  }
22  throw MSXException("Unknown IDE device: ", type);
23 }
24 
25 } // namespace openmsx::IDEDeviceFactory
std::string_view getChildData(std::string_view name) const
Definition: DeviceConfig.cc:48
const XMLElement * getXML() const
Definition: DeviceConfig.hh:48
std::unique_ptr< IDEDevice > create(const DeviceConfig &config)