FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Description Class Reference

#include <description.hh>

Public Member Functions

 Description ()
 
Descriptionname (const string &s)
 
Descriptionauthor (const string &s)
 
Descriptioncopyright (const string &s)
 
Descriptionlicense (const string &s)
 
Descriptionversion (const string &s)
 
DescriptionclassName (const string &s)
 
Descriptioninputs (int n)
 
Descriptionoutputs (int n)
 
void ui (Tree t)
 
void print (int n, ostream &fout)
 

Private Member Functions

void addGroup (int level, Tree t)
 
int addWidget (Tree label, Tree varname, Tree sig)
 
void tab (int n, ostream &fout)
 
void addActiveLine (const string &l)
 
void addPassiveLine (const string &l)
 
void addLayoutLine (int n, const string &l)
 

Private Attributes

string fName
 
string fAuthor
 
string fCopyright
 
string fLicense
 
string fVersion
 
string fClassName
 
int fInputs
 
int fOutputs
 
int fWidgetID
 
int fActiveWidgetCount
 
int fPassiveWidgetCount
 
list< string > fActiveLines
 
list< string > fPassiveLines
 
list< string > fLayoutLines
 
list< int > fLayoutTabs
 

Detailed Description

Definition at line 23 of file description.hh.

Constructor & Destructor Documentation

Description::Description ( )
inline

Definition at line 45 of file description.hh.

45  : /*fName("Unknow"),
46  fAuthor("Unknow"),
47  fCopyright("Unknow"),
48  fLicense("Unknow"),
49  fVersion("Unknow"),*/
50 
51  fInputs(0),
52  fOutputs(0),
53  fWidgetID(0),
56  {}
int fActiveWidgetCount
Definition: description.hh:35
int fPassiveWidgetCount
Definition: description.hh:36

Member Function Documentation

void Description::addActiveLine ( const string &  l)
inlineprivate

Definition at line 77 of file description.hh.

Referenced by addWidget().

77 { fActiveLines.push_back(l);}
list< string > fActiveLines
Definition: description.hh:37

Here is the caller graph for this function:

void Description::addGroup ( int  level,
Tree  t 
)
private

Definition at line 206 of file description.cpp.

References addLayoutLine(), addWidget(), hd(), isNil(), isUiFolder(), isUiWidget(), left(), right(), subst(), T(), tl(), tree2int(), tree2str(), and xmlize().

Referenced by ui().

207 {
208  Tree label, elements, varname, sig;
209  const char* groupnames[] = {"vgroup", "hgroup", "tgroup"};
210 
211  if (isUiFolder(t, label, elements)) {
212 
213  const int orient = tree2int(left(label));
214  const char * str = tree2str(right(label));
215 
216  addLayoutLine(level, subst("<group type=\"$0\">", groupnames[orient]));
217  addLayoutLine(level+1, subst("<label>$0</label>", xmlize(str)));
218  while (!isNil(elements)) {
219  addGroup(level+1, right(hd(elements)));
220  elements = tl(elements);
221  }
222  addLayoutLine(level, "</group>");
223 
224  } else if (isUiWidget(t, label, varname, sig)) {
225 
226  int w = addWidget(label, varname, sig);
227  addLayoutLine(level, subst("<widgetref id=\"$0\" />", T(w)));
228 
229  } else {
230 
231  fprintf(stderr, "error in user interface generation 2\n");
232  exit(1);
233 
234  }
235 }
Tree left(Tree t)
Definition: list.hh:170
int tree2int(Tree t)
if t has a node of type int, return it otherwise error
Definition: tree.cpp:230
int addWidget(Tree label, Tree varname, Tree sig)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
void addGroup(int level, Tree t)
Tree hd(Tree l)
Definition: list.hh:133
Tree right(Tree t)
Definition: list.hh:171
bool isNil(Tree l)
Definition: list.hh:137
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
string T(char *c)
Definition: Text.cpp:158
bool isUiWidget(Tree t, Tree &label, Tree &varname, Tree &sig)
Definition: uitree.cpp:141
bool isUiFolder(Tree t)
Definition: uitree.cpp:136
static string xmlize(const string &fullsrc)
removes enclosing quotes and transforms '<', '>' and '&' characters
Tree tl(Tree l)
Definition: list.hh:134
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
void addLayoutLine(int n, const string &l)
Definition: description.hh:79

Here is the call graph for this function:

Here is the caller graph for this function:

void Description::addLayoutLine ( int  n,
const string &  l 
)
inlineprivate

