//--------------------------------------------------------------------------- // // SCSI Target Emulator PiSCSI // for Raspberry Pi // // Copyright (C) 2021-2023 Uwe Seimet // // The DeviceFactory creates devices based on their type and the image file extension // //--------------------------------------------------------------------------- #pragma once #include #include #include "generated/piscsi_interface.pb.h" using namespace std; using namespace piscsi_interface; class PrimaryDevice; class DeviceFactory { public: DeviceFactory() = default; ~DeviceFactory() = default; shared_ptr CreateDevice(PbDeviceType, int, const string&) const; PbDeviceType GetTypeForFile(const string&) const; const auto& GetExtensionMapping() const { return EXTENSION_MAPPING; } private: const inline static unordered_map> EXTENSION_MAPPING = { { "hd1", SCHD }, { "hds", SCHD }, { "hda", SCHD }, { "hdn", SCHD }, { "hdi", SCHD }, { "nhd", SCHD }, { "hdr", SCRM }, { "mos", SCMO }, { "is1", SCCD }, { "iso", SCCD } }; const inline static unordered_map> DEVICE_MAPPING = { { "bridge", SCBR }, { "daynaport", SCDP }, { "printer", SCLP }, { "services", SCHS } }; };