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.
schemamakeCableSchema (unsigned int n=1)
 Build n cables in parallel.
schemamakeInverterSchema (const string &color)
 Build n cables in parallel.
schemamakeCutSchema ()
 Creates a new Cut schema.
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.
schemamakeParSchema (schema *s1, schema *s2)
schemamakeSeqSchema (schema *s1, schema *s2)
 Make a sequential schema.
schemamakeMergeSchema (schema *s1, schema *s2)
 Creates a new merge schema.
schemamakeSplitSchema (schema *s1, schema *s2)
 Creates a new split schema.
schemamakeRecSchema (schema *s1, schema *s2)
 Creates a new recursive schema (s1 ~ s2).
schemamakeTopSchema (schema *s1, double margin, const string &text, const string &link)
 Creates a new top schema.
schemamakeDecorateSchema (schema *s1, double margin, const string &text)
 Creates a new decorated schema.

Variables

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

Enumeration Type Documentation

anonymous enum
Enumerator:
kLeftRight 
kRightLeft 

Definition at line 90 of file schema.h.


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 40 of file blockSchema.cpp.

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

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

{
    // determine the optimal size of the box
    double minimal = 3*dWire;
    double w = 2*dHorz + max( minimal, quantize(text.size()) );
    double h = 2*dVert + max( minimal, max(inputs, outputs) * dWire );

    return new blockSchema(inputs, outputs, w, h, text, color, link);
}

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().

{
    assert(n>0);
    return new cableSchema(n);
}

Here is the caller graph for this function:

Creates a new Cut schema.

Definition at line 33 of file cutSchema.cpp.

Referenced by generateInsideSchema().

{
    return new cutSchema();
}

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().

{
    return new decorateSchema (s, margin, text);
}

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().

{
    if (width > s->width()) {
        return new enlargedSchema(s, width);
    } else {
        return s;
    }
}

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 35 of file inverterSchema.cpp.

Referenced by generateInsideSchema().

{
    return new inverterSchema(color);
}

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().

{
    // avoid ugly diagram by ensuring at least dWire width
    schema * a = makeEnlargedSchema(s1, dWire);
    schema * b = makeEnlargedSchema(s2, dWire);
    double  hgap = (a->height()+b->height())/4;
    return new mergeSchema(a,b,hgap);
}

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 generateAbstractionSchema(), generateInsideSchema(), and makeSeqSchema().

{
    // make sure s1 and s2 have same width
    return new parSchema(   makeEnlargedSchema(s1, s2->width()),
                            makeEnlargedSchema(s2, s1->width()) );
}

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().

{
    schema* a = makeEnlargedSchema(s1, s2->width());
    schema* b = makeEnlargedSchema(s2, s1->width());
    double  m = dWire * max(b->inputs(), b->outputs());
    double  w = a->width() + 2*m;

    return new recSchema(a,b,w);
}

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 generateAbstractionSchema(), and generateInsideSchema().

{
    unsigned int o = s1->outputs();
    unsigned int i = s2->inputs();

    schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
    schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;

    return new seqSchema(a, b, computeHorzGap(a,b));
}

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().

{
    // make sure a and b are at least dWire large
    schema * a = makeEnlargedSchema(s1, dWire);
    schema * b = makeEnlargedSchema(s2, dWire);

    // horizontal gap to avaoid too slopy connections
    double  hgap = (a->height()+b->height())/4;

    return new splitSchema(a,b,hgap);
}

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().

{
    return new topSchema (makeDecorateSchema(s, margin/2, text), margin/2, "", link);
}

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