Jamba  3.0.2
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 }
ParamLine & paramSeparator(std::string iString)
Definition: ParamLine.h:44
ParamLine(ParamDisplay iParamDisplay)
Definition: ParamLine.h:35
std::string fNextSeparator
Definition: ParamLine.h:77
ParamDisplay & precision(int32 iPrecision)
Definition: ParamDisplay.h:67
Definition: Parameters.h:39
Definition: GUIState.h:39
Definition: ParamDisplay.h:33
ParamDisplay & ids(std::vector< ParamID > const &iParamIDs)
Definition: ParamDisplay.h:70
ParamLine & ids(std::vector< ParamID > const &iParamIDs)
Definition: ParamLine.h:40
ParamDisplay & key(Key iKey)
Definition: ParamDisplay.h:69
Definition: Clock.h:22
std::string fFirstSeparator
Definition: ParamLine.h:76
Definition: ParamLine.h:32
Definition: RTState.h:43
ParamLine & nextSeparator(std::string iString)
Definition: ParamLine.h:43
Definition: NormalizedState.h:38
ParamLine & keys(std::vector< ParamDisplay::Key > const &iKeys)
Definition: ParamLine.h:38
ParamLine & key(ParamDisplay::Key iKey)
Definition: ParamLine.h:39
ParamDisplay & keys(std::vector< Key > const &iKeys)
Definition: ParamDisplay.h:68
ParamLine & skipEmptyEntry(bool iFlag=true)
Definition: ParamLine.h:45
ParamLine & id(ParamID iParamID)
Definition: ParamLine.h:41
ParamLine & firstSeparator(std::string iString)
Definition: ParamLine.h:42
std::string fParamSeparator
Definition: ParamLine.h:78
bool fSkipEmptyEntry
Definition: ParamLine.h:79
Key
Definition: ParamDisplay.h:36
static ParamLine from(Parameters const &iParams)
Definition: ParamLine.cpp:87
ParamDisplay fParamDisplay
Definition: ParamLine.h:74
std::string toString() const
Definition: ParamLine.cpp:69
std::map< ParamID, ValueMap > ParamMap
Definition: ParamDisplay.h:59
ParamDisplay & id(ParamID iParamID)
Definition: ParamDisplay.h:71
ParamLine & precision(int32 iPrecision)
Definition: ParamLine.h:37