Jamba  3.0.2
NormalizedState.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 <pluginterfaces/vst/vsttypes.h>
21 #include <base/source/fstreamer.h>
22 #include <pongasoft/logging/logging.h>
23 
24 #include <string>
25 #include <vector>
26 
27 namespace pongasoft {
28 namespace VST {
29 
30 using namespace Steinberg::Vst;
31 using namespace Steinberg;
32 
33 class Parameters;
34 
39 {
40 public:
44  struct SaveOrder
45  {
46  int16 fVersion{0};
47  std::vector<ParamID> fOrder{};
48  inline int getCount() const { return static_cast<int>(fOrder.size()); }
49  };
50 
51  // Constructor
52  explicit NormalizedState(SaveOrder const *iSaveOrder);
53 
54  // Destructor
55  ~NormalizedState();
56 
57  // Copy constructor
58  NormalizedState(NormalizedState const &other);
59 
60  // Copies the content of the array ONLY when same SaveOrder (which is the case internally)
61  NormalizedState& operator=(NormalizedState const &other);
62 
63  // getCount
64  inline int getCount() const { return fSaveOrder->getCount(); }
65 
66  // set the param value (check for index bounds)
67  inline void set(int iIdx, ParamValue iParamValue)
68  {
69  DCHECK_F(iIdx >= 0 && iIdx < fSaveOrder->getCount());
70  fValues[iIdx] = iParamValue;
71  }
72 
73  // readFromStream
74  virtual tresult readFromStream(Parameters const *iParameters, IBStreamer &iStreamer);
75 
76  // writeToStream
77  virtual tresult writeToStream(Parameters const *iParameters, IBStreamer &oStreamer) const;
78 
79  // toString
80  std::string toString() const;
81 
82 
83 public:
85  ParamValue *fValues{nullptr};
86 };
87 
88 
89 }
90 }
91 
SaveOrder const * fSaveOrder
Definition: NormalizedState.h:84
Definition: Parameters.h:39
int getCount() const
Definition: NormalizedState.h:64
Definition: Clock.h:22
Definition: NormalizedState.h:44
Definition: NormalizedState.h:38
int getCount() const
Definition: NormalizedState.h:48
void set(int iIdx, ParamValue iParamValue)
Definition: NormalizedState.h:67