mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 23:29:39 +00:00
c78ba80088
* Move default parameter handling
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// 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 "shared/piscsi_util.h"
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <unordered_map>
|
|
#include "generated/piscsi_interface.pb.h"
|
|
|
|
using namespace std;
|
|
using namespace piscsi_interface;
|
|
|
|
class PrimaryDevice;
|
|
|
|
class DeviceFactory
|
|
{
|
|
|
|
public:
|
|
|
|
DeviceFactory();
|
|
~DeviceFactory() = default;
|
|
|
|
shared_ptr<PrimaryDevice> CreateDevice(PbDeviceType, int, const string&) const;
|
|
PbDeviceType GetTypeForFile(const string&) const;
|
|
unordered_set<uint32_t> GetSectorSizes(PbDeviceType type) const;
|
|
const auto& GetExtensionMapping() const { return extension_mapping; }
|
|
|
|
private:
|
|
|
|
unordered_map<PbDeviceType, unordered_set<uint32_t>> sector_sizes;
|
|
|
|
unordered_map<string, PbDeviceType, piscsi_util::StringHash, equal_to<>> extension_mapping;
|
|
|
|
unordered_map<string, PbDeviceType, piscsi_util::StringHash, equal_to<>> device_mapping;
|
|
};
|