boxcomplexity.cpp File Reference

Implement complexity computation for box diagrams. More...

#include <ostream>
#include "xtended.hh"
#include "boxcomplexity.h"
#include "tlib.hh"
#include "signals.hh"
Include dependency graph for boxcomplexity.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BC   boxComplexity
 internal shortcut to simplify computeBoxComplexity code

Functions

static int computeBoxComplexity (Tree box)
 Compute the complexity of a box expression.
int boxComplexity (Tree box)
 Return the complexity propety of a box expression tree.

Variables

Tree BCOMPLEXITY = tree ("BCOMPLEXITY")
 property Key used to store box complexity

Detailed Description

Implement complexity computation for box diagrams.

Definition in file boxcomplexity.cpp.


Define Documentation

#define BC   boxComplexity

internal shortcut to simplify computeBoxComplexity code

Definition at line 73 of file boxcomplexity.cpp.

Referenced by computeBoxComplexity().


Function Documentation

int boxComplexity ( Tree  box  ) 

Return the complexity propety of a box expression tree.

Return the complexity propety of a box expression tree. If no complexity property exist, it is created an computeBoxComplexity is called do to the job.

Parameters:
box an evaluated box expression tree
Returns:
the complexity of box
See also:
computeBoxComplexity

Definition at line 56 of file boxcomplexity.cpp.

References computeBoxComplexity(), CTree::getProperty(), CTree::setProperty(), tree(), and tree2int().

Referenced by drawSchema(), and generateDiagramSchema().

00057 {
00058     Tree prop = box->getProperty(BCOMPLEXITY);
00059     
00060     if (prop) {
00061         return tree2int(prop);
00062         
00063     } else {
00064         int v = computeBoxComplexity(box);
00065         box->setProperty(BCOMPLEXITY,tree(v));
00066         return v;
00067     }
00068 }

Here is the call graph for this function:

Here is the caller graph for this function:

int computeBoxComplexity ( Tree  box  )  [static]

Compute the complexity of a box expression.

Compute the complexity of a box expression tree according to the complexity of its subexpressions. Basically it counts the number of boxes to be drawn. The box-diagram expression is supposed to be evaluated. It will exit with an error if it is not the case.

Parameters:
box an evaluated box expression tree
Returns:
the complexity of box

Definition at line 87 of file boxcomplexity.cpp.

References BC, getUserData(), isBoxButton(), isBoxCheckbox(), isBoxCut(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxInt(), isBoxMerge(), isBoxNumEntry(), isBoxPar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWire(), max(), min(), and name().

Referenced by boxComplexity().

00088 {
00089     int     i;
00090     double  r;
00091     prim0   p0;
00092     prim1   p1;
00093     prim2   p2;
00094     prim3   p3;
00095     prim4   p4;
00096     prim5   p5;
00097 
00098     Tree    t1, t2, ff, label, cur, min, max, step, type, name, file;
00099     
00100     xtended* xt = (xtended*) getUserData(box);
00101 
00102     
00103     // simple elements 
00104          if (xt)                        return 1;
00105     else if (isBoxInt(box, &i))         return 1; 
00106     else if (isBoxReal(box, &r))        return 1; 
00107 
00108     else if (isBoxCut(box))             return 0; 
00109     else if (isBoxWire(box))            return 0; 
00110      
00111     else if (isBoxPrim0(box, &p0))      return 1;  
00112     else if (isBoxPrim1(box, &p1))      return 1;  
00113     else if (isBoxPrim2(box, &p2))      return 1;  
00114     else if (isBoxPrim3(box, &p3))      return 1;  
00115     else if (isBoxPrim4(box, &p4))      return 1;  
00116     else if (isBoxPrim5(box, &p5))      return 1; 
00117     
00118     // foreign elements 
00119     else if (isBoxFFun(box, ff))        return 1; 
00120     else if (isBoxFConst(box, type, name, file))        
00121                                         return 1; 
00122     else if (isBoxFVar(box, type, name, file))        
00123                                         return 1; 
00124     // slots and symbolic boxes
00125     else if (isBoxSlot(box, &i))        return 1;
00126     else if (isBoxSymbolic(box,t1,t2))  return 1 + BC(t2);
00127     
00128     // block diagram binary operator 
00129     else if (isBoxSeq(box, t1, t2))     return BC(t1) + BC(t2);
00130     else if (isBoxSplit(box, t1, t2))   return BC(t1) + BC(t2);
00131     else if (isBoxMerge(box, t1, t2))   return BC(t1) + BC(t2);
00132     else if (isBoxPar(box, t1, t2))     return BC(t1) + BC(t2);
00133     else if (isBoxRec(box, t1, t2))     return BC(t1) + BC(t2);
00134     
00135     // user interface widgets
00136     else if (isBoxButton(box, label))                       return 1;  
00137     else if (isBoxCheckbox(box, label))                     return 1;  
00138     else if (isBoxVSlider(box, label, cur, min, max, step)) return 1;
00139     else if (isBoxHSlider(box, label, cur, min, max, step)) return 1;
00140     else if (isBoxHBargraph(box, label, min, max))          return 1;
00141     else if (isBoxVBargraph(box, label, min, max))          return 1;
00142     else if (isBoxNumEntry(box, label, cur, min, max, step))return 1;
00143     
00144     // user interface groups
00145     else if (isBoxVGroup(box, label, t1))   return BC(t1);
00146     else if (isBoxHGroup(box, label, t1))   return BC(t1);
00147     else if (isBoxTGroup(box, label, t1))   return BC(t1);
00148 
00149     //a completer
00150     else {
00151         //fout << tree2str(box);
00152         cerr << "ERROR in boxComplexity : not an evaluated box [[  " << *box << " ]]";
00153         exit(-1);
00154     }
00155 
00156     return -1;
00157 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Tree BCOMPLEXITY = tree ("BCOMPLEXITY")

property Key used to store box complexity

Definition at line 41 of file boxcomplexity.cpp.

Generated on Tue Aug 10 08:04:09 2010 for FAUST compiler by  doxygen 1.6.3