Jamba C++ API  5.0.0
GUIJmbParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 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 
197  tresult resetToDefault() override
198  {
199  return 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  // resetToDefault
423  tresult resetToDefault() override
424  {
425  return fJmbParameter->resetToDefault();
426  }
427 
428  // edit
429  std::unique_ptr<EditorType> edit() override
430  {
431  int32 currentDiscreteValue;
432  tresult res = getValue(currentDiscreteValue);
433  if(res == kResultOk)
434  return std::make_unique<DefaultEditorImpl<int32>>(this, currentDiscreteValue);
435  else
436  return nullptr;
437  }
438 
439  // toUTF8String
440  std::string toUTF8String(int32 iPrecision) const override
441  {
442  return fJmbParameter->toUTF8String(iPrecision);
443  }
444 
445 protected:
446  std::shared_ptr<GUIJmbParameter<T>> fJmbParameter;
447  std::shared_ptr<IDiscreteConverter<T>> fConverter;
448 };
449 
450 //------------------------------------------------------------------------
451 // GUIJmbParameter<T>::asDiscreteParameter
452 //------------------------------------------------------------------------
453 template<typename T>
454 std::shared_ptr<GUIDiscreteParameter> GUIJmbParameter<T>::asDiscreteParameter(int32 iStepCount)
455 {
456  // Step 1: check if the Jmb param provide a discrete converter
457  auto converter = getParamDefT()->getDiscreteConverter();
458 
459  if(converter && converter->getStepCount() > 0)
460  return std::make_shared<GUIDiscreteJmbParameter<T>>(std::dynamic_pointer_cast<GUIJmbParameter<T>>(ITGUIParameter<T>::shared_from_this()),
461  std::move(converter));
462  else
463  {
464  // Step 2: no discrete converter, so we check if T can be automatically converted to an int32 (case where
465  // T is a numeric value, an enum, or a type that offers a "constructor(int32)" and "operator int32()" methods)
466  if(iStepCount > 0)
467  {
468  if constexpr(Utils::is_static_cast_defined<int32, T> && Utils::is_static_cast_defined<T, int32>)
469  {
470  converter = std::make_shared<StaticCastDiscreteConverter<T>>(iStepCount);
471  return std::make_shared<GUIDiscreteJmbParameter<T>>(std::dynamic_pointer_cast<GUIJmbParameter<T>>(ITGUIParameter<T>::shared_from_this()),
472  std::move(converter));
473  }
474  else
475  {
476  DLOG_F(WARNING, "Jmb param [%d] (type [%s]) cannot be converted to a discrete parameter",
477  getParamID(),
478  Utils::typeString<T>().c_str());
479  }
480  }
481  return nullptr;
482  }
483 }
484 
485 //------------------------------------------------------------------------
486 // GUIJmbParam - wrapper to make writing the code much simpler and natural
487 //------------------------------------------------------------------------
494 template<typename T>
495 class GUIJmbParam: public Utils::Operators::Dereferenceable<GUIJmbParam<T>>
496 {
497 public:
498  using ParamType = T;
500  using Editor = std::unique_ptr<EditorType>;
501 
502 public:
503  GUIJmbParam(std::shared_ptr<GUIJmbParameter<T>> iPtr = nullptr) : // NOLINT (not marked explicit on purpose)
504  fPtr{std::move(iPtr)}
505  {}
506 
508  GUIJmbParam<T> &operator=(GUIJmbParam<T> const &iOther) = default;
509 
510  // exists
511  inline bool exists() const { return fPtr != nullptr; }
512 
513  // getParamID
514  inline ParamID getParamID() const { DCHECK_F(exists()); return fPtr->getParamID(); }
515 
520  inline bool update(T const &iNewValue) { DCHECK_F(exists()); return fPtr->update(iNewValue); }
521 
526  template<class ValueModifier>
527  inline bool updateIf(ValueModifier const &iValueModifier) { DCHECK_F(exists()); return fPtr->updateIf(iValueModifier); }
528 
532  inline void setValue(T const &iNewValue) { DCHECK_F(exists()); fPtr->setValue(iNewValue); }
533 
537  inline void setValue(T &&iNewValue) { DCHECK_F(exists()); fPtr->setValue(std::move(iNewValue)); }
538 
541  inline Editor edit() { DCHECK_F(exists()); return fPtr->edit(); }
542 
546  inline Editor edit(T const &iValue) { DCHECK_F(exists()); return fPtr->edit(iValue); }
547 
550  inline tresult resetToDefault() { DCHECK_F(exists()); return fPtr->resetToDefault(); }
551 
552  // getValue
553  inline T const & getValue() const { DCHECK_F(exists()); return fPtr->getValue(); }
554 
556  inline T const & value() const { DCHECK_F(exists()); return fPtr->getValue(); }
557 
558  // allow to use the param as the underlying `ParamType` (ex: `if(param)` in the case `ParamType` is `bool`))
559  [[deprecated("Since 4.1.0 - use operator* or .value() instead (ex: if(*param) {...} or if(param.value()) {...}")]]
560  inline operator T const &() const { DCHECK_F(exists()); return fPtr->getValue(); } // NOLINT
561 
563  constexpr T const & operator *() const { DCHECK_F(exists()); return fPtr->getValue(); }
564 
565  // allow writing param->xxx to access the underlying type directly (if not a primitive)
566  constexpr T const * operator->() const { DCHECK_F(exists()); return &fPtr->getValue(); }
567 
569  inline GUIJmbParam<T> &operator=(T const &iValue) { DCHECK_F(exists()); fPtr->setValue(iValue); return *this; }
570 
571  // broadcast
572  inline tresult broadcast() const { DCHECK_F(exists()); return fPtr->broadcast(); }
573 
574  // broadcast
575  inline void broadcast(T const &iValue)
576  {
577  setValue(iValue);
578  broadcast();
579  }
580 
581  // broadcast
582  inline void broadcast(T &&iValue)
583  {
584  setValue(std::move(iValue));
585  broadcast();
586  }
587 
590  inline std::string toUTF8String(int32 iPrecision) const { DCHECK_F(exists()); return fPtr->toUTF8String(iPrecision); }
591 
592  // connect
593  inline std::unique_ptr<FObjectCx> connect(Parameters::IChangeListener *iChangeListener) { DCHECK_F(exists()); return fPtr->connect(iChangeListener); }
594 
595  // connect
596  inline std::unique_ptr<FObjectCx> connect(Parameters::ChangeCallback iChangeCallback) { DCHECK_F(exists()); return fPtr->connect(std::move(iChangeCallback)); }
597 
598 private:
599  std::shared_ptr<GUIJmbParameter<T>> fPtr;
600 };
601 
602 }
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:429
bool updateIf(ValueModifier const &iValueModifier)
Use this flavor of update if you want to modify the value itself.
Definition: GUIJmbParameter.h:527
bool update(T const &iNewValue)
This method is typically called by a view to change the value of the parameter.
Definition: GUIJmbParameter.h:520
void broadcast(T const &iValue)
Definition: GUIJmbParameter.h:575
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:44
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
UTF8String ParamType
Definition: GUIJmbParameter.h:498
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 resetToDefault() override
Resets the param to its default value.
Definition: GUIJmbParameter.h:197
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:569
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:182
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:532
tresult writeToMessage(Message &oMessage) const override
Definition: GUIJmbParameter.h:239
Editor edit()
Definition: GUIJmbParameter.h:541
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:563
tresult resetToDefault()
Resets the param to its default value.
Definition: GUIJmbParameter.h:550
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:440
Definition: GUIState.h:37
tresult handleMessage(Message const &iMessage) override
Definition: GUIJmbParameter.h:68
tresult setValue(int32 const &iDiscreteValue) override
Unconditionally 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:593
constexpr T const * operator->() const
Definition: GUIJmbParameter.h:566
std::shared_ptr< GUIJmbParameter< T > > fPtr
Definition: GUIJmbParameter.h:599
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIJmbParameter.h:495
std::shared_ptr< GUIJmbParameter< T > > fJmbParameter
Definition: GUIJmbParameter.h:446
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:511
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
std::unique_ptr< EditorType > Editor
Definition: GUIJmbParameter.h:500
tresult resetToDefault() override
Resets the parameter to its default value.
Definition: GUIJmbParameter.h:423
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:553
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:503
ParamType const & getValue() const
Definition: GUIJmbParameter.h:252
typename GUIJmbParameter< UTF8String >::EditorType EditorType
Definition: GUIJmbParameter.h:499
std::shared_ptr< GUIDiscreteParameter > asDiscreteParameter(int32 iStepCount) override
Converts this parameter into a discrete parameter.
Definition: GUIJmbParameter.h:454
void broadcast(T &&iValue)
Definition: GUIJmbParameter.h:582
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:596
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:514
Editor edit(T const &iValue)
Definition: GUIJmbParameter.h:546
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:537
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:236
std::string toUTF8String(int32 iPrecision) const
Returns the current value of the parameter as a string (which is properly UTF-8 encoded).
Definition: GUIJmbParameter.h:590
virtual tresult readFromStream(IBStreamer &iStreamer)=0
T const & value() const
Synonym to getValue()
Definition: GUIJmbParameter.h:556
std::shared_ptr< IDiscreteConverter< T > > fConverter
Definition: GUIJmbParameter.h:447
Base class for all non vst parameters (need to provide serialization/deserialization)
Definition: ParamDef.h:316
tresult broadcast() const
Definition: GUIJmbParameter.h:572
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:279
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