mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
52c2aa474f
* Rebrand project to PiSCSI - rascsi ->piscsi - rasctl -> scsictl - rasdump -> scsidump - ras* -> piscsi* (rasutil -> piscsi_util, etc.) * Refined the formatting and wording of the app startup banner * Kept some references to rascsi and rasctl where backwards compatibility is concerned * Point to the new github repo URL Co-authored-by: nucleogenic <nr@nucleogenic.com> Co-authored-by: Uwe Seimet <Uwe.Seimet@seimet.de>
52 lines
1005 B
C++
52 lines
1005 B
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "generated/piscsi_interface.pb.h"
|
|
#include <functional>
|
|
#include <thread>
|
|
|
|
class CommandContext;
|
|
|
|
using namespace std;
|
|
using namespace piscsi_interface;
|
|
|
|
class PiscsiService
|
|
{
|
|
using callback = function<bool(const CommandContext&, piscsi_interface::PbCommand&)>;
|
|
|
|
callback execute;
|
|
|
|
int service_socket = -1;
|
|
|
|
thread monthread;
|
|
|
|
static inline volatile bool running = false;
|
|
|
|
public:
|
|
|
|
PiscsiService() = default;
|
|
~PiscsiService() = default;
|
|
|
|
bool Init(const callback&, int);
|
|
void Cleanup() const;
|
|
|
|
bool IsRunning() const { return running; }
|
|
void SetRunning(bool b) const { running = b; }
|
|
|
|
private:
|
|
|
|
void Execute() const;
|
|
|
|
PbCommand ReadCommand(CommandContext&) const;
|
|
|
|
static void KillHandler(int) { running = false; }
|
|
};
|