Jamba C++ API  4.1.0
GUIJmbParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019 pongasoft
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 #pragma once
19 
20 #include <base/source/fobject.h>
22 #include <pongasoft/VST/ParamDef.h>
29 #include "IGUIParameter.h"
30 #include "GUIParamCx.h"
31 
33 
41 {
42 public:
43  // Constructor
44  explicit IGUIJmbParameter(std::shared_ptr<IJmbParamDef> iParamDef) : fParamDef{std::move(iParamDef)} {}
45 
46  // getParamDef
47  inline IJmbParamDef const *getParamDef() const { return fParamDef.get(); }
48 
49  // getJmbParamID
50  ParamID getJmbParamID() const { return fParamDef->fParamID; }
51 
52  // readFromStream
53  virtual tresult readFromStream(IBStreamer &iStreamer) = 0;
54 
55  // writeToStream
56  virtual tresult writeToStream(IBStreamer &oStreamer) const = 0;
57 
58  // readFromMessage
59  virtual tresult readFromMessage(Message const &iMessage) = 0;
60 
61  // writeToMessage
62  virtual tresult writeToMessage(Message &oMessage) const = 0;
63 
64  // writeToStream
65  virtual void writeToStream(std::ostream &oStream) const = 0;
66 
67  // handleMessage
68  tresult handleMessage(Message const &iMessage) override { return readFromMessage(iMessage); }
69 
70  // broadcast
71  tresult broadcast() const;
72 
73  // setMessageProducer
74  void setMessageProducer(IMessageProducer *iMessageProducer) { fMessageProducer = iMessageProducer; }
75 
76 protected:
77  std::shared_ptr<IJmbParamDef> fParamDef;
79 };
80 
85 template<typename T>
86 class GUIJmbParameter : public ITGUIParameter<T>, public IGUIJmbParameter, public FObject
87 {
88 public:
89  using ParamType = T;
91 
92  using FObject::update; // fixes overload hiding warning
93 
94  // Constructor
95  explicit GUIJmbParameter(std::shared_ptr<JmbParamDef<T>> iParamDef) :
96  IGUIJmbParameter(iParamDef),
97  FObject(),
98  fValue{iParamDef->fDefaultValue}
99  {
100 // DLOG_F(INFO, "GUIJmbParameter(%p)", this);
101  }
102 
103  // Destructor
104  ~GUIJmbParameter() override
105  {
106 // DLOG_F(INFO, "~GUIJmbParameter(%p)", this);
107  }
108 
109  // getParamID
110  ParamID getParamID() const override { return getJmbParamID(); }
111 
112  inline int32 getStepCount() const override { return 0; }
113 
114  // getParamDef
115  inline JmbParamDef<T> const *getParamDefT() const
116  {
117  return static_cast<JmbParamDef<T> const *>(getParamDef());
118  }
119 
125  bool update(ParamType const &iValue) override
126  {
127  // Implementation note: because this method is declared virtual the compiler must instantiate it
128  // even if never called and will generate an error if the ParamType does not define operator!=, so we
129  // need to account for this case
130  if constexpr(Utils::is_operator_not_eq_defined<ParamType>)
131  {
132  if(fValue != iValue)
133  {
134  if(setValue(iValue) == kResultOk)
135  return true;
136  }
137  }
138  else
139  {
140  if(setValue(iValue) == kResultOk)
141  return true;
142  }
143  return false;
144  }
145 
151  template<class ValueModifier>
152  bool updateIf(ValueModifier const &iValueModifier)
153  {
154  if(iValueModifier(&fValue))
155  {
156  changed();
157  return true;
158  }
159  return false;
160  }
161 
166  tresult setValue(ParamType const &iValue) override
167  {
168  // Implementation note: because this method is declared virtual the compiler must instantiate it
169  // even if never called and will generate an error if the ParamType does is not copy assignable, so we
170  // need to account for this case
171  if constexpr(std::is_copy_assignable_v<ParamType>)
172  {
173  fValue = iValue;
174  changed();
175  return kResultOk;
176  }
177  else
178  {
179  DLOG_F(ERROR, "%s is not copy_assignable. Call updateIf instead.", typeid(ParamType).name());
180  return kResultFalse;
181  }
182  }
183 
188  tresult setValue(ParamType &&iValue)
189  {
190  fValue = std::move(iValue);
191  changed();
192  return kResultOk;
193  }
194 
198  {
199  setValue(getParamDefT()->fDefaultValue);
200  }
201 
202  // readFromStream
203  tresult readFromStream(IBStreamer &iStreamer) override
204  {
205  tresult res = getParamDefT()->readFromStream(iStreamer, fValue);
206  if(res == kResultOk)
207  changed();
208  return res;
209  }
210 
211  // writeToStream
212  tresult writeToStream(IBStreamer &oStreamer) const override
213  {
214  return getParamDefT()->writeToStream(fValue, oStreamer);
215  }
216 
217  // writeToStream
218  void writeToStream(std::ostream &oStream) const override
219  {
220  getParamDefT()->writeToStream(fValue, oStream);
221  }
222 
223  // toUTF8String
224  std::string toUTF8String(int32 iPrecision) const override
225  {
226  return getParamDefT()->toUTF8String(getValue(), iPrecision);
227  }
228 
229  // readFromMessage
230  tresult readFromMessage(Message const &iMessage) override
231  {
232  tresult res = getParamDefT()->readFromMessage(iMessage, fValue);
233  if(res == kResultOk)
234  changed();
235  return res;
236  }
237 
238  // writeToMessage
239  tresult writeToMessage(Message &oMessage) const override
240  {
241  return getParamDefT()->writeToMessage(fValue, oMessage);
242  }
243 
244  // accessValue
245  tresult accessValue(typename ITGUIParameter<T>::ValueAccessor const &iGetter) const override
246  {
247  iGetter(fValue);
248  return kResultOk;
249  }
250 
251  // getValue
252  inline ParamType const &getValue() const { return fValue; }
253 
254  // getValue
255  inline ParamType &getValue() { return fValue; }
256 
257  // edit
258  std::unique_ptr<EditorType> edit() override
259  {
260  return std::make_unique<DefaultEditorImpl<T>>(this, getValue());
261  }
262 
267 
271  std::unique_ptr<FObjectCx> connect(Parameters::IChangeListener *iChangeListener) const override
272  {
273  return std::make_unique<GUIParamCx>(getJmbParamID(), const_cast<GUIJmbParameter *>(this), iChangeListener);
274  }
275 
279  std::unique_ptr<FObjectCx> connect(Parameters::ChangeCallback iChangeCallback) const override
280  {
281  return std::make_unique<FObjectCxCallback>(const_cast<GUIJmbParameter *>(this), std::move(iChangeCallback));
282  }
283 
284  // asDiscreteParameter
285  std::shared_ptr<GUIDiscreteParameter> asDiscreteParameter(int32 iStepCount) override;
286 
287 protected:
289 };
290 
295 template<typename T>
296 static std::shared_ptr<GUIJmbParameter<T>> castToJmb(std::shared_ptr<IGUIParameter> iParam)
297 {
298  return std::dynamic_pointer_cast<GUIJmbParameter<T>>(iParam);
299 }
300 
304 template<typename T>
306 {
307 public:
308  using EditorType = typename GUIDiscreteParameter::ITEditor;
309 
310 public:
311  GUIDiscreteJmbParameter(std::shared_ptr<GUIJmbParameter<T>> iJmbParameter,
312  std::shared_ptr<IDiscreteConverter<T>> iConverter) :
313  fJmbParameter{std::move(iJmbParameter)},
314  fConverter{iConverter}
315  {
316  DCHECK_F(fJmbParameter != nullptr);
317  DCHECK_F(fConverter != nullptr);
318  }
319 
320  // getParamID
321  ParamID getParamID() const override
322  {
323  return fJmbParameter->getParamID();
324  }
325 
326  // getStepCount
327  int32 getStepCount() const override
328  {
329  return fConverter->getStepCount();
330  }
331 
332  // connect
333  std::unique_ptr<FObjectCx> connect(Parameters::IChangeListener *iChangeListener) const override
334  {
335  return fJmbParameter->connect(iChangeListener);
336  }
337 
338  // connect
339  std::unique_ptr<FObjectCx> connect(Parameters::ChangeCallback iChangeCallback) const override
340  {
341  return fJmbParameter->connect(iChangeCallback);
342  }
343 
344  // asDiscreteParameter
345  std::shared_ptr <GUIDiscreteParameter> asDiscreteParameter(int32 iStepCount) override
346  {
347  return fJmbParameter->asDiscreteParameter(iStepCount);
348  }
349 
355  tresult getValue(int32 &oDiscreteValue) const
356  {
357  auto res = fConverter->convertToDiscreteValue(fJmbParameter->getValue(), oDiscreteValue);
358  #ifndef NDEBUG
359  if(res == kResultFalse)
360  DLOG_F(WARNING, "Cannot convert current value of Jmb param [%d] to a discrete value", getParamID());
361  #endif
362  return res;
363  }
364 
365  // accessValue
366  tresult accessValue(ValueAccessor const &iGetter) const override
367  {
368  int32 discreteValue;
369  if(getValue(discreteValue) == kResultOk)
370  {
371  iGetter(discreteValue);
372  return kResultOk;
373  }
374  return kResultFalse;
375  }
376 
377  // update
378  bool update(int32 const &iDiscreteValue) override
379  {
380  int32 currentDiscreteValue;
381  tresult res = getValue(currentDiscreteValue);
382 
383  if(res == kResultOk)
384  {
385  if(iDiscreteValue != currentDiscreteValue)
386  {
387  if(setValue(iDiscreteValue) == kResultOk)
388  return true;
389  }
390  }
391 
392  return false;
393  }
394 
395  // setValue
396  tresult setValue(int32 const &iDiscreteValue) override
397  {
398  int32 currentDiscreteValue;
399  tresult res = getValue(currentDiscreteValue);
400  if(res == kResultOk)
401  {
402  if(iDiscreteValue != currentDiscreteValue)
403  {
404  res = kResultFalse;
405  if constexpr(std::is_copy_assignable_v<T>)
406  {
407  T jmbValue = fJmbParameter->getValue();
408  if(fConverter->convertFromDiscreteValue(iDiscreteValue, jmbValue) == kResultOk)
409  res = fJmbParameter->setValue(jmbValue);
410  else
411  DLOG_F(WARNING, "Cannot convert discrete value [%d] to a [%s] value of Jmb param [%d]",
412  iDiscreteValue,
413  typeid(T).name(),
414  getParamID());
415  }
416  }
417  }
418 
419  return res;
420  }
421 
422  // edit
423  std::unique_ptr<EditorType> edit() override
424  {
425  int32 currentDiscreteValue;
426  tresult res = getValue(currentDiscreteValue);
427  if(res == kResultOk)
428  return std::make_unique<DefaultEditorImpl<int32>>(this, currentDiscreteValue);
429  else
430  return nullptr;
431  }
432 
433  // toUTF8String
434  std::string toUTF8String(int32 iPrecision) const override
435  {
436  return fJmbParameter->toUTF8String(iPrecision);
437  }
438 
439 protected:
440  std::shared_ptr<GUIJmbParameter<T>> fJmbParameter;
441  std::shared_ptr<IDiscreteConverter<T>> fConverter;
442 };
443 
444 //------------------------------------------------------------------------
445 // GUIJmbParameter<T>::asDiscreteParameter
446 //------------------------------------------------------------------------
447 template<typename T>
448 std::shared_ptr<GUIDiscreteParameter> GUIJmbParameter<T>::asDiscreteParameter(int32 iStepCount)
449 {
450  // Step 1: check if the Jmb param provide a discrete converter
451  auto converter = getParamDefT()->getDiscreteConverter();
452 
453  if(converter && converter->getStepCount() > 0)
454  return std::make_shared<GUIDiscreteJmbParameter<T>>(std::dynamic_pointer_cast<GUIJmbParameter<T>>(ITGUIParameter<T>::shared_from_this()),
455  std::move(converter));
456  else
457  {
458  // Step 2: no discrete converter, so we check if T can be automatically converted to an int32 (case where
459  // T is a numeric value, an enum, or a type that offers a "constructor(int32)" and "operator int32()" methods)
460  if(iStepCount > 0)
461  {
462  if constexpr(Utils::is_static_cast_defined<int32, T> && Utils::is_static_cast_defined<T, int32>)
463  {
464  converter = std::make_shared<StaticCastDiscreteConverter<T>>(iStepCount);
465  return std::make_shared<GUIDiscreteJmbParameter<T>>(std::dynamic_pointer_cast<GUIJmbParameter<T>>(ITGUIParameter<T>::shared_from_this()),
466  std::move(converter));
467  }
468  else
469  {
470  DLOG_F(WARNING, "Jmb param [%d] (type [%s]) cannot be converted to a discrete parameter",
471  getParamID(),
472  Utils::typeString<T>().c_str());
473  }
474  }
475  return nullptr;
476  }
477 }
478 
479 //------------------------------------------------------------------------
480 // GUIJmbParam - wrapper to make writing the code much simpler and natural
481 //------------------------------------------------------------------------
488 template<typename T>
489 class GUIJmbParam: public Utils::Operators::Dereferenceable<GUIJmbParam<T>>
490 {
491 public:
492  GUIJmbParam(std::shared_ptr<GUIJmbParameter<T>> iPtr = nullptr) : // NOLINT (not marked explicit on purpose)
493  fPtr{std::move(iPtr)}
494  {}
495 
497  GUIJmbParam<T> &operator=(GUIJmbParam<T> const &iOther) = default;
498 
499  // exists
500  inline bool exists() const { return fPtr != nullptr; }
501 
502  // getParamID
503  inline ParamID getParamID() const { DCHECK_F(exists()); return fPtr->getParamID(); }
504 
509  inline bool update(T const &iNewValue) { DCHECK_F(exists()); return fPtr->update(iNewValue); }
510 
515  template<class ValueModifier>
516  inline bool updateIf(ValueModifier const &iValueModifier) { DCHECK_F(exists()); return fPtr->updateIf(iValueModifier); }
517 
521  inline void setValue(T const &iNewValue) { DCHECK_F(exists()); fPtr->setValue(iNewValue); }
522 
526  inline void setValue(T &&iNewValue) { DCHECK_F(exists()); fPtr->setValue(std::move(iNewValue)); }
527 
530  inline void resetToDefault() { DCHECK_F(exists()); fPtr->resetToDefault(); }
531 
532  // getValue
533  inline T const & getValue() const { DCHECK_F(exists()); return fPtr->getValue(); }
534 
536  inline T const & value() const { DCHECK_F(exists()); return fPtr->getValue(); }
537 
538  // allow to use the param as the underlying `ParamType` (ex: `if(param)` in the case `ParamType` is `bool`))
539  [[deprecated("Since 4.1.0 - use operator* or .value() instead (ex: if(*param) {...} or if(param.value()) {...}")]]
540  inline operator T const &() const { DCHECK_F(exists()); return fPtr->getValue(); } // NOLINT
541 
543  constexpr T const & operator *() const { DCHECK_F(exists()); return fPtr->getValue(); }
544 
545  // allow writing param->xxx to access the underlying type directly (if not a primitive)
546  constexpr T const * operator->() const { DCHECK_F(exists()); return &fPtr->getValue(); }
547 
549  inline GUIJmbParam<T> &operator=(T const &iValue) { DCHECK_F(exists()); fPtr->setValue(iValue); return *this; }
550 
551  // broadcast
552  inline tresult broadcast() const { DCHECK_F(exists()); return fPtr->broadcast(); }
553 
554  // broadcast
555  inline void broadcast(T const &iValue)
556  {
557  setValue(iValue);
558  broadcast();
559  }
560 
561  // broadcast
562  inline void broadcast(T &&iValue)
563  {
564  setValue(std::move(iValue));
565  broadcast();
566  }
567 
568  // connect
569  inline std::unique_ptr<FObjectCx> connect(Parameters::IChangeListener *iChangeListener) { DCHECK_F(exists()); return fPtr->connect(iChangeListener); }
570 
571  // connect
572  inline std::unique_ptr<FObjectCx> connect(Parameters::ChangeCallback iChangeCallback) { DCHECK_F(exists()); return fPtr->connect(std::move(iChangeCallback)); }
573 
574 private:
575  std::shared_ptr<GUIJmbParameter<T>> fPtr;
576 };
577 
578 }
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIJmbParameter.h:110
std::unique_ptr< EditorType > edit() override
Creates an editor to modify the parameter in a transactional fashion.
Definition: GUIJmbParameter.h:423
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIJmbParameter.h:516
void resetToDefault()
Resets the param to its default value.
Definition: GUIJmbParameter.h:197
bool update(T const &iNewValue)
This method is typically called by a view to change the value of the parameter.
Definition: GUIJmbParameter.h:509
void broadcast(T const &iValue)
Definition: GUIJmbParameter.h:555
std::shared_ptr< IJmbParamDef > fParamDef
Definition: GUIJmbParameter.h:77
tresult accessValue(typename ITGUIParameter< T >::ValueAccessor const &iGetter) const override
Definition: GUIJmbParameter.h:245
typename ITGUIParameter< T >::ITEditor EditorType
Definition: GUIJmbParameter.h:90
Base class for a Jamba (Jmb) GUI parameter.
Definition: GUIJmbParameter.h:40
Abstraction for allocating and sending a message.
Definition: MessageProducer.h:33
Simple wrapper class with better api.
Definition: Messaging.h:42
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
Represents a gui parameter with its underlying backing type T (aka ParamType).
Definition: IGUIParameter.h:33
tresult getValue(int32 &oDiscreteValue) const
Because converting the current Jmb value to an int32 may fail this api returns kResultOk if it works ...
Definition: GUIJmbParameter.h:355
ParamID getParamID() const override
Each parameter has a unique ID returned by this method.
Definition: GUIJmbParameter.h:321
IMessageProducer * fMessageProducer
Definition: GUIJmbParameter.h:78
JmbParamDef< T > const * getParamDefT() const
Definition: GUIJmbParameter.h:115
tresult readFromStream(IBStreamer &iStreamer) override
Definition: GUIJmbParameter.h:203
bool update(int32 const &iDiscreteValue) override
First check if the value provided (iValue) is different from the current value and if that is the cas...
Definition: GUIJmbParameter.h:378
Interface defining a message handler.
Definition: MessageHandler.h:30
void writeToStream(std::ostream &oStream) const override
Definition: GUIJmbParameter.h:218
tresult broadcast() const
Definition: GUIJmbParameter.cpp:29
IGUIJmbParameter(std::shared_ptr< IJmbParamDef > iParamDef)
Definition: GUIJmbParameter.h:44
GUIJmbParam< T > & operator=(GUIJmbParam< T > const &iOther)=default
Assignment operator: fMyParam = registerParam(...);
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Definition: GUIJmbParameter.h:279
tresult accessValue(ValueAccessor const &iGetter) const override
API to access the underlying value.
Definition: GUIJmbParameter.h:366
GUIJmbParam< T > & operator=(T const &iValue)
Allow to write param = 3.0.
Definition: GUIJmbParameter.h:549
tresult setValue(ParamType &&iValue)
Sets the value.
Definition: GUIJmbParameter.h:188
Implements all the various equality and relational operators for the type T which is assumed to encap...
Definition: Operators.h:54
std::function< void(T const &)> ValueAccessor
API to access the value of the param.
Definition: IGUIParameter.h:178
void setValue(T const &iNewValue)
The difference with update is that it does not check for equality (case when T is not comparable)
Definition: GUIJmbParameter.h:521
tresult writeToMessage(Message &oMessage) const override
Definition: GUIJmbParameter.h:239
T ParamType
Definition: GUIJmbParameter.h:89
void setMessageProducer(IMessageProducer *iMessageProducer)
Definition: GUIJmbParameter.h:74
constexpr T const & operator *() const
allow writing *param to access the underlying value (or in other words, *param is the same param....
Definition: GUIJmbParameter.h:543
typename GUIDiscreteParameter::ITEditor EditorType
Definition: GUIJmbParameter.h:308
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIJmbParameter.h:434
Definition: GUIState.h:36
tresult handleMessage(Message const &iMessage) override
Definition: GUIJmbParameter.h:68
tresult setValue(int32 const &iDiscreteValue) override
Unconditionaly sets the value of the parameter to the value provided.
Definition: GUIJmbParameter.h:396
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIJmbParameter.h:152
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener)
Definition: GUIJmbParameter.h:569
constexpr T const * operator->() const
Definition: GUIJmbParameter.h:546
std::shared_ptr< GUIJmbParameter< T > > fPtr
Definition: GUIJmbParameter.h:575
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIJmbParameter.h:489
std::shared_ptr< GUIJmbParameter< T > > fJmbParameter
Definition: GUIJmbParameter.h:440
virtual tresult writeToMessage(Message &oMessage) const =0
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Creates a connection between this parameter and the change listener: whenever the parameter changes,...
Definition: GUIJmbParameter.h:333
bool exists() const
Definition: GUIJmbParameter.h:500
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIJmbParameter.h:345
std::unique_ptr< FObjectCx > connect(Parameters::IChangeListener *iChangeListener) const override
Definition: GUIJmbParameter.h:271
This is the templated version providing serializer methods, very similar to the GUIVstParameter conce...
Definition: GUIJmbParameter.h:86
T const & getValue() const
Definition: GUIJmbParameter.h:533
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIJmbParameter.h:327
~GUIJmbParameter() override
Definition: GUIJmbParameter.h:104
bool update(ParamType const &iValue) override
Update the parameter with a value.
Definition: GUIJmbParameter.h:125
GUIJmbParam(std::shared_ptr< GUIJmbParameter< T >> iPtr=nullptr)
Definition: GUIJmbParameter.h:492
void resetToDefault()
Resets the param to its default value.
Definition: GUIJmbParameter.h:530
ParamType const & getValue() const
Definition: GUIJmbParameter.h:252
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIJmbParameter.h:448
void broadcast(T &&iValue)
Definition: GUIJmbParameter.h:562
Interface that defines a converter from a type T to an int32 given a number of steps (provided by get...
Definition: ParamSerializers.h:45
ParamType fValue
Definition: GUIJmbParameter.h:288
virtual tresult writeToStream(IBStreamer &oStreamer) const =0
GUIJmbParameter(std::shared_ptr< JmbParamDef< T >> iParamDef)
Definition: GUIJmbParameter.h:95
IJmbParamDef const * getParamDef() const
Definition: GUIJmbParameter.h:47
Wraps a GUIJmbParameter<T> to interpret it as a discrete parameter using the converter.
Definition: GUIJmbParameter.h:305
int32 getStepCount() const override
When a parameter is a discrete parameter (which means its underlying backing type is an int32 with va...
Definition: GUIJmbParameter.h:112
tresult writeToStream(IBStreamer &oStreamer) const override
Definition: GUIJmbParameter.h:212
ParamID getJmbParamID() const
Definition: GUIJmbParameter.h:50
tresult setValue(ParamType const &iValue) override
Sets the value.
Definition: GUIJmbParameter.h:166
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback)
Definition: GUIJmbParameter.h:572
static std::shared_ptr< GUIJmbParameter< T > > castToJmb(std::shared_ptr< IGUIParameter > iParam)
Convenient function to cast a generic IGUIParameter to a GUIJmbParameter<T>.
Definition: GUIJmbParameter.h:296
ParamID getParamID() const
Definition: GUIJmbParameter.h:503
GUIDiscreteJmbParameter(std::shared_ptr< GUIJmbParameter< T >> iJmbParameter, std::shared_ptr< IDiscreteConverter< T >> iConverter)
Definition: GUIJmbParameter.h:311
void setValue(T &&iNewValue)
The difference with update is that it does not check for equality (case when T is not comparable)
Definition: GUIJmbParameter.h:526
std::unique_ptr< FObjectCx > connect(Parameters::ChangeCallback iChangeCallback) const override
Creates a connection between this parameter and the callback: whenever the parameter changes,...
Definition: GUIJmbParameter.h:339
Defines the API for the editor which can be obtained by calling ITGUIParameter::edit().
Definition: IGUIParameter.h:232
virtual tresult readFromStream(IBStreamer &iStreamer)=0
T const & value() const
Synonym to getValue()
Definition: GUIJmbParameter.h:536
std::shared_ptr< IDiscreteConverter< T > > fConverter
Definition: GUIJmbParameter.h:441
Base class for all non vst parameters (need to provide serialization/deserialization)
Definition: ParamDef.h:273
tresult broadcast() const
Definition: GUIJmbParameter.h:552
std::string toUTF8String(int32 iPrecision) const override
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIJmbParameter.h:224
virtual tresult readFromMessage(Message const &iMessage)=0
Base class for jamba parameters (non templated)
Definition: ParamDef.h:237
std::unique_ptr< EditorType > edit() override
Creates an editor to modify the parameter in a transactional fashion.
Definition: GUIJmbParameter.h:258
ParamType & getValue()
Definition: GUIJmbParameter.h:255
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
tresult readFromMessage(Message const &iMessage) override
Definition: GUIJmbParameter.h:230