Jamba C++ API  6.3.0
ParamAware.hpp
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 "ParamAware.h"
21 #include "GUIParamCxMgr.h"
22 
24 
25 
26 //------------------------------------------------------------------------
27 // ParamAware::registerOptionalParam
28 //------------------------------------------------------------------------
29 template<typename T>
30 GUIOptionalParam<T> ParamAware::registerOptionalParam(ParamID iParamID, bool iSubscribeToChanges)
31 {
32  if(fParamCxMgr)
33  {
34  return fParamCxMgr->registerOptionalParam<T>(iParamID, iSubscribeToChanges ? this : nullptr);
35  }
36  else
37  return GUIOptionalParam<T>();
38 }
39 
40 //------------------------------------------------------------------------
41 // ParamAware::registerOptionalCallback
42 //------------------------------------------------------------------------
43 template<typename T>
45  Parameters::ChangeCallback iChangeCallback,
46  bool iInvokeCallback)
47 {
48  if(fParamCxMgr)
49  {
50  return fParamCxMgr->registerOptionalCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
51  }
52  else
53  return GUIOptionalParam<T>();
54 }
55 
56 //------------------------------------------------------------------------
57 // ParamAware::registerOptionalCallback
58 //------------------------------------------------------------------------
59 template<typename T>
62  bool iInvokeCallback)
63 {
64  if(fParamCxMgr)
65  {
66  return fParamCxMgr->registerOptionalCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
67  }
68  else
69  return GUIOptionalParam<T>();
70 }
71 
72 //------------------------------------------------------------------------
73 // ParamAware::registerVstParam
74 //------------------------------------------------------------------------
75 template<typename T>
76 GUIVstParam<T> ParamAware::registerVstParam(ParamID iParamID, bool iSubscribeToChanges)
77 {
78  if(fParamCxMgr)
79  return fParamCxMgr->registerVstParam<T>(iParamID, iSubscribeToChanges ? this : nullptr);
80  else
81  return GUIVstParam<T>{};
82 }
83 
84 //------------------------------------------------------------------------
85 // ParamAware::registerVstCallback
86 //------------------------------------------------------------------------
87 template<typename T>
89  Parameters::ChangeCallback iChangeCallback,
90  bool iInvokeCallback)
91 {
92  if(fParamCxMgr)
93  return fParamCxMgr->registerVstCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
94  else
95  return GUIVstParam<T>{};
96 }
97 
98 //------------------------------------------------------------------------
99 // ParamAware::registerVstCallback
100 //------------------------------------------------------------------------
101 template<typename T>
104  bool iInvokeCallback)
105 {
106  if(fParamCxMgr)
107  return fParamCxMgr->registerVstCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
108  else
109  return GUIVstParam<T>{};
110 }
111 
112 //------------------------------------------------------------------------
113 // ParamAware::registerJmbParam
114 //------------------------------------------------------------------------
115 template<typename T>
116 GUIJmbParam<T> ParamAware::registerJmbParam(ParamID iParamID, bool iSubscribeToChanges)
117 {
118  if(fParamCxMgr)
119  return fParamCxMgr->registerJmbParam<T>(iParamID, iSubscribeToChanges ? this : nullptr);
120  else
121  return GUIJmbParam<T>{};
122 }
123 
124 //------------------------------------------------------------------------
125 // ParamAware::registerJmbCallback
126 //------------------------------------------------------------------------
127 template<typename T>
129  Parameters::ChangeCallback iChangeCallback,
130  bool iInvokeCallback)
131 {
132  if(fParamCxMgr)
133  return fParamCxMgr->registerJmbCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
134  else
135  return GUIJmbParam<T>{};
136 }
137 
138 //------------------------------------------------------------------------
139 // ParamAware::registerJmbCallback
140 //------------------------------------------------------------------------
141 template<typename T>
144  bool iInvokeCallback)
145 {
146  if(fParamCxMgr)
147  return fParamCxMgr->registerJmbCallback<T>(iParamID, std::move(iChangeCallback), iInvokeCallback);
148  else
149  return GUIJmbParam<T>{};
150 }
151 
152 }
GUIOptionalParam< T > registerOptionalParam(ParamID iParamID, bool iSubscribeToChanges=true)
Registers an optional parameter which handles Vst, Jmb or no parameter at all.
Definition: ParamAware.hpp:30
GUIVstParam< T > registerVstCallback(ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
Register a callback for a Vst parameter simply given its id The callback will be invoked when the par...
Definition: ParamAware.hpp:88
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
GUIOptionalParam< T > registerOptionalCallback(ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
Registers an optional parameter which handles Vst, Jmb or no parameter at all.
Definition: ParamAware.hpp:44
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIVstParameter.h:278
Definition: GUIState.h:37
GUIJmbParam< T > registerJmbCallback(ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
Registers a callback for the Jmb param by its id and return the wrapper to the param.
Definition: ParamAware.hpp:128
This is the main class that the plugin should use as it exposes only the necessary methods of the par...
Definition: GUIJmbParameter.h:495
GUIVstParam< T > registerVstParam(ParamID iParamID, bool iSubscribeToChanges=true)
Register a Vst parameter simply given its id onParameterChange() will be called on changes (if iSubsc...
Definition: ParamAware.hpp:76
std::unique_ptr< GUIParamCxMgr > fParamCxMgr
Definition: ParamAware.h:551
std::function< void(Param &)> ChangeCallback1
A callback which will be invoked for changes with the param as an argument.
Definition: Parameters.h:61
GUIJmbParam< T > registerJmbParam(ParamID iParamID, bool iSubscribeToChanges=true)
Registers the Jmb param by its id and return the wrapper to the param.
Definition: ParamAware.hpp:116
Represents an optional parameter (Jmb, Vst or no param at all).
Definition: GUIOptionalParam.h:48