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 
9 namespace openmsx {
10 namespace IDEDeviceFactory {
11 
12 std::unique_ptr<IDEDevice> create(const DeviceConfig& config)
13 {
14  if (!config.getXML()) {
15  return std::make_unique<DummyIDEDevice>();
16  }
17  const std::string& type = config.getChildData("type");
18  if (type == "IDEHD") {
19  return std::make_unique<IDEHD>(config);
20  } else if (type == "IDECDROM") {
21  return std::make_unique<IDECDROM>(config);
22  }
23  throw MSXException("Unknown IDE device: ", type);
24 }
25 
26 } // namespace IDEDeviceFactory
27 } // namespace openmsx
const std::string & getChildData(string_view name) const
Definition: DeviceConfig.cc:43
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
std::unique_ptr< IDEDevice > create(const DeviceConfig &config)
const XMLElement * getXML() const
Definition: DeviceConfig.hh:47