175 lines
4.7 KiB
C++
175 lines
4.7 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2022 SenseGlove
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "Containers/UnrealString.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
#include "Templates/SharedPointer.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGCoreImpl/SGDeviceImpl.h"
|
|
#include "SGCoreImpl/SGPlatform.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
|
|
namespace SGCore
|
|
{
|
|
class BetaDevice;
|
|
}
|
|
|
|
class SENSEGLOVECOREIMPL_API FSGBetaDeviceImpl final : public FSGDeviceImpl
|
|
{
|
|
#if ENGINE_MAJOR_VERSION >= 5
|
|
friend class SharedPointerInternals::TIntrusiveReferenceController<FSGBetaDeviceImpl, ESPMode::ThreadSafe>;
|
|
#else
|
|
friend class SharedPointerInternals::TIntrusiveReferenceController<FSGBetaDeviceImpl>;
|
|
#endif /* ENGINE_MAJOR_VERSION >= 5 */
|
|
|
|
public:
|
|
typedef SGCore::BetaDevice FBetaDeviceType;
|
|
|
|
typedef std::shared_ptr<FBetaDeviceType> FBetaDevicePtrType;
|
|
typedef std::vector<FBetaDevicePtrType> FBetaDevicePtrVectorType;
|
|
|
|
public:
|
|
static TSharedRef<FSGBetaDeviceImpl> Parse(const FString& String);
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
FSGBetaDeviceImpl();
|
|
|
|
FSGBetaDeviceImpl(const FString& ConstantsString, const FString& DeviceId,
|
|
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion);
|
|
|
|
public:
|
|
/**
|
|
* The cast from underlying type constructor.
|
|
*/
|
|
explicit FSGBetaDeviceImpl(const FBetaDeviceType BetaDevice);
|
|
|
|
/**
|
|
* The cast from underlying pointer type constructor.
|
|
*/
|
|
explicit FSGBetaDeviceImpl(const FBetaDevicePtrType BetaDevice);
|
|
|
|
public:
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
FSGBetaDeviceImpl(const FSGBetaDeviceImpl& Rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
FSGBetaDeviceImpl(FSGBetaDeviceImpl&& Rhs)
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 && SG_CPP17 )
|
|
noexcept
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 && SG_CPP17 ) */
|
|
;
|
|
|
|
public:
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
virtual ~FSGBetaDeviceImpl() override;
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
FSGBetaDeviceImpl& operator=(const FSGBetaDeviceImpl& Rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
FSGBetaDeviceImpl& operator=(FSGBetaDeviceImpl&& Rhs)
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 && SG_CPP17 )
|
|
noexcept
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 && SG_CPP17 ) */
|
|
;
|
|
|
|
public:
|
|
/**
|
|
* The cast to underlying type method.
|
|
*/
|
|
FBetaDeviceType ToBetaDevice() const;
|
|
|
|
/**
|
|
* The cast to underlying pointer type method.
|
|
*/
|
|
FBetaDevicePtrType ToBetaDevicePtr() const;
|
|
|
|
/**
|
|
* The checked cast to underlying pointer type method.
|
|
*/
|
|
FBetaDevicePtrType ToBetaDevicePtrChecked() const;
|
|
|
|
public:
|
|
virtual ESGDeviceType GetDeviceType() const override;
|
|
|
|
virtual FString GetDeviceId() const override;
|
|
|
|
virtual FString GetHardwareVersion() const override;
|
|
|
|
virtual int32 GetFirmwareVersion() const override;
|
|
|
|
virtual int32 GetSubFirmwareVersion() const override;
|
|
|
|
public:
|
|
FString GetConstantsString() const;
|
|
|
|
FString GetSensorData() const;
|
|
|
|
FString GetLastCommand() const;
|
|
|
|
public:
|
|
bool SendHaptics(const FString& Command) const;
|
|
|
|
public:
|
|
virtual FString ToString() const override;
|
|
}; |