2022-10-06 14:15:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-06 14:15:19 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021-2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "generated/piscsi_interface.pb.h"
|
2022-10-06 14:15:19 +00:00
|
|
|
#include "localizer.h"
|
2022-11-10 06:44:06 +00:00
|
|
|
#include "shared/protobuf_serializer.h"
|
2022-10-06 14:15:19 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace std;
|
2022-12-05 17:58:23 +00:00
|
|
|
using namespace piscsi_interface;
|
2022-10-06 14:15:19 +00:00
|
|
|
|
|
|
|
class CommandContext
|
|
|
|
{
|
|
|
|
const ProtobufSerializer serializer;
|
|
|
|
|
|
|
|
const Localizer localizer;
|
|
|
|
|
|
|
|
string locale;
|
|
|
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
CommandContext(const std::string& s = "", int f = -1) : locale(s), fd(f) {}
|
|
|
|
~CommandContext() = default;
|
|
|
|
|
2022-10-08 17:26:04 +00:00
|
|
|
void Cleanup();
|
2022-10-06 14:15:19 +00:00
|
|
|
|
|
|
|
const ProtobufSerializer& GetSerializer() const { return serializer; }
|
|
|
|
int GetFd() const { return fd; }
|
|
|
|
void SetFd(int f) { fd = f; }
|
|
|
|
bool IsValid() const { return fd != -1; }
|
|
|
|
|
|
|
|
bool ReturnLocalizedError(LocalizationKey, const string& = "", const string& = "", const string& = "") const;
|
|
|
|
bool ReturnLocalizedError(LocalizationKey, PbErrorCode, const string& = "", const string& = "", const string& = "") const;
|
|
|
|
bool ReturnStatus(bool = true, const string& = "", PbErrorCode = PbErrorCode::NO_ERROR_CODE, bool = true) const;
|
|
|
|
};
|