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