Jamba C++ API  6.3.0
ParamLine.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 
19 #pragma once
20 
21 #include "ParamDisplay.h"
22 
23 #include <sstream>
24 
25 namespace pongasoft {
26 namespace VST {
27 namespace Debug {
28 
32 class ParamLine
33 {
34 public:
35  explicit ParamLine(ParamDisplay iParamDisplay) : fParamDisplay{std::move(iParamDisplay)} {}
36 
37  ParamLine &precision(int32 iPrecision) { fParamDisplay.precision(iPrecision); return *this; }
38  ParamLine &keys(std::vector<ParamDisplay::Key> const &iKeys) { fParamDisplay.keys(iKeys); return *this; };
39  ParamLine &key(ParamDisplay::Key iKey) { fParamDisplay.key(iKey); return *this; }
40  ParamLine &ids(std::vector<ParamID> const &iParamIDs) { fParamDisplay.ids(iParamIDs); return *this; };
41  ParamLine &id(ParamID iParamID) { fParamDisplay.id(iParamID); return *this; };
42  ParamLine &firstSeparator(std::string iString) { fFirstSeparator = std::move(iString); return *this; }
43  ParamLine &nextSeparator(std::string iString) { fNextSeparator = std::move(iString); return *this; }
44  ParamLine &paramSeparator(std::string iString) { fParamSeparator = std::move(iString); return *this; }
45  ParamLine &skipEmptyEntry(bool iFlag = true) { fSkipEmptyEntry = iFlag; return *this; }
46 
47  // returns a line representation of the params
48  std::string toString() const;
49 
50  // returns a line representation of normalized state
51  std::string toString(NormalizedState const &iNormalizedState) const;
52 
53 public:
57  static ParamLine from(Parameters const &iParams);
58 
62  static ParamLine from(RT::RTState const *iState, bool iSaveStateOnly = false);
63 
67  static ParamLine from(GUI::GUIState const *iState, bool iSaveStateOnly = false);
68 
69 protected:
70  // toString
71  std::string toString(ParamDisplay::ParamMap const &iParamMap) const;
72 
73 private:
75 
76  std::string fFirstSeparator{"="};
77  std::string fNextSeparator{"/"};
78  std::string fParamSeparator{", "};
79  bool fSkipEmptyEntry{true};
80 };
81 
82 }
83 }
84 }
This is the class which maintains all the registered parameters.
Definition: Parameters.h:37
Definition: GUIState.h:41
ParamLine & precision(int32 iPrecision)
Definition: ParamLine.h:37
std::string fFirstSeparator
Definition: ParamLine.h:76
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition: ParamDisplay.h:33
Key
Definition: ParamDisplay.h:36
Definition: Clock.h:22
ParamDisplay & keys(std::vector< Key > const &iKeys)
Definition: ParamDisplay.h:68
ParamDisplay & id(ParamID iParamID)
Definition: ParamDisplay.h:71
ParamLine & id(ParamID iParamID)
Definition: ParamLine.h:41
ParamLine(ParamDisplay iParamDisplay)
Definition: ParamLine.h:35
This helper class is used to display the parameters (vst/jmb) in a line WARNING: this class is alloca...
Definition: ParamLine.h:32
ParamDisplay & precision(int32 iPrecision)
Definition: ParamDisplay.h:67
ParamDisplay fParamDisplay
Definition: ParamLine.h:74
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition: RTState.h:44
ParamLine & nextSeparator(std::string iString)
Definition: ParamLine.h:43
std::string toString() const
Definition: ParamLine.cpp:69
Used to communicate the state between the UI and the RT and read/write to stream.
Definition: NormalizedState.h:37
ParamLine & skipEmptyEntry(bool iFlag=true)
Definition: ParamLine.h:45
ParamLine & paramSeparator(std::string iString)
Definition: ParamLine.h:44
ParamLine & keys(std::vector< ParamDisplay::Key > const &iKeys)
Definition: ParamLine.h:38
ParamLine & ids(std::vector< ParamID > const &iParamIDs)
Definition: ParamLine.h:40
bool fSkipEmptyEntry
Definition: ParamLine.h:79
ParamDisplay & key(Key iKey)
Definition: ParamDisplay.h:69
std::map< ParamID, ValueMap > ParamMap
Definition: ParamDisplay.h:59
static ParamLine from(Parameters const &iParams)
Shortcut to create a table for all registered parameter (definition not current value)
Definition: ParamLine.cpp:87
ParamDisplay & ids(std::vector< ParamID > const &iParamIDs)
Definition: ParamDisplay.h:70
ParamLine & firstSeparator(std::string iString)
Definition: ParamLine.h:42
std::string fParamSeparator
Definition: ParamLine.h:78
std::string fNextSeparator
Definition: ParamLine.h:77
ParamLine & key(ParamDisplay::Key iKey)
Definition: ParamLine.h:39