FAUST compiler  0.9.9.6b8
Classes | Enumerations | Functions | Variables
schema.h File Reference
#include "device.h"
#include <vector>
#include <string>
#include <set>
Include dependency graph for schema.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  point
 
struct  trait
 
struct  collector
 
class  schema
 An abstract block diagram schema. More...
 

Enumerations

enum  { kLeftRight =1, kRightLeft =-1 }
 

Functions

schemamakeBlockSchema (unsigned int inputs, unsigned int outputs, const string &name, const string &color, const string &link)
 Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link. More...
 
schemamakeCableSchema (unsigned int n=1)
 Build n cables in parallel. More...
 
schemamakeInverterSchema (const string &color)
 Build n cables in parallel. More...
 
schemamakeCutSchema ()
 Creates a new Cut schema. More...
 
schemamakeEnlargedSchema (schema *s, double width)
 Returns an enlarged schema, but only if really needed that is if the requiered width is greater that the schema width. More...
 
schemamakeParSchema (schema *s1, schema *s2)
 
schemamakeSeqSchema (schema *s1, schema *s2)
 Make a sequential schema. More...
 
schemamakeMergeSchema (schema *s1, schema *s2)
 Creates a new merge schema. More...
 
schemamakeSplitSchema (schema *s1, schema *s2)
 Creates a new split schema. More...
 
schemamakeRecSchema (schema *s1, schema *s2)
 Creates a new recursive schema (s1 ~ s2). More...
 
schemamakeTopSchema (schema *s1, double margin, const string &text, const string &link)
 Creates a new top schema. More...
 
schemamakeDecorateSchema (schema *s1, double margin, const string &text)
 Creates a new decorated schema. More...
 
schemamakeConnectorSchema ()
 Connectors are used to ensure unused inputs and outputs are drawn. More...
 

Variables

const double dWire = 8
 distance between two wires More...
 
const double dLetter = 4.3
 width of a letter More...
 
const double dHorz = 4
 marge horizontale More...
 
const double dVert = 4
 marge verticale More...
 

Enumeration Type Documentation

anonymous enum
Enumerator
kLeftRight 
kRightLeft 

Definition at line 90 of file schema.h.

90 { kLeftRight=1, kRightLeft=-1 };

Function Documentation

schema* makeBlockSchema ( unsigned int  inputs,
unsigned int  outputs,
const string &  text,
const string &  color,
const string &  link 
)

Build a simple colored blockSchema with a certain number of inputs and outputs, a text to be displayed, and an optional link.

Computes the size of the box according to the length of the text and the maximum number of ports.

Definition at line 41 of file blockSchema.cpp.

References dHorz, dVert, dWire, max(), and quantize().

Referenced by generateBargraphSchema(), generateDiagramSchema(), generateInputSlotSchema(), generateInsideSchema(), generateOutputSlotSchema(), and generateUserInterfaceSchema().

46 {
47  // determine the optimal size of the box
48  double minimal = 3*dWire;
49  double w = 2*dHorz + max( minimal, quantize((int)text.size()) );
50  double h = 2*dVert + max( minimal, max(inputs, outputs) * dWire );
51 
52  return new blockSchema(inputs, outputs, w, h, text, color, link);
53 }
const double dWire
distance between two wires
Definition: schema.h:33
const double dVert
marge verticale
Definition: schema.h:37
double max(double x, double y)
Definition: interval.hh:60
static double quantize(int n)
Definition: blockSchema.cpp:28
A simple rectangular box with a text and inputs and outputs.
Definition: blockSchema.h:35
const double dHorz
marge horizontale
Definition: schema.h:36

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeCableSchema ( unsigned int  n = 1)

Build n cables in parallel.

Definition at line 32 of file cableSchema.cpp.

Referenced by generateInsideSchema(), and makeSeqSchema().

33 {
34  assert(n>0);
35  return new cableSchema(n);
36 }
Simple cables (identity box) in parallel.
Definition: cableSchema.h:34

Here is the caller graph for this function:

schema* makeConnectorSchema ( )

Connectors are used to ensure unused inputs and outputs are drawn.

Definition at line 33 of file connectorSchema.cpp.

Referenced by addSchemaInputs(), and addSchemaOutputs().

34 {
35  return new connectorSchema();
36 }
A simple rectangular box with a text and inputs and outputs.

Here is the caller graph for this function:

schema* makeCutSchema ( )

Creates a new Cut schema.

Definition at line 33 of file cutSchema.cpp.

Referenced by generateInsideSchema().

34 {
35  return new cutSchema();
36 }
Terminate a cable (cut box)
Definition: cutSchema.h:32

Here is the caller graph for this function:

schema* makeDecorateSchema ( schema s1,
double  margin,
const string &  text 
)

Creates a new decorated schema.

Definition at line 31 of file decorateSchema.cpp.

Referenced by generateDiagramSchema(), generateInsideSchema(), and makeTopSchema().

32 {
33  return new decorateSchema (s, margin, text);
34 }
A decorateSchema is a schema surrounded by a dashed rectangle with a label on the top left...

Here is the caller graph for this function:

schema* makeEnlargedSchema ( schema s,
double  width 
)

Returns an enlarged schema, but only if really needed that is if the requiered width is greater that the schema width.

Definition at line 32 of file enlargedSchema.cpp.

References schema::width().

Referenced by makeMergeSchema(), makeParSchema(), makeRecSchema(), and makeSplitSchema().

33 {
34  if (width > s->width()) {
35  return new enlargedSchema(s, width);
36  } else {
37  return s;
38  }
39 }
An enlarged schema.
double width() const
Definition: schema.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeInverterSchema ( const string &  color)

Build n cables in parallel.

Definition at line 36 of file inverterSchema.cpp.