Definition at line 79 of file description.hh.

Referenced by addGroup().

79 { fLayoutTabs.push_back(n); fLayoutLines.push_back(l);}
list< string > fLayoutLines
Definition: description.hh:39
list< int > fLayoutTabs
Definition: description.hh:40

Here is the caller graph for this function:

void Description::addPassiveLine ( const string &  l)
inlineprivate

Definition at line 78 of file description.hh.

Referenced by addWidget().

78 { fPassiveLines.push_back(l);}
list< string > fPassiveLines
Definition: description.hh:38

Here is the caller graph for this function:

int Description::addWidget ( Tree  label,
Tree  varname,
Tree  sig 
)
private

Definition at line 243 of file description.cpp.

References addActiveLine(), addPassiveLine(), fActiveWidgetCount, fPassiveWidgetCount, fWidgetID, isSigButton(), isSigCheckbox(), isSigHBargraph(), isSigHSlider(), isSigNumEntry(), isSigVBargraph(), isSigVSlider(), subst(), T(), tree2double(), tree2str(), and xmlize().

Referenced by addGroup().

244 {
245  Tree path, c, x, y, z;
246 
247  // add an active widget description
248 
249  if ( isSigButton(sig, path) ) {
250 
251  fWidgetID++;
253  addActiveLine(subst("<widget type=\"button\" id=\"$0\">", T(fWidgetID)));
254  addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
255  addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
256  addActiveLine("</widget>");
257 
258  } else if ( isSigCheckbox(sig, path) ) {
259 
260  fWidgetID++;
262  addActiveLine(subst("<widget type=\"checkbox\" id=\"$0\">", T(fWidgetID)));
263  addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
264  addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
265  addActiveLine("</widget>");
266 
267  } else if ( isSigVSlider(sig, path,c,x,y,z) ) {
268 
269  fWidgetID++;
271  addActiveLine(subst("<widget type=\"vslider\" id=\"$0\">", T(fWidgetID)));
272  addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
273  addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
274  addActiveLine(subst("\t<init>$0</init>", T(tree2double(c))));
275  addActiveLine(subst("\t<min>$0</min>", T(tree2double(x))));
276  addActiveLine(subst("\t<max>$0</max>", T(tree2double(y))));
277  addActiveLine(subst("\t<step>$0</step>", T(tree2double(z))));
278  addActiveLine("</widget>");
279 
280  } else if ( isSigHSlider(sig, path,c,x,y,z) ) {
281 
282  fWidgetID++;
284  addActiveLine(subst("<widget type=\"hslider\" id=\"$0\">", T(fWidgetID)));
285  addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
286  addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
287  addActiveLine(subst("\t<init>$0</init>", T(tree2double(c))));
288  addActiveLine(subst("\t<min>$0</min>", T(tree2double(x))));
289  addActiveLine(subst("\t<max>$0</max>", T(tree2double(y))));
290  addActiveLine(subst("\t<step>$0</step>", T(tree2double(z))));
291  addActiveLine("</widget>");
292 
293  } else if ( isSigNumEntry(sig, path,c,x,y,z) ) {
294 
295  fWidgetID++;
297  addActiveLine(subst("<widget type=\"nentry\" id=\"$0\">", T(fWidgetID)));
298  addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
299  addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
300  addActiveLine(subst("\t<init>$0</init>", T(tree2double(c))));
301  addActiveLine(subst("\t<min>$0</min>", T(tree2double(x))));
302  addActiveLine(subst("\t<max>$0</max>", T(tree2double(y))));
303  addActiveLine(subst("\t<step>$0</step>", T(tree2double(z))));
304  addActiveLine("</widget>");
305 
306 
307  // add a passive widget description
308 
309  } else if ( isSigVBargraph(sig,path,x,y,z) ) {
310 
311  fWidgetID++;
313  addPassiveLine(subst("<widget type=\"vbargraph\" id=\"$0\">", T(fWidgetID)));
314  addPassiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
315  addPassiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
316  addPassiveLine(subst("\t<min>$0</min>", T(tree2double(x))));
317  addPassiveLine(subst("\t<max>$0</max>", T(tree2double(y))));
318  addPassiveLine("</widget>");
319 
320  } else if ( isSigHBargraph(sig,path,x,y,z) ) {
321 
322  fWidgetID++;
324  addPassiveLine(subst("<widget type=\"hbargraph\" id=\"$0\">", T(fWidgetID)));
325  addPassiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
326  addPassiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
327  addPassiveLine(subst("\t<min>$0</min>", T(tree2double(x))));
328  addPassiveLine(subst("\t<max>$0</max>", T(tree2double(y))));
329  addPassiveLine("</widget>");
330 
331  } else {
332  fprintf(stderr, "Error describing widget : unrecognized expression\n");
333  exit(1);
334  }
335 
336  return fWidgetID;
337 }
bool isSigHSlider(Tree s)
Definition: signals.cpp:217
bool isSigCheckbox(Tree s)
Definition: signals.cpp:205
bool isSigNumEntry(Tree s)
Definition: signals.cpp:257
void addActiveLine(const string &l)
Definition: description.hh:77
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigVBargraph(Tree s)
Definition: signals.cpp:285
bool isSigVSlider(Tree s)
Definition: signals.cpp:237
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
bool isSigHBargraph(Tree s)
Definition: signals.cpp:279
string T(char *c)
Definition: Text.cpp:158
int fActiveWidgetCount
Definition: description.hh:35
int fPassiveWidgetCount
Definition: description.hh:36
double tree2double(Tree t)
if t has a node of type float, return it otherwise error
Definition: tree.cpp:262
void addPassiveLine(const string &l)
Definition: description.hh:78
static string xmlize(const string &fullsrc)
removes enclosing quotes and transforms '<', '>' and '&' characters
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
bool isSigButton(Tree s)
Definition: signals.cpp:199

