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

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

#include <ParamSerializers.h>

Inherits IParamSerializer< T >, and IDiscreteConverter< T >.

Public Types

using ConstructorType = std::initializer_list<std::pair<const T, std::string>> 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::pair<std::string, int32>, Compare>
 Maintains the map of possible values of T (defined in constructor).
Public Types inherited from IParamSerializer< T >
using ParamType = T

Public Member Functions

tresult convertFromDiscreteValue (int32 iDiscreteValue, ParamType &oValue) const override
tresult convertToDiscreteValue (ParamType const &iValue, int32 &oDiscreteValue) const override
 DiscreteTypeParamSerializer (ConstructorType iInitList)
int32 getStepCount () const override
tresult readFromStream (IBStreamer &iStreamer, ParamType &oValue) const override
 This method should read from the stream and populate oValue accordingly (aka deserialization).
tresult writeToStream (const ParamType &iValue, IBStreamer &oStreamer) const override
 This method should write iValue to the stream (aka serialization).
void writeToStream (ParamType const &iValue, std::ostream &oStream) const override
 By default, this implementation simply writes the value to the stream IF it is possible (determined at compilation time).
Public Member Functions inherited from IParamSerializer< 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::DiscreteTypeParamSerializer< 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("ToggleButton")},
})
.add();
std::shared_ptr< JmbParamDef< T > > JmbParam
Definition ParamDef.h:522

Member Typedef Documentation

◆ ConstructorType

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

Defines the type for the constructor argument.

Example: { { t, "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::pair<std::string, int32>, Compare>

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

Constructor & Destructor Documentation

◆ DiscreteTypeParamSerializer()

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

Member Function Documentation

◆ convertFromDiscreteValue()

template<typename T, class Compare = std::less<T>>
tresult convertFromDiscreteValue ( int32 iDiscreteValue,
ParamType & oValue ) const
inlineoverridevirtual

◆ convertToDiscreteValue()

template<typename T, class Compare = std::less<T>>
tresult convertToDiscreteValue ( ParamType const & iValue,
int32 & oDiscreteValue ) const
inlineoverridevirtual

◆ getStepCount()

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

◆ readFromStream()

template<typename T, class Compare = std::less<T>>
tresult readFromStream ( IBStreamer & iStreamer,
ParamType & oValue ) const
inlineoverridevirtual

This method should read from the stream and populate oValue accordingly (aka deserialization).

Returns
kResultOk if reading was successful, kResultFalse otherwise (or kNotImplemented if not supported)

Reimplemented from IParamSerializer< T >.

◆ writeToStream() [1/2]

template<typename T, class Compare = std::less<T>>
tresult writeToStream ( const ParamType & iValue,
IBStreamer & oStreamer ) const
inlineoverridevirtual

This method should write iValue to the stream (aka serialization).

Returns
kResultOk if writing was successful, kResultFalse otherwise (or kNotImplemented if not supported)

Reimplemented from IParamSerializer< T >.

◆ writeToStream() [2/2]

template<typename T, class Compare = std::less<T>>
void writeToStream ( ParamType const & iValue,
std::ostream & oStream ) const
inlineoverridevirtual

By default, this implementation simply writes the value to the stream IF it is possible (determined at compilation time).

Doesn't do anything if not. Subclasses can redefine this behavior.

Reimplemented from IParamSerializer< 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: