mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-26 22:29:45 +00:00
* Initial dummy test * Makefile update * Make protected method visible * Test update * Test update * Updated mode page device * Only build tests with explicit test target * make test builds and executes tests * Replaced constant * Added TODO * Merged develop * Added unit test * Comment update * Unit test update * Added tests * Added tests * Test cleanup * Updated error handling * Reverted MODE SENSE change * Reverted last change * Use GoogleMock * Comment update * Signature update * Cleanup * Cleanup * Further cleanup * Removed obsolete comment * Updated error handling * Cleanup * Added TODO * Added test * Added test * Renaming * Added test * Cleanup * Header update * Added two tests * Renaming * Fixed test argument order * Namespaces are needed in order to avoid name clashes * Added test * Added tests * Added tests * Added tests * Added tests * Updated host services test * Merge with develop * Moved code * Renaming * Added tests * Added tests * Initial device tests * Test cleanup * Added test * Removed cast * RASCSI_TEST target has to depend on SRC_PROTOBUF
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021 Uwe Seimet
|
|
//
|
|
// The DeviceFactory singleton creates devices based on their type and the image file extension
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include <list>
|
|
#include <unordered_set>
|
|
#include <unordered_map>
|
|
#include <string>
|
|
#include "rascsi_interface.pb.h"
|
|
|
|
using namespace std;
|
|
using namespace rascsi_interface;
|
|
|
|
typedef pair<uint32_t, uint32_t> Geometry;
|
|
|
|
class Device;
|
|
|
|
class DeviceFactory
|
|
{
|
|
DeviceFactory();
|
|
~DeviceFactory() {}
|
|
|
|
public:
|
|
|
|
static DeviceFactory& instance();
|
|
|
|
Device *CreateDevice(PbDeviceType, const string&);
|
|
PbDeviceType GetTypeForFile(const string&) const;
|
|
const unordered_set<uint32_t>& GetSectorSizes(PbDeviceType type) { return sector_sizes[type]; }
|
|
const unordered_set<uint32_t>& GetSectorSizes(const string&);
|
|
const unordered_set<uint64_t> GetCapacities(PbDeviceType) const;
|
|
const unordered_map<string, string>& GetDefaultParams(PbDeviceType type) { return default_params[type]; }
|
|
const list<string> GetNetworkInterfaces() const;
|
|
const unordered_map<string, PbDeviceType> GetExtensionMapping() const { return extension_mapping; }
|
|
|
|
private:
|
|
|
|
unordered_map<PbDeviceType, unordered_set<uint32_t>> sector_sizes;
|
|
|
|
// Optional mapping of drive capacities to drive geometries
|
|
unordered_map<PbDeviceType, unordered_map<uint64_t, Geometry>> geometries;
|
|
|
|
unordered_map<PbDeviceType, unordered_map<string, string>> default_params;
|
|
|
|
unordered_map<string, PbDeviceType> extension_mapping;
|
|
|
|
string GetExtension(const string&) const;
|
|
};
|