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

Represents an optional parameter (Jmb, Vst or no param at all). More...

#include <GUIOptionalParam.h>

Public Types

using class_type = GUIOptionalParam< T >
 
using EditorType = typename ITGUIParameter< T >::ITEditor
 
using ParamType = T
 

Public Member Functions

std::unique_ptr< FObjectCxconnect (Parameters::IChangeListener *iChangeListener) const
 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
 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 ()
 Creates an editor to modify the parameter in a transactional fashion. More...
 
std::unique_ptr< EditorTypeedit (ParamType const &iValue)
 Shortcut api which creates an editor followed by ITEditor::setValue(ParamType const &) to set the parameter value to iValue. More...
 
bool exists () const
 Always return true because by definition an optional parameter always exist. More...
 
ParamID getParamID () const
 Each parameter has a unique ID returned by this method. More...
 
int32 getStepCount () const
 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...
 
ParamType getValue () const
 
 GUIOptionalParam ()
 
 GUIOptionalParam (T const &iDefaultValue)
 
 GUIOptionalParam (std::shared_ptr< ITGUIParameter< T >> iParameter)
 
 operator T () const
 Allow to use the param as the underlying ParamType. More...
 
bool operator!= (const class_type &rhs) const
 Allow to write param1 != param2 to compare the underlying values. More...
 
GUIOptionalParamoperator= (T const &iValue)
 Allow to write param = 3 instead of param.update(3) for example. More...
 
bool operator== (const class_type &rhs) const
 Allow to write param1 == param2 to compare the underlying values. More...
 
tresult setValue (ParamType const &iValue)
 Unconditionaly sets the value of the parameter to the value provided. More...
 
bool update (ParamType const &iValue)
 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...
 

Private Attributes

std::shared_ptr< ITGUIParameter< T > > fParameter
 

Detailed Description

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

Represents an optional parameter (Jmb, Vst or no param at all).

Like GUIVstParam and GUIJmbParam, this class is a wrapper arount the underlying parameter. This parameter is used in very generic views that need to handle a Vst or Jmb parameter, as well as no parameter at all (which is for example the case when adding a brand new view in the VSTGUI editor) and still be functional.

You can obtain an instance of an optional parameter by calling any ParamAware::registerOptionalXXX (resp. ParamAware::registerOptionalDiscreteXX) method.

Note
Because GUIOptionalParam can represent a Vst parameter or a Jmb parameter, there are some restrictions on T itself (which do not exist if you use GUIJmbParam):
  • T must have empty constructor: T()
  • T have a copy constructor: T(T const &)
  • T must be copy assignable: T& operator=(T const &)

Member Typedef Documentation

◆ class_type

◆ EditorType

using EditorType = typename ITGUIParameter<T>::ITEditor

◆ ParamType

using ParamType = T

Constructor & Destructor Documentation

◆ GUIOptionalParam() [1/3]

GUIOptionalParam ( )
inline

◆ GUIOptionalParam() [2/3]

GUIOptionalParam ( T const &  iDefaultValue)
inlineexplicit

◆ GUIOptionalParam() [3/3]

GUIOptionalParam ( std::shared_ptr< ITGUIParameter< T >>  iParameter)
inlineexplicit

Member Function Documentation

◆ connect() [1/2]

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

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

◆ connect() [2/2]

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

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

◆ edit() [1/2]

std::unique_ptr<EditorType> edit ( )
inline

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

See also
ITGUIParameter::ITEditor

◆ edit() [2/2]

std::unique_ptr<EditorType> edit ( ParamType const &  iValue)
inline

Shortcut api which creates an editor followed by ITEditor::setValue(ParamType const &) to set the parameter value to iValue.

◆ exists()

bool exists ( ) const
inline

Always return true because by definition an optional parameter always exist.

◆ getParamID()

ParamID getParamID ( ) const
inline

Each parameter has a unique ID returned by this method.

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

◆ getStepCount()

int32 getStepCount ( ) const
inline

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.

◆ getValue()

ParamType getValue ( ) const
inline
Returns
the current value of the parameter as a T

◆ operator T()

operator T ( ) const
inline

Allow to use the param as the underlying ParamType.

Example: if(param) in the case T is bool

◆ operator!=()

bool operator!= ( const class_type rhs) const
inline

Allow to write param1 != param2 to compare the underlying values.

◆ operator=()

GUIOptionalParam& operator= ( T const &  iValue)
inline

Allow to write param = 3 instead of param.update(3) for example.

◆ operator==()

bool operator== ( const class_type rhs) const
inline

Allow to write param1 == param2 to compare the underlying values.

◆ setValue()

tresult setValue ( ParamType const &  iValue)
inline

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

Parameters
iValuethe value to set
Returns
kResultOk if successful

◆ update()

bool update ( ParamType const &  iValue)
inline

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

Member Data Documentation

◆ fParameter

std::shared_ptr<ITGUIParameter<T> > fParameter
private

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