mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-17 18:29:39 +00:00
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
54 lines
1.5 KiB
C++
54 lines
1.5 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 "devices/device.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
|
|
{
|
|
const inline static string DEFAULT_IP = "10.10.20.1/24"; //NOSONAR This hardcoded IP address is safe
|
|
|
|
public:
|
|
|
|
DeviceFactory();
|
|
~DeviceFactory() = default;
|
|
|
|
shared_ptr<PrimaryDevice> CreateDevice(PbDeviceType, int, const string&) const;
|
|
PbDeviceType GetTypeForFile(const string&) const;
|
|
const unordered_set<uint32_t>& GetSectorSizes(PbDeviceType type) const;
|
|
const param_map& GetDefaultParams(PbDeviceType type) const;
|
|
const auto& GetExtensionMapping() const { return extension_mapping; }
|
|
|
|
private:
|
|
|
|
unordered_map<PbDeviceType, unordered_set<uint32_t>> sector_sizes;
|
|
|
|
unordered_map<PbDeviceType, param_map> default_params;
|
|
|
|
unordered_map<string, PbDeviceType, piscsi_util::StringHash, equal_to<>> extension_mapping;
|
|
|
|
unordered_map<string, PbDeviceType, piscsi_util::StringHash, equal_to<>> device_mapping;
|
|
|
|
inline static const unordered_set<uint32_t> EMPTY_SET;
|
|
inline static const param_map EMPTY_PARAM_MAP;
|
|
};
|