Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
ParamTable.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#pragma once
21
25
26#include "ParamDisplay.h"
27
28#include <string>
29
30namespace pongasoft {
31namespace VST {
32namespace Debug {
33
38{
39public:
40 explicit ParamTable(ParamDisplay iParamDisplay) : fParamDisplay{std::move(iParamDisplay)} {}
41
42public:
43 // builder pattern to initialize the table
44 ParamTable &precision(int32 iPrecision) { fParamDisplay.precision(iPrecision); return *this; }
45 ParamTable &keys(std::vector<ParamDisplay::Key> const &iKeys) { fParamDisplay.keys(iKeys); return *this; };
46 ParamTable &key(ParamDisplay::Key iKey) { fParamDisplay.key(iKey); return *this; }
47 ParamTable &ids(std::vector<ParamID> const &iParamIDs) { fParamDisplay.ids(iParamIDs); return *this; };
48 ParamTable &id(ParamID iParamID) { fParamDisplay.id(iParamID); return *this; };
49 ParamTable &header(bool iDisplayHeader = true) { fDisplayHeader = iDisplayHeader; return *this; };
50 ParamTable &showHeader() { return header(true); };
51 ParamTable &hideHeader() { return header(false); };
52 ParamTable &headerSeparation(bool iDisplayHeaderSeparation = true) { fDisplayHeaderSeparation = iDisplayHeaderSeparation; return *this; };
55 ParamTable &lineSeparation(bool iDisplayLineSeparation = true) { fDisplayLineSeparation = iDisplayLineSeparation; return *this; };
58 ParamTable &cellSeparation(bool iDisplayCellSeparation = true) { fDisplayCellSeparation = iDisplayCellSeparation; return *this; };
61
64
65 // returns the table as a vector of rows
66 std::vector<std::string> rows() const;
67
68 // returns a tabular representation of the params
69 std::string toString() const;
70
71 // print the table
72 void print(std::string const &iFirstLine = "") const;
73
74 // returns the table as a vector of rows
75 std::vector<std::string> rows(NormalizedState const &iNormalizedState) const;
76
77 // returns a tabular representation of the params
78 std::string toString(NormalizedState const &iNormalizedState) const;
79
80 // print the table
81 void print(NormalizedState const &iNormalizedState, std::string const &iFirstLine = "") const;
82
83protected:
84 // computeSizes
85 std::string::size_type computeSizes(ParamDisplay::ValueMap const &iHeader,
86 ParamDisplay::ParamMap const &iParams,
87 std::map<ParamDisplay::Key, std::string::size_type> &oSizes) const;
88
89 // computeHeader
91
92 // returns the table as a vector of rows
93 std::vector<std::string> rows(ParamDisplay::ParamMap const &iParamMap) const;
94
95public:
99 static ParamTable from(Parameters const &iParams);
100
104 static ParamTable from(RT::RTState const *iState, bool iSaveStateOnly = false);
105
109 static ParamTable from(GUI::GUIState const *iState, bool iSaveStateOnly = false);
110
111private:
112 bool fDisplayHeader{true};
116
118};
119
120}
121}
122}
123
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition ParamDisplay.h:35
std::map< ParamID, ValueMap > ParamMap
Definition ParamDisplay.h:60
Key
Definition ParamDisplay.h:38
std::map< Key, Value > ValueMap
Definition ParamDisplay.h:59
This helper class is used to display the parameters (vst/jmb) in a table WARNING: this class is alloc...
Definition ParamTable.h:38
ParamDisplay::ValueMap computeHeader() const
Definition ParamTable.cpp:188
bool fDisplayCellSeparation
Definition ParamTable.h:115
ParamTable & compact()
Definition ParamTable.h:62
ParamTable(ParamDisplay iParamDisplay)
Definition ParamTable.h:40
std::string toString() const
Definition ParamTable.cpp:41
bool fDisplayHeaderSeparation
Definition ParamTable.h:113
ParamTable & lineSeparation(bool iDisplayLineSeparation=true)
Definition ParamTable.h:55
ParamTable & headerSeparation(bool iDisplayHeaderSeparation=true)
Definition ParamTable.h:52
std::string::size_type computeSizes(ParamDisplay::ValueMap const &iHeader, ParamDisplay::ParamMap const &iParams, std::map< ParamDisplay::Key, std::string::size_type > &oSizes) const
Definition ParamTable.cpp:203
static ParamTable from(Parameters const &iParams)
Shortcut to create a table for all registered parameter (definition not current value).
Definition ParamTable.cpp:242
ParamTable & ids(std::vector< ParamID > const &iParamIDs)
Definition ParamTable.h:47
ParamTable & showHeader()
Definition ParamTable.h:50
ParamTable & id(ParamID iParamID)
Definition ParamTable.h:48
std::vector< std::string > rows() const
Definition ParamTable.cpp:135
ParamTable & showCellSeparation()
Definition ParamTable.h:59
ParamTable & header(bool iDisplayHeader=true)
Definition ParamTable.h:49
ParamTable & showHeaderSeparation()
Definition ParamTable.h:53
ParamTable & key(ParamDisplay::Key iKey)
Definition ParamTable.h:46
ParamTable & cellSeparation(bool iDisplayCellSeparation=true)
Definition ParamTable.h:58
ParamTable & hideCellSeparation()
Definition ParamTable.h:60
ParamTable & hideHeaderSeparation()
Definition ParamTable.h:54
ParamDisplay fParamDisplay
Definition ParamTable.h:117
ParamTable & hideLineSeparation()
Definition ParamTable.h:57
void print(std::string const &iFirstLine="") const
Definition ParamTable.cpp:60
bool fDisplayLineSeparation
Definition ParamTable.h:114
ParamTable & keys(std::vector< ParamDisplay::Key > const &iKeys)
Definition ParamTable.h:45
ParamTable & full()
Definition ParamTable.h:63
ParamTable & precision(int32 iPrecision)
Definition ParamTable.h:44
ParamTable & showLineSeparation()
Definition ParamTable.h:56
ParamTable & hideHeader()
Definition ParamTable.h:51
bool fDisplayHeader
Definition ParamTable.h:112
Definition GUIState.h:43
Used to communicate the state between the UI and the RT and read/write to stream.
Definition NormalizedState.h:39
This is the class which maintains all the registered parameters.
Definition Parameters.h:39
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition RTState.h:46
Definition ParamDisplay.cpp:29
Definition Clock.h:24
Definition Clock.h:23