//--------------------------------------------------------------------------- // // SCSI Target Emulator RaSCSI Reloaded // for Raspberry Pi // // Copyright (C) 2021-2022 Uwe Seimet // //--------------------------------------------------------------------------- #pragma once #include "protobuf_serializer.h" class RascsiResponse; class RascsiImage; class DeviceFactory; class ControllerManager; class PrimaryDevice; class CommandContext; class RascsiExecutor { RascsiResponse& rascsi_response; RascsiImage& rascsi_image; DeviceFactory& device_factory; ControllerManager& controller_manager; ProtobufSerializer serializer; unordered_set reserved_ids; public: RascsiExecutor(RascsiResponse& rascsi_response, RascsiImage& rascsi_image, DeviceFactory& device_factory, ControllerManager& controller_manager) : rascsi_response(rascsi_response), rascsi_image(rascsi_image), device_factory(device_factory), controller_manager(controller_manager) {} ~RascsiExecutor() = default; unordered_set GetReservedIds() const { return reserved_ids; } bool ProcessDeviceCmd(const CommandContext&, const PbDeviceDefinition&, const PbCommand&, bool); bool ProcessCmd(const CommandContext&, const PbCommand&); bool SetLogLevel(const string&) const; bool Start(shared_ptr, bool) const; bool Stop(shared_ptr, bool) const; bool Eject(shared_ptr, bool) const; bool Protect(shared_ptr, bool) const; bool Unprotect(shared_ptr, bool) const; bool Attach(const CommandContext&, const PbDeviceDefinition&, bool); bool Insert(const CommandContext&, const PbDeviceDefinition&, shared_ptr, bool) const; bool Detach(const CommandContext&, shared_ptr, bool) const; void DetachAll(); bool ShutDown(const CommandContext&, const string&); string SetReservedIds(string_view); bool ValidateImageFile(const CommandContext&, shared_ptr, const string&, string&) const; void PrintCommand(const PbCommand&, const PbDeviceDefinition&, bool) const; string ValidateLunSetup(const PbCommand&) const; bool VerifyExistingIdAndLun(const CommandContext&, int, int) const; shared_ptr CreateDevice(const CommandContext&, const PbDeviceType, int, const string&) const; bool SetSectorSize(const CommandContext&, shared_ptr, int) const; static bool ValidateOperationAgainstDevice(const CommandContext&, const shared_ptr, const PbOperation&); static bool ValidateIdAndLun(const CommandContext&, int, int); static bool SetProductData(const CommandContext&, const PbDeviceDefinition&, shared_ptr); };