RASCSI/src/raspberrypi/devices/device_factory.h
Uwe Seimet f782156e51
Added INFO_IMAGE_FILES and INFO_NETWORK_INTERFACES (#243)
* Added GET_IMAGE_FILES

* Added default folder to GET_IMAGE_FILES

* Renaming

* Updated setting image folder

* Fixed default image folder handling

* Added NETWORK_INTERFACES_INFO

* Filter "lo"

* Use PF_INET in favor of PF_INET6

* Added network interfaces to server info

* Filter rascsi_bridge

* Use list of available network interfaces as default parameters
2021-09-19 09:05:01 +02:00

52 lines
1.3 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI (*^..^*)
// for Raspberry Pi
//
// Copyright (C) 2021 Uwe Seimet
//
// The DeviceFactory singleton creates devices based on their type and the extension of their image file
//
//---------------------------------------------------------------------------
#pragma once
#include <set>
#include <list>
#include <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
{
public:
DeviceFactory();
~DeviceFactory() {};
static DeviceFactory& instance();
Device *CreateDevice(PbDeviceType type, const string& filename, const string& ext);
const set<uint32_t>& GetSectorSizes(PbDeviceType type) { return sector_sizes[type]; }
const set<uint32_t>& GetSectorSizes(const string&);
const set<uint64_t> GetCapacities(PbDeviceType);
const map<string, string>& GetDefaultParams(PbDeviceType type) { return default_params[type]; }
const list<string> GetNetworkInterfaces() const;
private:
map<PbDeviceType, set<uint32_t>> sector_sizes;
map<PbDeviceType, map<uint64_t, Geometry>> geometries;
map<PbDeviceType, map<string, string>> default_params;
};