Extract device creation

This commit is contained in:
momo5502
2024-11-06 16:31:30 +01:00
parent 4c0c1bf0c6
commit 8cf451fd1f
4 changed files with 57 additions and 39 deletions

View File

@@ -0,0 +1,29 @@
#include "io_device.hpp"
namespace
{
struct dummy_device : stateless_device
{
void read() override
{
}
void write() override
{
}
};
}
std::unique_ptr<io_device> create_device(const std::wstring_view device)
{
if (device == L"CNG"
|| device == L"KsecDD"
|| device == L"DeviceApi\\CMApi"
|| device == L"ConDrv\\Server"
|| device == L"Afd\\Endpoint")
{
return std::make_unique<dummy_device>();
}
throw std::runtime_error("Unsupported device: " + std::string(device.begin(), device.end()));
}