Jamba C++ API  4.0.0
GUIDiscreteJmbParameter< T > Class Template Reference

Wraps a GUIJmbParameter<T> to interpret it as a discrete parameter using the converter. More...

#include <GUIJmbParameter.h>

Inherits ITGUIParameter< int32 >.

Public Types

using EditorType = typename GUIDiscreteParameter::ITEditor
 
- Public Types inherited from ITGUIParameter< int32 >
using ParamType = int32
 The type of the param (alias) More...
 
using ValueAccessor = std::function< void(int32 const &)>
 API to access the value of the param. More...
 

Public Member Functions

tresult accessValue (ValueAccessor const &iGetter) const override
 API to access the underlying value. More...
 
std::shared_ptr< GUIDiscreteParameterasDiscreteParameter (int32 iStepCount) override
 Converts this parameter into a discrete parameter. More...
 
std::unique_ptr< FObjectCxconnect (Parameters::IChangeListener *iChangeListener) const override
 Creates a connection between this parameter and the change listener: whenever the parameter changes, the listener will be notified of the changes (Parameters::IChangeListener::onParameterChange(ParamID)). More...
 
std::unique_ptr< FObjectCxconnect (Parameters::ChangeCallback iChangeCallback) const override
 Creates a connection between this parameter and the callback: whenever the parameter changes, the callback will be invoked (std::function<void()>). More...
 
std::unique_ptr< EditorTypeedit () override
 Creates an editor to modify the parameter in a transactional fashion. More...
 
ParamID getParamID () const override
 Each parameter has a unique ID returned by this method. More...
 
int32 getStepCount () const override
 When a parameter is a discrete parameter (which means its underlying backing type is an int32 with values in the discrete range [0, getStepCount()]), this method will return the number of steps (> 0). More...
 
tresult getValue (int32 &oDiscreteValue) const
 Because converting the current Jmb value to an int32 may fail this api returns kResultOk if it works in which case, oDiscreteValue contains the value. More...
 
 GUIDiscreteJmbParameter (std::shared_ptr< GUIJmbParameter< T >> iJmbParameter, std::shared_ptr< IDiscreteConverter< T >> iConverter)
 
tresult setValue (int32 const &iDiscreteValue) override
 Unconditionaly sets the value of the parameter to the value provided. More...
 
std::string toUTF8String (int32 iPrecision) const override
 Returns the current value of the parameter as a string (which is properly UTF-8 encoded). More...
 
bool update (int32 const &iDiscreteValue) override
 First check if the value provided (iValue) is different from the current value and if that is the case then updates it to the new value. More...
 
- Public Member Functions inherited from ITGUIParameter< int32 >
virtual std::unique_ptr< ITEditor > edit (ParamType const &iValue)
 Shortcut api which creates an editor followed by ITEditor::setValue(ParamType const &) to set the parameter value to iValue. More...
 
- Public Member Functions inherited from IGUIParameter
template<typename T >
std::shared_ptr< ITGUIParameter< T > > cast ()
 Downcasts this parameter into a typed version. More...
 

Protected Attributes

std::shared_ptr< IDiscreteConverter< T > > fConverter
 
std::shared_ptr< GUIJmbParameter< T > > fJmbParameter
 

Detailed Description

template<typename T>
class pongasoft::VST::GUI::Params::GUIDiscreteJmbParameter< T >

Wraps a GUIJmbParameter<T> to interpret it as a discrete parameter using the converter.

Member Typedef Documentation

◆ EditorType

using EditorType = typename GUIDiscreteParameter::ITEditor

Constructor & Destructor Documentation

◆ GUIDiscreteJmbParameter()

GUIDiscreteJmbParameter ( std::shared_ptr< GUIJmbParameter< T >>  iJmbParameter,
std::shared_ptr< IDiscreteConverter< T >>  iConverter 
)
inline

Member Function Documentation

◆ accessValue()

tresult accessValue ( ValueAccessor const &  iGetter) const
inlineoverridevirtual

API to access the underlying value.

getValue() has a different api depending on the type of param (Vst and Jmb). As a result this interface only provides a common way to access it in both cases via an accessor which allows to:

  • avoid copy in the case of Jmb
  • avoid duplicating values in the case of Vst
Returns
kResultOk if the getter is called, and kResultFalse if the getter is not called for some reason

Implements ITGUIParameter< int32 >.

◆ asDiscreteParameter()

