//====================================================================================================== // Copyright 2016, NaturalPoint Inc. //====================================================================================================== #pragma once #include #include "AnalogSystemBuildConfig.h" #pragma warning( push ) #pragma warning( disable : 4251 ) namespace Core { class cUID; } namespace MoCapCore { class cPropertyCollection; } namespace AnalogSystem { class IPropVal { }; /// /// cPropertyValue is a property value wrapper /// template 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; }; /// /// 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. /// class ANALOGSYSTEM_API cPropertySet { public: cPropertySet() = default; virtual ~cPropertySet() = default; /// Sets the property. /// Name of the property. /// The new value. /// 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 ); /// Gets the property. /// Name of the property. /// The value. /// 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; /// (Internal) Gets the shared pointer to the Motive cPropertyCollection /// Motive cPropertyCollection std::shared_ptr PropertyCollection(); std::shared_ptr PropertyCollection() const; /// /// Modifies a property's attributes. /// /// Name of the property. /// if set to true [read only]. /// if set to true [hidden]. /// The group. /// true if successful, false otherwise bool ModifyProperty( const char* propertyName, bool readOnly, bool hidden, bool advanced = false, bool serializable = true ); protected: /// Create and initializes the cPropertyCollection. /// Name of the property set. /// true if successful, false otherwise bool Initialize( const char* propertySetName ); /// /// Adds the property with the default value, which determines the property type. /// /// Name of the property. /// The default value. /// true if successful, false otherwise 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 bool GetPropertyInternal( const char* propertyName, T2& value ) const; template bool SetPropertyInternal( const char* propertyName, T2 value ); std::shared_ptr mPropertyCollection; }; } #pragma warning( pop )