Here is the call graph for this function:

Here is the caller graph for this function:

Description* Description::author ( const string &  s)
inline

Definition at line 59 of file description.hh.

Referenced by main().

59 { fAuthor = s; return this; }
string fAuthor
Definition: description.hh:26

Here is the caller graph for this function:

Description* Description::className ( const string &  s)
inline

Definition at line 64 of file description.hh.

Referenced by main().

64 { fClassName = s; return this; }
string fClassName
Definition: description.hh:31

Here is the caller graph for this function:

Description* Description::copyright ( const string &  s)
inline

Definition at line 60 of file description.hh.

Referenced by main().

60 { fCopyright = s; return this; }
string fCopyright
Definition: description.hh:27

Here is the caller graph for this function:

Description* Description::inputs ( int  n)
inline

Definition at line 65 of file description.hh.

Referenced by main().

65 { fInputs = n; return this; }

Here is the caller graph for this function:

Description* Description::license ( const string &  s)
inline

Definition at line 61 of file description.hh.

Referenced by main().

61 { fLicense = s; return this; }
string fLicense
Definition: description.hh:28

Here is the caller graph for this function:

Description* Description::name ( const string &  s)
inline

Definition at line 58 of file description.hh.

Referenced by main().

58 { fName = s; return this; }
string fName
Definition: description.hh:25

Here is the caller graph for this function:

Description* Description::outputs ( int  n)
inline

Definition at line 66 of file description.hh.

Referenced by main().

66 { fOutputs = n; return this; }

Here is the caller graph for this function:

void Description::print ( int  n,
ostream &  fout 
)

Definition at line 146 of file description.cpp.

References fActiveLines, fActiveWidgetCount, fAuthor, fClassName, fCopyright, fInputs, fLayoutLines, fLayoutTabs, fLicense, fName, fOutputs, fPassiveLines, fPassiveWidgetCount, fVersion, tab(), and xmlize().

Referenced by main().