std::shared_ptr<GUIDiscreteParameter> asDiscreteParameter ( int32  iStepCount)
inlineoverridevirtual

Converts this parameter into a discrete parameter.

The discrete parameter returned is a parameter with an underlying backing type int32 and values in the discrete range [0, getStepCount()] or [0, iStepCount] if getStepCount() <= 0.

Parameters
iStepCountif this parameter already defines a step count (getStepCount() > 0), then this parameter is ignored, otherwise it is used to convert this parameter into a discrete parameter with iStepCount steps.
Returns
the discrete parameter or nullptr if this parameter cannot be converted to a discrete parameter.

Implements IGUIParameter.

◆ connect() [1/2]

std::unique_ptr<FObjectCx> connect ( Parameters::IChangeListener iChangeListener) const
inlineoverridevirtual

Creates a connection between this parameter and the change listener: whenever the parameter changes, the listener will be notified of the changes (Parameters::IChangeListener::onParameterChange(ParamID)).

Note
This method is usually invoked by the framework but it may be used in the rare cases when the caller requires to handle the duration of the connection in a more granular fashion
Parameters
iChangeListenerthe listener that will be notified on parameter changes. nullptr is allowed and will be a noop.
Returns
the connection between this parameter and the listener and is maintained for as long as this pointer exists

Implements IGUIParameter.

◆ connect() [2/2]

std::unique_ptr<FObjectCx> connect ( Parameters::ChangeCallback  iChangeCallback) const
inlineoverridevirtual

Creates a connection between this parameter and the callback: whenever the parameter changes, the callback will be invoked (std::function<void()>).

Note
This method is usually invoked by the framework but it may be used in the rare cases when the caller requires to handle the duration of the connection in a more granular fashion
Parameters
iChangeCallbackthe callback that will be invoked on parameter changes.
Returns
the connection between this parameter and the callback and is maintained for as long as this pointer exists

Implements IGUIParameter.

◆ edit()

std::unique_ptr<EditorType> edit ( )
inlineoverridevirtual

Creates an editor to modify the parameter in a transactional fashion.

See also
ITGUIParameter::ITEditor

Implements ITGUIParameter< int32 >.

◆ getParamID()

ParamID getParamID ( ) const
inlineoverridevirtual

Each parameter has a unique ID returned by this method.

Note
Some parameters (in particular GUIOptionalParam) may return pongasoft::VST::UNDEFINED_PARAM_ID

Implements IGUIParameter.

◆ getStepCount()

int32 getStepCount ( ) const
inlineoverridevirtual

When a parameter is a discrete parameter (which means its underlying backing type is an int32 with values in the discrete range [0, getStepCount()]), this method will return the number of steps (> 0).

Note
Although a parameter may not be a discrete parameter itself, the method asDiscreteParameter(int32) may be able to convert/adapt it to one.
Returns
the number of steps which is > 0 if and only if this parameter is a discrete parameter.

Implements IGUIParameter.

◆ getValue()

tresult getValue ( int32 &  oDiscreteValue) const
inline

Because converting the current Jmb value to an int32 may fail this api returns kResultOk if it works in which case, oDiscreteValue contains the value.

Otherwise it returns kResultFalse and oDiscreteValue is left untouched.

◆ setValue()

tresult setValue ( int32 const &  iValue)
inlineoverridevirtual

Unconditionaly sets the value of the parameter to the value provided.

Parameters
iValuethe value to set
Returns
kResultOk if successful

Implements ITGUIParameter< int32 >.

◆ toUTF8String()

std::string toUTF8String ( int32  iPrecision) const
inlineoverridevirtual

Returns the current value of the parameter as a string (which is properly UTF-8 encoded).

Parameters
iPrecisionif iPrecision < 0 the parameter is free to use whichever precision is tied to the parameter otherwise it should use the one provided

Implements IGUIParameter.

◆ update()

bool update ( int32 const &  iValue)
inlineoverridevirtual

First check if the value provided (iValue) is different from the current value and if that is the case then updates it to the new value.

Note
If the type T does not provide a way to compare the value, then this call will delegate to setValue(ParamType const &) and return true.
Parameters
iValuethe value to update
Returns
true if the value was updated

Implements ITGUIParameter< int32 >.

Member Data Documentation

◆ fConverter

std::shared_ptr<IDiscreteConverter<T> > fConverter
protected

◆ fJmbParameter

std::shared_ptr<GUIJmbParameter<T> > fJmbParameter
protected

The documentation for this class was generated from the following file: