Description Class Reference

#include <description.hh>

List of all members.

Public Member Functions

 Description ()
Descriptionname (const string &s)
Descriptionauthor (const string &s)
Descriptioncopyright (const string &s)
Descriptionlicense (const string &s)
Descriptionversion (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
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 20 of file description.hh.


Constructor & Destructor Documentation

Description::Description (  )  [inline]

Definition at line 41 of file description.hh.

00041                  :  /*fName("Unknow"), 
00042                     fAuthor("Unknow"), 
00043                     fCopyright("Unknow"),
00044                     fLicense("Unknow"), 
00045                     fVersion("Unknow"),*/
00046                     
00047                     fInputs(0),
00048                     fOutputs(0),
00049                     fWidgetID(0),
00050                     fActiveWidgetCount(0),
00051                     fPassiveWidgetCount(0)
00052                     {}


Member Function Documentation

void Description::addActiveLine ( const string &  l  )  [inline, private]

Definition at line 72 of file description.hh.

References fActiveLines.

Referenced by addWidget().

00072 { fActiveLines.push_back(l);}

Here is the caller graph for this function:

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

Definition at line 210 of file description.cpp.

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

Referenced by ui().

00211 {
00212     Tree    label, elements, varname, sig;
00213     const char* groupnames[] = {"vgroup", "hgroup", "tgroup"};
00214     
00215     if (isUiFolder(t, label, elements)) {
00216     
00217         const int       orient = tree2int(left(label));
00218         const char *    str = tree2str(right(label));
00219 
00220         addLayoutLine(level, subst("<group type=\"$0\">", groupnames[orient]));
00221         addLayoutLine(level+1, subst("<label>$0</label>", xmlize(str)));
00222         while (!isNil(elements)) {
00223             addGroup(level+1, right(hd(elements)));
00224             elements = tl(elements);
00225         }       
00226         addLayoutLine(level, "</group>");
00227         
00228     } else if (isUiWidget(t, label, varname, sig)) {
00229             
00230         int w = addWidget(label, varname, sig);
00231         addLayoutLine(level, subst("<widgetref id=\"$0\" />", T(w)));
00232         
00233     } else {
00234         
00235         fprintf(stderr, "error in user interface generation 2\n");
00236         exit(1);
00237         
00238     }
00239 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Description::addLayoutLine ( int  n,
const string &  l 
) [inline, private]

Definition at line 74 of file description.hh.

References fLayoutLines, and fLayoutTabs.

Referenced by addGroup().

00074 { fLayoutTabs.push_back(n); fLayoutLines.push_back(l);}

Here is the caller graph for this function:

void Description::addPassiveLine ( const string &  l  )  [inline, private]

Definition at line 73 of file description.hh.

References fPassiveLines.

Referenced by addWidget().

00073 { fPassiveLines.push_back(l);}

Here is the caller graph for this function:

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

Definition at line 247 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().

00248 {
00249     Tree path, c, x, y, z;
00250     
00251     // add an active widget description
00252     
00253     if ( isSigButton(sig, path) )                   {
00254     
00255         fWidgetID++;
00256         fActiveWidgetCount++;
00257         addActiveLine(subst("<widget type=\"button\" id=\"$0\">", T(fWidgetID)));
00258             addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
00259             addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
00260         addActiveLine("</widget>");
00261             
00262     } else if ( isSigCheckbox(sig, path) )          {
00263     
00264         fWidgetID++;
00265         fActiveWidgetCount++;
00266         addActiveLine(subst("<widget type=\"checkbox\" id=\"$0\">", T(fWidgetID)));
00267             addActiveLine(subst("\t<label>$0</label>", xmlize(tree2str(label))));
00268             addActiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
00269         addActiveLine("</widget>");
00270             
00271     } else if ( isSigVSlider(sig, path,c,x,y,z) )   {
00272     
00273         fWidgetID++;
00274         fActiveWidgetCount++;
00275         addActiveLine(subst("<widget type=\"vslider\" id=\"$0\">", T(fWidgetID)));
00276             addActiveLine(subst("\t<label>$0</label>",      xmlize(tree2str(label))));
00277             addActiveLine(subst("\t<varname>$0</varname>",  tree2str(varname)));
00278             addActiveLine(subst("\t<init>$0</init>",        T(tree2double(c))));
00279             addActiveLine(subst("\t<min>$0</min>",          T(tree2double(x))));
00280             addActiveLine(subst("\t<max>$0</max>",          T(tree2double(y))));
00281             addActiveLine(subst("\t<step>$0</step>",        T(tree2double(z))));
00282         addActiveLine("</widget>");
00283             
00284     } else if ( isSigHSlider(sig, path,c,x,y,z) )   {
00285     
00286         fWidgetID++;
00287         fActiveWidgetCount++;
00288         addActiveLine(subst("<widget type=\"hslider\" id=\"$0\">", T(fWidgetID)));
00289             addActiveLine(subst("\t<label>$0</label>",      xmlize(tree2str(label))));
00290             addActiveLine(subst("\t<varname>$0</varname>",  tree2str(varname)));
00291             addActiveLine(subst("\t<init>$0</init>",        T(tree2double(c))));
00292             addActiveLine(subst("\t<min>$0</min>",          T(tree2double(x))));
00293             addActiveLine(subst("\t<max>$0</max>",          T(tree2double(y))));
00294             addActiveLine(subst("\t<step>$0</step>",        T(tree2double(z))));
00295         addActiveLine("</widget>");
00296             
00297     } else if ( isSigNumEntry(sig, path,c,x,y,z) )  {
00298     
00299         fWidgetID++;
00300         fActiveWidgetCount++;
00301         addActiveLine(subst("<widget type=\"nentry\" id=\"$0\">", T(fWidgetID)));
00302             addActiveLine(subst("\t<label>$0</label>",      xmlize(tree2str(label))));
00303             addActiveLine(subst("\t<varname>$0</varname>",  tree2str(varname)));
00304             addActiveLine(subst("\t<init>$0</init>",        T(tree2double(c))));
00305             addActiveLine(subst("\t<min>$0</min>",          T(tree2double(x))));
00306             addActiveLine(subst("\t<max>$0</max>",          T(tree2double(y))));
00307             addActiveLine(subst("\t<step>$0</step>",        T(tree2double(z))));
00308         addActiveLine("</widget>");
00309 
00310             
00311     // add a passive widget description
00312     
00313     } else if ( isSigVBargraph(sig,path,x,y,z) )    {
00314     
00315         fWidgetID++;
00316         fPassiveWidgetCount++;
00317         addPassiveLine(subst("<widget type=\"vbargraph\" id=\"$0\">", T(fWidgetID)));
00318             addPassiveLine(subst("\t<label>$0</label>",     xmlize(tree2str(label))));
00319             addPassiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
00320             addPassiveLine(subst("\t<min>$0</min>",         T(tree2double(x))));
00321             addPassiveLine(subst("\t<max>$0</max>",         T(tree2double(y))));
00322         addPassiveLine("</widget>");
00323         
00324     } else if ( isSigHBargraph(sig,path,x,y,z) )    {
00325     
00326         fWidgetID++;
00327         fPassiveWidgetCount++;
00328         addPassiveLine(subst("<widget type=\"hbargraph\" id=\"$0\">", T(fWidgetID)));
00329             addPassiveLine(subst("\t<label>$0</label>",     xmlize(tree2str(label))));
00330             addPassiveLine(subst("\t<varname>$0</varname>", tree2str(varname)));
00331             addPassiveLine(subst("\t<min>$0</min>",         T(tree2double(x))));
00332             addPassiveLine(subst("\t<max>$0</max>",         T(tree2double(y))));
00333         addPassiveLine("</widget>");
00334         
00335     } else {
00336         fprintf(stderr, "Error describing widget : unrecognized expression\n");
00337         exit(1);
00338     }
00339 
00340     return fWidgetID;
00341 }

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 55 of file description.hh.

References fAuthor.

Referenced by main().

00055 { fAuthor = s;  return this; }

Here is the caller graph for this function:

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

Definition at line 56 of file description.hh.

References fCopyright.

Referenced by main().

00056 { fCopyright = s; return this; }

Here is the caller graph for this function:

Description* Description::inputs ( int  n  )  [inline]

Definition at line 60 of file description.hh.

References fInputs.

Referenced by main().

00060 { fInputs = n;  return this; }

Here is the caller graph for this function:

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

Definition at line 57 of file description.hh.

References fLicense.

Referenced by main().

00057 { fLicense = s; return this; }

Here is the caller graph for this function:

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

Definition at line 54 of file description.hh.

References fName.

Referenced by main().

00054 { fName = s;    return this; }

Here is the caller graph for this function:

Description* Description::outputs ( int  n  )  [inline]

Definition at line 61 of file description.hh.

References fOutputs.

Referenced by main().

00061 { fOutputs = n; return this; }

Here is the caller graph for this function:

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

Definition at line 151 of file description.cpp.

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

Referenced by main().

00152 {
00153     list<string>::iterator  s;
00154     list<int>::iterator     t;
00155     
00156     tab(n,fout); fout << "<faust>";
00157         
00158         tab(n+1,fout);  fout << "<name>"        << xmlize(fName)        << "</name>";
00159         tab(n+1,fout);  fout << "<author>"      << xmlize(fAuthor)      << "</author>";
00160         tab(n+1,fout);  fout << "<copyright>"   << xmlize(fCopyright)   << "</copyright>";
00161         tab(n+1,fout);  fout << "<license>"     << xmlize(fLicense)     << "</license>";
00162         tab(n+1,fout);  fout << "<version>"     << xmlize(fVersion)     << "</version>";
00163         tab(n+1,fout);  fout << "<inputs>"      << fInputs              << "</inputs>";
00164         tab(n+1,fout);  fout << "<outputs>"     << fOutputs             << "</outputs>";
00165     
00166         tab(n+1,fout);  fout << "<ui>";
00167 
00168             // active widget list
00169             tab(n+2,fout);  fout << "<activewidgets>";
00170                 tab(n+3,fout);  fout << "<count>" << fActiveWidgetCount << "</count>";
00171                 for (s = fActiveLines.begin(); s != fActiveLines.end(); s++) {
00172                     tab(n+3, fout); fout << *s;
00173                 }
00174             tab(n+2,fout);  fout << "</activewidgets>";
00175 
00176             tab(n+2,fout);
00177             
00178             // passive widget list
00179             tab(n+2,fout);  fout << "<passivewidgets>";
00180                 tab(n+3,fout);  fout << "<count>" << fPassiveWidgetCount << "</count>";
00181                 for (s = fPassiveLines.begin(); s != fPassiveLines.end(); s++) {
00182                     tab(n+3, fout); fout << *s;
00183                 }
00184             tab(n+2,fout);  fout << "</passivewidgets>";
00185     
00186             
00187             tab(n+2,fout);
00188             
00189             // widget layout 
00190             tab(n+2,fout);  fout << "<layout>";
00191                 for (   t = fLayoutTabs.begin(), s = fLayoutLines.begin();
00192                         s != fLayoutLines.end(); t++, s++) {
00193                     tab(n+3+*t, fout); fout << *s;
00194                 }
00195             tab(n+2,fout);  fout << "</layout>";
00196         
00197         tab(n+1,fout);  fout << "</ui>";
00198 
00199 
00200     tab(n,fout); fout << "</faust>" << endl;
00201      
00202 }

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 241 of file description.cpp.

Referenced by print().

00242 {
00243     fout << '\n';
00244     while (n--) fout << '\t'; 
00245 }

Here is the caller graph for this function:

void Description::ui ( Tree  t  ) 

Definition at line 204 of file description.cpp.

References addGroup().

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

00205 {
00206     addGroup(0,t);
00207 }

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 58 of file description.hh.

References fVersion.

Referenced by main().

00058 { fVersion = s; return this; }

Here is the caller graph for this function:


Member Data Documentation

list<string> Description::fActiveLines [private]

Definition at line 33 of file description.hh.

Referenced by addActiveLine(), and print().

Definition at line 31 of file description.hh.

Referenced by addWidget(), and print().

string Description::fAuthor [private]

Definition at line 23 of file description.hh.

Referenced by author(), and print().

string Description::fCopyright [private]

Definition at line 24 of file description.hh.

Referenced by copyright(), and print().

int Description::fInputs [private]

Definition at line 28 of file description.hh.

Referenced by inputs(), and print().

list<string> Description::fLayoutLines [private]

Definition at line 35 of file description.hh.

Referenced by addLayoutLine(), and print().

list<int> Description::fLayoutTabs [private]

Definition at line 36 of file description.hh.

Referenced by addLayoutLine(), and print().

string Description::fLicense [private]

Definition at line 25 of file description.hh.

Referenced by license(), and print().

string Description::fName [private]

Definition at line 22 of file description.hh.

Referenced by name(), and print().

int Description::fOutputs [private]

Definition at line 29 of file description.hh.

Referenced by outputs(), and print().

list<string> Description::fPassiveLines [private]

Definition at line 34 of file description.hh.

Referenced by addPassiveLine(), and print().

Definition at line 32 of file description.hh.

Referenced by addWidget(), and print().

string Description::fVersion [private]

Definition at line 26 of file description.hh.

Referenced by print(), and version().

int Description::fWidgetID [private]

Definition at line 30 of file description.hh.

Referenced by addWidget().


The documentation for this class was generated from the following files:
Generated on Tue Aug 10 08:04:20 2010 for FAUST compiler by  doxygen 1.6.3