Referenced by generateInsideSchema().

37 {
38  return new inverterSchema(color);
39 }
An inverter : a special symbol corresponding to '*(-1)' to create more compact diagrams.

Here is the caller graph for this function:

schema* makeMergeSchema ( schema s1,
schema s2 
)

Creates a new merge schema.

Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.

Definition at line 35 of file mergeSchema.cpp.

References dWire, schema::height(), and makeEnlargedSchema().

Referenced by generateInsideSchema().

36 {
37  // avoid ugly diagram by ensuring at least dWire width
38  schema * a = makeEnlargedSchema(s1, dWire);
39  schema * b = makeEnlargedSchema(s2, dWire);
40  double hgap = (a->height()+b->height())/4;
41  return new mergeSchema(a,b,hgap);
42 }
const double dWire
distance between two wires
Definition: schema.h:33
Place and connect two diagrams in merge composition.
Definition: mergeSchema.h:33
An abstract block diagram schema.
Definition: schema.h:97
double height() const
Definition: schema.h:127
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeParSchema ( schema s1,
schema s2 
)

Definition at line 28 of file parSchema.cpp.

References makeEnlargedSchema(), and schema::width().

Referenced by addSchemaInputs(), addSchemaOutputs(), generateAbstractionSchema(), generateInsideSchema(), and makeSeqSchema().

29 {
30  // make sure s1 and s2 have same width
31  return new parSchema( makeEnlargedSchema(s1, s2->width()),
32  makeEnlargedSchema(s2, s1->width()) );
33 }
place two schemi in parallel
Definition: parSchema.h:33
double width() const
Definition: schema.h:126
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeRecSchema ( schema s1,
schema s2 
)

Creates a new recursive schema (s1 ~ s2).

The smallest component is enlarged to the width of the other. The left and right horizontal margins are computed according to the number of internal connections.

Definition at line 34 of file recSchema.cpp.

References dWire, makeEnlargedSchema(), max(), and schema::width().

Referenced by generateInsideSchema().

35 {
36  schema* a = makeEnlargedSchema(s1, s2->width());
37  schema* b = makeEnlargedSchema(s2, s1->width());
38  double m = dWire * max(b->inputs(), b->outputs());
39  double w = a->width() + 2*m;
40 
41  return new recSchema(a,b,w);
42 }
const double dWire
distance between two wires
Definition: schema.h:33
double max(double x, double y)
Definition: interval.hh:60
double width() const
Definition: schema.h:126
An abstract block diagram schema.
Definition: schema.h:97
place and connect two diagrams in recursive composition
Definition: recSchema.h:33
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeSeqSchema ( schema s1,
schema s2 
)

Make a sequential schema.

May add cables to ensure the internal connections are between the same number of outputs and inputs. Compute an horizontal gap based on the number of upward and downward connections.

Definition at line 43 of file seqSchema.cpp.

References computeHorzGap(), schema::inputs(), makeCableSchema(), makeParSchema(), and schema::outputs().

Referenced by addSchemaInputs(), addSchemaOutputs(), generateAbstractionSchema(), and generateInsideSchema().

44 {
45  unsigned int o = s1->outputs();
46  unsigned int i = s2->inputs();
47 
48  schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
49  schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;
50 
51  return new seqSchema(a, b, computeHorzGap(a,b));
52 }
unsigned int outputs() const
Definition: schema.h:129
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
unsigned int inputs() const
Definition: schema.h:128
static double computeHorzGap(schema *a, schema *b)
Compute the horizontal gap needed to draw the internal wires.
Definition: seqSchema.cpp:325
Sequential composition.
Definition: seqSchema.h:36
An abstract block diagram schema.
Definition: schema.h:97
schema * makeCableSchema(unsigned int n)
Build n cables in parallel.
Definition: cableSchema.cpp:32

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeSplitSchema ( schema s1,
schema s2 
)

Creates a new split schema.

Cables are enlarged to dWire. The horizontal gap between the two subschema is such that the connections are not too slopy.

Definition at line 34 of file splitSchema.cpp.

References dWire, schema::height(), and makeEnlargedSchema().

Referenced by generateInsideSchema().

35 {
36  // make sure a and b are at least dWire large
37  schema * a = makeEnlargedSchema(s1, dWire);
38  schema * b = makeEnlargedSchema(s2, dWire);
39 
40  // horizontal gap to avaoid too slopy connections
41  double hgap = (a->height()+b->height())/4;
42 
43  return new splitSchema(a,b,hgap);
44 }
const double dWire
distance between two wires
Definition: schema.h:33
place and connect two diagrams in split composition
Definition: splitSchema.h:33
An abstract block diagram schema.
Definition: schema.h:97
double height() const
Definition: schema.h:127
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Here is the call graph for this function:

Here is the caller graph for this function:

schema* makeTopSchema ( schema s1,
double  margin,
const string &  text,
const string &  link 
)

Creates a new top schema.

Definition at line 33 of file topSchema.cpp.

References makeDecorateSchema().

Referenced by writeSchemaFile().

34 {
35  return new topSchema (makeDecorateSchema(s, margin/2, text), margin/2, "", link);
36 }
A topSchema is a schema surrounded by a dashed rectangle with a label on the top left.
Definition: topSchema.h:34
schema * makeDecorateSchema(schema *s, double margin, const string &text)
Creates a new decorated schema.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const double dHorz = 4
const double dLetter = 4.3

width of a letter

Definition at line 35 of file schema.h.

Referenced by decorateSchema::draw(), and quantize().

const double dVert = 4

marge verticale

Definition at line 37 of file schema.h.

Referenced by blockSchema::drawOrientationMark(), blockSchema::drawRectangle(), and makeBlockSchema().

const double dWire = 8