1 /************************************************************************ 2 ************************************************************************ 3 FAUST compiler 4 Copyright (C) 2003-2018 GRAME, Centre National de Creation Musicale 5 --------------------------------------------------------------------- 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 ************************************************************************ 20 ************************************************************************/ 21 22 #ifndef __DESCRIPTION__ 23 #define __DESCRIPTION__ 24 25 //------------------------------------ 26 // generation of an xml description 27 //------------------------------------ 28 29 #include <list> 30 #include <map> 31 #include <set> 32 #include <string> 33 34 #include "garbageable.hh" 35 #include "signals.hh" 36 #include "tlib.hh" 37 #include "uitree.hh" 38 39 using namespace std; 40 41 void extractMetadata(const string& fulllabel, string& label, map<string, set<string> >& metadata); 42 string extractName(Tree fulllabel); 43 44 class Description : public virtual Garbageable { 45 string fName; 46 string fAuthor; 47 string fCopyright; 48 string fLicense; 49 string fVersion; 50 map<string, set<string> > fMetadata; 51 52 string fClassName; 53 int fInputs; 54 int fOutputs; 55 int fWidgetID; 56 int fActiveWidgetCount; 57 int fPassiveWidgetCount; 58 list<string> fActiveLines; 59 list<string> fPassiveLines; 60 list<string> fLayoutLines; 61 list<int> fLayoutTabs; 62 63 public: Description()64 Description() 65 : fInputs(0), 66 fOutputs(0), 67 fWidgetID(0), 68 fActiveWidgetCount(0), 69 fPassiveWidgetCount(0) 70 { 71 } 72 name(const string & s)73 Description* name(const string& s) 74 { 75 fName = s; 76 return this; 77 } author(const string & s)78 Description* author(const string& s) 79 { 80 fAuthor = s; 81 return this; 82 } copyright(const string & s)83 Description* copyright(const string& s) 84 { 85 fCopyright = s; 86 return this; 87 } license(const string & s)88 Description* license(const string& s) 89 { 90 fLicense = s; 91 return this; 92 } version(const string & s)93 Description* version(const string& s) 94 { 95 fVersion = s; 96 return this; 97 } 98 className(const string & s)99 Description* className(const string& s) 100 { 101 fClassName = s; 102 return this; 103 } inputs(int n)104 Description* inputs(int n) 105 { 106 fInputs = n; 107 return this; 108 } outputs(int n)109 Description* outputs(int n) 110 { 111 fOutputs = n; 112 return this; 113 } declare(const string & key,const string & value)114 Description* declare(const string& key, const string& value) 115 { 116 fMetadata[key].insert(value); 117 return this; 118 } 119 120 void ui(Tree t); 121 void print(int n, ostream& fout); 122 123 private: 124 void addGroup(int level, Tree t); 125 int addWidget(Tree label, Tree varname, Tree sig); 126 127 void tab(int n, ostream& fout); addActiveLine(const string & l)128 void addActiveLine(const string& l) { fActiveLines.push_back(l); } addPassiveLine(const string & l)129 void addPassiveLine(const string& l) { fPassiveLines.push_back(l); } 130 void addActiveMetadata(Tree label); 131 void addPassiveMetadata(Tree label); addLayoutLine(int n,const string & l)132 void addLayoutLine(int n, const string& l) 133 { 134 fLayoutTabs.push_back(n); 135 fLayoutLines.push_back(l); 136 } 137 }; 138 139 #endif 140