Files
Plugin/Source/ThirdParty/include/SenseGlove/Connect/IpcCommand.hpp
T

94 lines
2.3 KiBLFS
C++

/**
* @file
*
* @author Max Lammers <max@senseglove.com>
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* @section DESCRIPTION
*
* Class to parse incoming/outgoing commands read from shared memory.
*
* The idea here is that incoming messages can have a 'messageID'. If they do,
* we assume they require a response from the device, which we will post back to
* Shared Memory with the same ID so the requesting program knows this response
* is to its specific command.
*/
#pragma once
#include <memory>
#include <string>
#include "Platform.hpp"
namespace SGConnect
{
class IpcCommand;
}
///<summary> A command read from IPC or to be written to IPC. </summary>
class SGConnect::IpcCommand
{
public:
///<summary> Parse an IpcCommand from the raw IPC string. </summary>
static IpcCommand Parse(const std::string& IpcString);
private:
struct Impl;
std::unique_ptr<Impl> Pimpl;
private:
IpcCommand();
public:
///<summary> Create a new instance of the IPC Command </summary>
IpcCommand(const std::string& cmId, const std::string& cmdContent);
/**
* The copy constructor.
*/
IpcCommand(const IpcCommand& rhs);
/**
* The move constructor.
*/
IpcCommand(IpcCommand&& rhs) noexcept;
virtual ~IpcCommand();
public:
/**
* The copy assignment operator.
*/
IpcCommand& operator=(const IpcCommand& rhs);
/**
* The move assignment operator.
*/
IpcCommand& operator=(IpcCommand&& rhs) noexcept;
public:
///<summary> Message ID for this command </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
const std::string& GetId() const;
///<summary> The content of the message </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
const std::string& GetContent() const;
public:
///<summary> Returns true if this command requires a response from the device. </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
bool HasResponse() const;
};