//--------------------------------------------------------------------------- // // SCSI Target Emulator PiSCSI // for Raspberry Pi // // Copyright (C) 2021-2022 Uwe Seimet // //--------------------------------------------------------------------------- #pragma once #include "devices/device_factory.h" #include "devices/primary_device.h" #include "generated/piscsi_interface.pb.h" #include #include #include using namespace std; using namespace piscsi_interface; class PiscsiResponse { using id_set = pair; public: PiscsiResponse() = default; ~PiscsiResponse() = default; bool GetImageFile(PbImageFile&, const string&, const string&) const; unique_ptr GetAvailableImages(PbResult&, const string&, const string&, const string&, int) const; unique_ptr GetReservedIds(PbResult&, const unordered_set&) const; void GetDevices(const unordered_set>&, PbServerInfo&, const string&) const; void GetDevicesInfo(const unordered_set>&, PbResult&, const PbCommand&, const string&) const; unique_ptr GetDeviceTypesInfo(PbResult&) const; unique_ptr GetVersionInfo(PbResult&) const; unique_ptr GetServerInfo(const unordered_set>&, PbResult&, const unordered_set&, const string&, const string&, const string&, const string&, int) const; unique_ptr GetNetworkInterfacesInfo(PbResult&) const; unique_ptr GetMappingInfo(PbResult&) const; unique_ptr GetLogLevelInfo(PbResult&, const string&) const; unique_ptr GetOperationInfo(PbResult&, int) const; private: DeviceFactory device_factory; const inline static array log_levels = { "trace", "debug", "info", "warn", "err", "off" }; unique_ptr GetDeviceProperties(const Device&) const; void GetDevice(const Device&, PbDevice&, const string&) const; void GetAllDeviceTypeProperties(PbDeviceTypesInfo&) const; void GetDeviceTypeProperties(PbDeviceTypesInfo&, PbDeviceType) const; void GetAvailableImages(PbImageFilesInfo&, const string&, const string&, const string&, const string&, int) const; void GetAvailableImages(PbResult& result, PbServerInfo&, const string&, const string&, const string&, int) const; unique_ptr CreateOperation(PbOperationInfo&, const PbOperation&, const string&) const; unique_ptr AddOperationParameter(PbOperationMetaData&, const string&, const string&, const string& = "", bool = false) const; set MatchDevices(const unordered_set>&, PbResult&, const PbCommand&) const; static string GetNextImageFile(const dirent *, const string&); };