125 lines
5.1 KiB
C++
125 lines
5.1 KiB
C++
//======================================================================================================
|
|
// Copyright 2016, NaturalPoint Inc.
|
|
//======================================================================================================
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "AnalogSystemBuildConfig.h"
|
|
|
|
#pragma warning( push )
|
|
#pragma warning( disable : 4251 )
|
|
|
|
namespace Core
|
|
{
|
|
class cUID;
|
|
}
|
|
|
|
namespace MoCapCore
|
|
{
|
|
class cPropertyCollection;
|
|
}
|
|
|
|
namespace AnalogSystem
|
|
{
|
|
class IPropVal
|
|
{
|
|
};
|
|
|
|
/// <summary>
|
|
/// cPropertyValue is a property value wrapper
|
|
/// </summary>
|
|
template<typename T>
|
|
class cPropVal : public IPropVal
|
|
{
|
|
public:
|
|
cPropVal( const T value ) { mValue = value; }
|
|
|
|
void SetValue( const T value ) { mValue = value; }
|
|
const T GetValue() { return mValue; }
|
|
|
|
private:
|
|
T mValue;
|
|
};
|
|
|
|
/// <summary>
|
|
/// cPropertySet is a wrapper for a Motive property collection, providing:
|
|
/// - Access to Motive PluginDevice base properties
|
|
/// - Ability to add custom properties, which will be settable in the UI
|
|
/// - Ability to respond to and generate property change events
|
|
///
|
|
/// See Plugin Device SDK for example.
|
|
///
|
|
/// Devices and DeviceChannels derive from this.
|
|
/// </summary>
|
|
class ANALOGSYSTEM_API cPropertySet
|
|
{
|
|
public:
|
|
cPropertySet() = default;
|
|
virtual ~cPropertySet() = default;
|
|
|
|
/// <summary>Sets the property.</summary>
|
|
/// <param name="propertyName">Name of the property.</param>
|
|
/// <param name="newValue">The new value.</param>
|
|
/// <returns></returns>
|
|
bool SetProperty( const char* propertyName, const char* newValue );
|
|
bool SetProperty( const char* propertyName, bool newValue );
|
|
bool SetProperty( const char* propertyName, int newValue );
|
|
bool SetProperty( const char* propertyName, double newValue );
|
|
bool SetProperty( const char* propertyName, double x, double y, double z );
|
|
|
|
/// <summary>Gets the property.</summary>
|
|
/// <param name="propertyName">Name of the property.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <returns></returns>
|
|
bool GetProperty( const char* propertyName, char* value, size_t bufferSize ) const;
|
|
bool GetProperty( const char* propertyName, bool& value ) const;
|
|
bool GetProperty( const char* propertyName, int& value ) const;
|
|
bool GetProperty( const char* propertyName, double& value ) const;
|
|
bool GetProperty( const char* propertyName, double& x, double& y, double& z ) const;
|
|
|
|
/// <summary>(Internal) Gets the shared pointer to the Motive cPropertyCollection</summary>
|
|
/// <returns>Motive cPropertyCollection</returns>
|
|
std::shared_ptr<MoCapCore::cPropertyCollection> PropertyCollection();
|
|
std::shared_ptr<const MoCapCore::cPropertyCollection> PropertyCollection() const;
|
|
|
|
/// <summary>
|
|
/// Modifies a property's attributes.
|
|
/// </summary>
|
|
/// <param name="propertyName">Name of the property.</param>
|
|
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
|
|
/// <param name="hidden">if set to <c>true</c> [hidden].</param>
|
|
/// <param name="group">The group.</param>
|
|
/// <returns>true if successful, false otherwise</returns>
|
|
bool ModifyProperty( const char* propertyName, bool readOnly, bool hidden, bool advanced = false, bool serializable = true );
|
|
|
|
protected:
|
|
/// <summary>Create and initializes the cPropertyCollection.</summary>
|
|
/// <param name="propertySetName">Name of the property set.</param>
|
|
/// <returns>true if successful, false otherwise</returns>
|
|
bool Initialize( const char* propertySetName );
|
|
|
|
/// <summary>
|
|
/// Adds the property with the default value, which determines the property type.
|
|
/// </summary>
|
|
/// <param name="propertyName">Name of the property.</param>
|
|
/// <param name="defaultValue">The default value.</param>
|
|
/// <returns>true if successful, false otherwise</returns>
|
|
bool AddProperty( const char* propertyName, const char* defaultValue, const char* group = "", bool serializable = true );
|
|
bool AddProperty( const char* propertyName, bool defaultValue, const char* group = "", bool serializable = true );
|
|
bool AddProperty( const char* propertyName, int defaultValue, const char* group = "", bool serializable = true );
|
|
bool AddProperty( const char* propertyName, double defaultValue, const char* group = "", bool serializable = true );
|
|
bool AddProperty( const char* propertyName, const char* constraintNames[], int constraintCount, int defaultValue, const char* group = "", bool serializable = true );
|
|
|
|
// Internal use only
|
|
bool Initialize( const Core::cUID& definitionID );
|
|
|
|
private:
|
|
template<typename T2> bool GetPropertyInternal( const char* propertyName, T2& value ) const;
|
|
template<typename T2> bool SetPropertyInternal( const char* propertyName, T2 value );
|
|
|
|
std::shared_ptr<MoCapCore::cPropertyCollection> mPropertyCollection;
|
|
};
|
|
}
|
|
|
|
#pragma warning( pop ) |