Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
DiscreteTypeParamConverter< T, Compare > Class Template Reference

This converters maps a list of values of type T to discrete values. More...

#include <ParamConverters.h>

Inherits IParamConverter< T >.

Public Types

using ConstructorType = std::initializer_list<std::pair<const T, VstString16>> const &
 Defines the type for the constructor argument.
using ParamType = T
using TList = std::vector<T>
 Defines the mapping: discrete value [0, stepCount] to T.
using TMap = std::map<T, std::tuple<VstString16, ParamValue, int32>, Compare>
 Maintains the map of possible values of T (defined in constructor).
Public Types inherited from IParamConverter< T >
using ParamType = T

Public Member Functions

ParamType denormalize (ParamValue iNormalizedValue) const override
 DiscreteTypeParamConverter (ConstructorType iInitList)
 This constructor will be called this way when initializing a vst or jmb parameter:
int32 getStepCount () const override
ParamValue normalize (ParamType const &iValue) const override
void toString (ParamType const &iValue, String128 oString, int32 iPrecision) const override
Public Member Functions inherited from IParamConverter< T >
virtual std::string toString (ParamType const &iValue, int32 iPrecision) const

Private Attributes

TList fList {}
TMap fMap {}

Detailed Description

template<typename T, class Compare = std::less<T>>
class pongasoft::VST::DiscreteTypeParamConverter< T, Compare >

This converters maps a list of values of type T to discrete values.

It can be used with any T that is comparable (note that you can optionally provide your own Compare). For example, T can be an enum, enum class, struct, class, etc...

Example:

enum class ETabs {
kTabAll = 100,
kTabToggleButtonView = 150
};
// ...
// ...
fTab =
vst<DiscreteTypeParamConverter<ETabs>>(EJambaTestPluginParamID::kTab, STR16("Tab"),
{
{ETabs::kTabAll, STR16("All Controls")},
{ETabs::kTabToggleButtonView, STR16("ToggleButtonView")}
})
.add();
std::shared_ptr< VstParamDef< T > > VstParam
Definition ParamDef.h:509

Member Typedef Documentation

◆ ConstructorType

template<typename T, class Compare = std::less<T>>
using ConstructorType = std::initializer_list<std::pair<const T, VstString16>> const &

Defines the type for the constructor argument.

Example: { { t, STR16("abc") }, ... }

◆ ParamType

template<typename T, class Compare = std::less<T>>
using ParamType = T

◆ TList

template<typename T, class Compare = std::less<T>>
using TList = std::vector<T>

Defines the mapping: discrete value [0, stepCount] to T.

◆ TMap

template<typename T, class Compare = std::less<T>>
using TMap = std::map<T, std::tuple<VstString16, ParamValue, int32>, Compare>

Maintains the map of possible values of T (defined in constructor).

Constructor & Destructor Documentation

◆ DiscreteTypeParamConverter()

template<typename T, class Compare = std::less<T>>
DiscreteTypeParamConverter ( ConstructorType iInitList)
inline

This constructor will be called this way when initializing a vst or jmb parameter:

Member Function Documentation

◆ denormalize()

template<typename T, class Compare = std::less<T>>
ParamType denormalize ( ParamValue iNormalizedValue) const
inlineoverridevirtual

Implements IParamConverter< T >.

◆ getStepCount()

template<typename T, class Compare = std::less<T>>
int32 getStepCount ( ) const
inlineoverridevirtual

Reimplemented from IParamConverter< T >.

◆ normalize()

template<typename T, class Compare = std::less<T>>
ParamValue normalize ( ParamType const & iValue) const
inlineoverridevirtual

Implements IParamConverter< T >.

◆ toString()

template<typename T, class Compare = std::less<T>>
void toString ( ParamType const & iValue,
String128 oString,
int32 iPrecision ) const
inlineoverridevirtual

Reimplemented from IParamConverter< T >.

Member Data Documentation

◆ fList

template<typename T, class Compare = std::less<T>>
TList fList {}
private

◆ fMap

template<typename T, class Compare = std::less<T>>
TMap fMap {}
private

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