mirror of
https://github.com/akuker/RASCSI.git
synced 2025-01-18 10:30:32 +00:00
621cc7d5a2
* Unit test updates * Lambda syntax cleanup * Use new-style casts * Use std::none_of when saving the cache * Use to_integer instead of casts * Use accessors for getting CDB data * Made ctrl_t private * Improved encapsulation * Replaced pointers by references * Removed all remaining occurrences of DWORD and BYTE, making os.h obsolete
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2022 Uwe Seimet
|
|
//
|
|
// The DeviceFactory singleton creates devices based on their type and the image file extension
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <unordered_set>
|
|
#include <unordered_map>
|
|
#include "rascsi_interface.pb.h"
|
|
|
|
using namespace std;
|
|
using namespace rascsi_interface;
|
|
|
|
class ControllerManager;
|
|
class PrimaryDevice;
|
|
|
|
class DeviceFactory
|
|
{
|
|
const string DEFAULT_IP = "10.10.20.1/24"; //NOSONAR This hardcoded IP address is safe
|
|
|
|
public:
|
|
|
|
DeviceFactory();
|
|
~DeviceFactory() = default;
|
|
|
|
shared_ptr<PrimaryDevice> CreateDevice(const ControllerManager&, PbDeviceType, int, const string&);
|
|
PbDeviceType GetTypeForFile(const string&) const;
|
|
const unordered_set<uint32_t>& GetSectorSizes(PbDeviceType type) const;
|
|
const unordered_map<string, string>& GetDefaultParams(PbDeviceType type) const;
|
|
vector<string> GetNetworkInterfaces() const;
|
|
const unordered_map<string, PbDeviceType>& GetExtensionMapping() const { return extension_mapping; }
|
|
|
|
private:
|
|
|
|
unordered_map<PbDeviceType, unordered_set<uint32_t>> sector_sizes;
|
|
|
|
unordered_map<PbDeviceType, unordered_map<string, string>> default_params;
|
|
|
|
unordered_map<string, PbDeviceType> extension_mapping;
|
|
|
|
unordered_map<string, PbDeviceType> device_mapping;
|
|
|
|
unordered_set<uint32_t> empty_set;
|
|
unordered_map<string, string> empty_map;
|
|
};
|