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 std::string& 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
IDEHD.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
MSXException.hh
openmsx::MSXException
Definition: MSXException.hh:9
openmsx::IDEDeviceFactory::create
std::unique_ptr< IDEDevice > create(const DeviceConfig &config)
Definition: IDEDeviceFactory.cc:11
openmsx::IDEDeviceFactory
Definition: IDEDeviceFactory.cc:9
openmsx::DeviceConfig::getChildData
const std::string & getChildData(std::string_view name) const
Definition: DeviceConfig.cc:43
DummyIDEDevice.hh
IDECDROM.hh
IDEDeviceFactory.hh
openmsx::DeviceConfig::getXML
const XMLElement * getXML() const
Definition: DeviceConfig.hh:47
DeviceConfig.hh