Jamba C++ API 8.0.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::VST::Debug {
31
36{
37public:
38 explicit ParamTable(ParamDisplay iParamDisplay) : fParamDisplay{std::move(iParamDisplay)} {}
39
40public:
41 // builder pattern to initialize the table
42 ParamTable &precision(int32 iPrecision) { fParamDisplay.precision(iPrecision); return *this; }
43 ParamTable &keys(std::vector<ParamDisplay::Key> const &iKeys) { fParamDisplay.keys(iKeys); return *this; }
44 ParamTable &key(ParamDisplay::Key iKey) { fParamDisplay.key(iKey); return *this; }
45 ParamTable &ids(std::vector<ParamID> const &iParamIDs) { fParamDisplay.ids(iParamIDs); return *this; }
46 ParamTable &id(ParamID iParamID) { fParamDisplay.id(iParamID); return *this; }
47 ParamTable &header(bool iDisplayHeader = true) { fDisplayHeader = iDisplayHeader; return *this; }
48 ParamTable &showHeader() { return header(true); }
49 ParamTable &hideHeader() { return header(false); }
50 ParamTable &headerSeparation(bool iDisplayHeaderSeparation = true) { fDisplayHeaderSeparation = iDisplayHeaderSeparation; return *this; }
53 ParamTable &lineSeparation(bool iDisplayLineSeparation = true) { fDisplayLineSeparation = iDisplayLineSeparation; return *this; }
56 ParamTable &cellSeparation(bool iDisplayCellSeparation = true) { fDisplayCellSeparation = iDisplayCellSeparation; return *this; }
59
62
63 // returns the table as a vector of rows
64 std::vector<std::string> rows() const;
65
66 // returns a tabular representation of the params
67 std::string toString() const;
68
69 // print the table
70 void print(std::string const &iFirstLine = "") const;
71
72 // returns the table as a vector of rows
73 std::vector<std::string> rows(NormalizedState const &iNormalizedState) const;
74
75 // returns a tabular representation of the params
76 std::string toString(NormalizedState const &iNormalizedState) const;
77
78 // print the table
79 void print(NormalizedState const &iNormalizedState, std::string const &iFirstLine = "") const;
80
81protected:
82 // computeSizes
83 std::string::size_type computeSizes(ParamDisplay::ValueMap const &iHeader,
84 ParamDisplay::ParamMap const &iParams,
85 std::map<ParamDisplay::Key, std::string::size_type> &oSizes) const;
86
87 // computeHeader
89
90 // returns the table as a vector of rows
91 std::vector<std::string> rows(ParamDisplay::ParamMap const &iParamMap) const;
92
93public:
97 static ParamTable from(Parameters const &iParams);
98
102 static ParamTable from(RT::RTState const *iState, bool iSaveStateOnly = false);
103
107 static ParamTable from(GUI::GUIState const *iState, bool iSaveStateOnly = false);
108
109private:
110 bool fDisplayHeader{true};
114
116};
117
118}
119
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition ParamDisplay.h:33
std::map< ParamID, ValueMap > ParamMap
Definition ParamDisplay.h:58
Key
Definition ParamDisplay.h:36
std::map< Key, Value > ValueMap
Definition ParamDisplay.h:57
This helper class is used to display the parameters (vst/jmb) in a table WARNING: this class is alloc...
Definition ParamTable.h:36
ParamDisplay::ValueMap computeHeader() const
Definition ParamTable.cpp:186
bool fDisplayCellSeparation
Definition ParamTable.h:113
ParamTable & compact()
Definition ParamTable.h:60
ParamTable(ParamDisplay iParamDisplay)
Definition ParamTable.h:38
std::string toString() const
Definition ParamTable.cpp:39
bool fDisplayHeaderSeparation
Definition ParamTable.h:111
ParamTable & lineSeparation(bool iDisplayLineSeparation=true)
Definition ParamTable.h:53
ParamTable & headerSeparation(bool iDisplayHeaderSeparation=true)
Definition ParamTable.h:50
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:201
static ParamTable from(Parameters const &iParams)
Shortcut to create a table for all registered parameter (definition not current value).
Definition ParamTable.cpp:240
ParamTable & ids(std::vector< ParamID > const &iParamIDs)
Definition ParamTable.h:45
ParamTable & showHeader()
Definition ParamTable.h:48
ParamTable & id(ParamID iParamID)
Definition ParamTable.h:46
std::vector< std::string > rows() const
Definition ParamTable.cpp:133
ParamTable & showCellSeparation()
Definition ParamTable.h:57
ParamTable & header(bool iDisplayHeader=true)
Definition ParamTable.h:47
ParamTable & showHeaderSeparation()
Definition ParamTable.h:51
ParamTable & key(ParamDisplay::Key iKey)
Definition ParamTable.h:44
ParamTable & cellSeparation(bool iDisplayCellSeparation=true)
Definition ParamTable.h:56
ParamTable & hideCellSeparation()
Definition ParamTable.h:58
ParamTable & hideHeaderSeparation()
Definition ParamTable.h:52
ParamDisplay fParamDisplay
Definition ParamTable.h:115
ParamTable & hideLineSeparation()
Definition ParamTable.h:55
void print(std::string const &iFirstLine="") const
Definition ParamTable.cpp:58
bool fDisplayLineSeparation
Definition ParamTable.h:112
ParamTable & keys(std::vector< ParamDisplay::Key > const &iKeys)
Definition ParamTable.h:43
ParamTable & full()
Definition ParamTable.h:61
ParamTable & precision(int32 iPrecision)
Definition ParamTable.h:42
ParamTable & showLineSeparation()
Definition ParamTable.h:54
ParamTable & hideHeader()
Definition ParamTable.h:49
bool fDisplayHeader
Definition ParamTable.h:110
Definition GUIState.h:45
Used to communicate the state between the UI and the RT and read/write to stream.
Definition NormalizedState.h:39
This is the class that maintains all the registered parameters.
Definition Parameters.h:41
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition RTState.h:45
Definition ParamDisplay.cpp:29