147 {
148  list<string>::iterator s;
149  list<int>::iterator t;
150 
151  tab(n,fout); fout << "<faust>";
152 
153  tab(n+1,fout); fout << "<name>" << xmlize(fName) << "</name>";
154  tab(n+1,fout); fout << "<author>" << xmlize(fAuthor) << "</author>";
155  tab(n+1,fout); fout << "<copyright>" << xmlize(fCopyright) << "</copyright>";
156  tab(n+1,fout); fout << "<license>" << xmlize(fLicense) << "</license>";
157  tab(n+1,fout); fout << "<version>" << xmlize(fVersion) << "</version>";
158  tab(n+1,fout); fout << "<classname>" << xmlize(fClassName) << "</classname>";
159  tab(n+1,fout); fout << "<inputs>" << fInputs << "</inputs>";
160  tab(n+1,fout); fout << "<outputs>" << fOutputs << "</outputs>";
161 
162  tab(n+1,fout); fout << "<ui>";
163 
164  // active widget list
165  tab(n+2,fout); fout << "<activewidgets>";
166  tab(n+3,fout); fout << "<count>" << fActiveWidgetCount << "</count>";
167  for (s = fActiveLines.begin(); s != fActiveLines.end(); s++) {
168  tab(n+3, fout); fout << *s;
169  }
170  tab(n+2,fout); fout << "</activewidgets>";
171 
172  tab(n+2,fout);
173 
174  // passive widget list
175  tab(n+2,fout); fout << "<passivewidgets>";
176  tab(n+3,fout); fout << "<count>" << fPassiveWidgetCount << "</count>";
177  for (s = fPassiveLines.begin(); s != fPassiveLines.end(); s++) {
178  tab(n+3, fout); fout << *s;
179  }
180  tab(n+2,fout); fout << "</passivewidgets>";
181 
182 
183  tab(n+2,fout);
184 
185  // widget layout
186  tab(n+2,fout); fout << "<layout>";
187  for ( t = fLayoutTabs.begin(), s = fLayoutLines.begin();
188  s != fLayoutLines.end(); t++, s++) {
189  tab(n+3+*t, fout); fout << *s;
190  }
191  tab(n+2,fout); fout << "</layout>";
192 
193  tab(n+1,fout); fout << "</ui>";
194 
195 
196  tab(n,fout); fout << "</faust>" << endl;
197 
198 }
void tab(int n, ostream &fout)
list< string > fLayoutLines
Definition: description.hh:39
list< string > fActiveLines
Definition: description.hh:37
string fClassName
Definition: description.hh:31
string fVersion
Definition: description.hh:29
list< int > fLayoutTabs
Definition: description.hh:40
string fCopyright
Definition: description.hh:27
int fActiveWidgetCount
Definition: description.hh:35
string fName
Definition: description.hh:25
int fPassiveWidgetCount
Definition: description.hh:36
list< string > fPassiveLines
Definition: description.hh:38
string fLicense
Definition: description.hh:28
string fAuthor
Definition: description.hh:26
static string xmlize(const string &fullsrc)
removes enclosing quotes and transforms '<', '>' and '&' characters

Here is the call graph for this function:

Here is the caller graph for this function:

void Description::tab ( int  n,
ostream &  fout 
)
private

Definition at line 237 of file description.cpp.

Referenced by print().

238 {
239  fout << '\n';
240  while (n--) fout << '\t';
241 }

Here is the caller graph for this function:

void Description::ui ( Tree  t)

Definition at line 200 of file description.cpp.

References addGroup().

Referenced by SchedulerCompiler::compileMultiSignal(), and VectorCompiler::compileMultiSignal().

201 {
202  addGroup(0,t);
203 }
void addGroup(int level, Tree t)

Here is the call graph for this function:

Here is the caller graph for this function:

Description* Description::version ( const string &  s)
inline

Definition at line 62 of file description.hh.

Referenced by main().

62 { fVersion = s; return this; }
string fVersion
Definition: description.hh:29

Here is the caller graph for this function:

Member Data Documentation

list<string> Description::fActiveLines
private

Definition at line 37 of file description.hh.

Referenced by print().

int Description::fActiveWidgetCount
private

Definition at line 35 of file description.hh.

Referenced by addWidget(), and print().

string Description::fAuthor
private

Definition at line 26 of file description.hh.

Referenced by print().

string Description::fClassName
private

Definition at line 31 of file description.hh.

Referenced by print().

string Description::fCopyright
private

Definition at line 27 of file description.hh.

Referenced by print().

int Description::fInputs
private

Definition at line 32 of file description.hh.

Referenced by print().

list<string> Description::fLayoutLines
private

Definition at line 39 of file description.hh.

Referenced by print().

list<int> Description::fLayoutTabs
private

Definition at line 40 of file description.hh.

Referenced by print().

string Description::fLicense
private

Definition at line 28 of file description.hh.

Referenced by print().

string Description::fName
private

Definition at line 25 of file description.hh.

Referenced by print().

int Description::fOutputs
private

Definition at line 33 of file description.hh.

Referenced by print().

list<string> Description::fPassiveLines
private

Definition at line 38 of file description.hh.

Referenced by print().

int Description::fPassiveWidgetCount
private

Definition at line 36 of file description.hh.

Referenced by addWidget(), and print().

string Description::fVersion
private

Definition at line 29 of file description.hh.

Referenced by print().

int Description::fWidgetID
private

Definition at line 34 of file description.hh.

Referenced by addWidget().


The documentation for this class was generated from the following files: