FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes
Lateq Class Reference

#include <lateq.hh>

List of all members.

Public Member Functions

 Lateq (const int &numInputs, const int &numOutputs)
 ~Lateq ()
void addInputSigFormula (const string &str)
 Add a line of a latex equation code corresponding to a signal.
void addConstSigFormula (const string &str)
void addParamSigFormula (const string &str)
void addStoreSigFormula (const string &str)
void addRecurSigFormula (const string &str)
void addRDTblSigFormula (const string &str)
void addRWTblSigFormula (const string &str)
void addSelectSigFormula (const string &str)
void addPrefixSigFormula (const string &str)
void addOutputSigFormula (const string &str)
void addUISigFormula (const string &path, const string &str)
void println (ostream &docout)
 Top-level method to print a whole set of compiled LaTeX formulas.
int inputs () const
int outputs () const

Private Member Functions

string makeItemTitle (const unsigned int formulasListSize, const string &titleName)
string makeSignamesList (const list< string > &formulasList, const string &ending)
string makeSignamesList (const vector< list< string > > &formulasListsVector, const string &ending)
 For all "internal" signals.
string getSigName (const string &s)
string makeSigDomain (const list< string > &formulasList)
string getUISigName (const string &s)
char getUISigType (const string &s)
vector< list< string > > makeUISignamesVector (const multimap< string, string > &field)
void printOneLine (const string &section, ostream &docout)
 Print a sorted list of input signals names ("x_i"), on a single line, separated by commas.
void printHierarchy (const string &section, multimap< string, string > &field, ostream &docout)
 Print formulas for user interface signals.
void printDGroup (const string &section, list< string > &field, ostream &docout)
 Print a dgroup environment to auto-break long formulas.
void printMath (const string &section, list< string > &field, ostream &docout)
 Print formulas for select2, select3 and prefix signals.
bool hasNotOnlyEmptyKeys (multimap< string, string > &mm)
 Find out whether all keys of the multimap are empty or not.
void tab (int n, ostream &docout) const
 Simple handling of indentation.

Private Attributes

const int fNumInputs
const int fNumOutputs
list< string > fInputSigsFormulas
 LaTeX formulas to print.
list< string > fConstSigsFormulas
list< string > fParamSigsFormulas
list< string > fStoreSigsFormulas
list< string > fRecurSigsFormulas
list< string > fRDTblSigsFormulas
list< string > fRWTblSigsFormulas
list< string > fSelectSigsFormulas
list< string > fPrefixSigsFormulas
list< string > fOutputSigsFormulas
multimap< string, string > fUISigsFormulas

Detailed Description

Definition at line 56 of file lateq.hh.


Constructor & Destructor Documentation

Lateq::Lateq ( const int &  numInputs,
const int &  numOutputs 
) [inline]

Definition at line 60 of file lateq.hh.

    :   fNumInputs(numInputs), fNumOutputs(numOutputs)
    {}
Lateq::~Lateq ( ) [inline]

Definition at line 64 of file lateq.hh.

{}

Member Function Documentation

void Lateq::addConstSigFormula ( const string &  str) [inline]

Definition at line 68 of file lateq.hh.

Referenced by DocCompiler::generateVariableStore().

{ fConstSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addInputSigFormula ( const string &  str) [inline]

Add a line of a latex equation code corresponding to a signal.

Definition at line 67 of file lateq.hh.

Referenced by DocCompiler::generateInput().

{ fInputSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addOutputSigFormula ( const string &  str) [inline]

Definition at line 76 of file lateq.hh.

Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().

{ fOutputSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addParamSigFormula ( const string &  str) [inline]

Definition at line 69 of file lateq.hh.

Referenced by DocCompiler::generateVariableStore().

{ fParamSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addPrefixSigFormula ( const string &  str) [inline]

Definition at line 75 of file lateq.hh.

Referenced by DocCompiler::generatePrefix().

{ fPrefixSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addRDTblSigFormula ( const string &  str) [inline]

Definition at line 72 of file lateq.hh.

Referenced by DocCompiler::generateDocConstantTbl().

{ fRDTblSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addRecurSigFormula ( const string &  str) [inline]

Definition at line 71 of file lateq.hh.

Referenced by DocCompiler::generateDelayLine(), and DocCompiler::generateDelayVecNoTemp().

{ fRecurSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addRWTblSigFormula ( const string &  str) [inline]

Definition at line 73 of file lateq.hh.

Referenced by DocCompiler::generateDocWriteTbl().

{ fRWTblSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addSelectSigFormula ( const string &  str) [inline]

Definition at line 74 of file lateq.hh.

Referenced by DocCompiler::generateSelect2(), and DocCompiler::generateSelect3().

{ fSelectSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addStoreSigFormula ( const string &  str) [inline]

Definition at line 70 of file lateq.hh.

Referenced by DocCompiler::generateVariableStore().

{ fStoreSigsFormulas.push_back(str); }

Here is the caller graph for this function:

void Lateq::addUISigFormula ( const string &  path,
const string &  str 
) [inline]

Definition at line 77 of file lateq.hh.

Referenced by DocCompiler::generateButton(), DocCompiler::generateCheckbox(), DocCompiler::generateHSlider(), DocCompiler::generateNumEntry(), and DocCompiler::generateVSlider().

{ fUISigsFormulas.insert(make_pair(path, str)); };

Here is the caller graph for this function:

string Lateq::getSigName ( const string &  s) [private]

< Looking for a left member.

< Strip "(t)" argument if exists.

< Strip "[t]" argument if exists (for tables).

< Strip indice if exists.

Definition at line 206 of file lateq.cpp.

Referenced by makeSigDomain().

{
    size_t found;
    string signame;
    
    found = s.find(" =");
    if (found != string::npos) { 
        signame = s.substr (0, found);
    }
    found = s.find("(t)");
    if (found != string::npos) { 
        signame = s.substr (0, found);
    }
    found = signame.find("[t]");
    if (found != string::npos) { 
        signame = s.substr (0, found);
    }
    found = signame.find_last_of("_");
    if (found != string::npos) { 
        signame = signame.substr (0, found);
    }
    
    return signame;
}

Here is the caller graph for this function:

string Lateq::getUISigName ( const string &  s) [private]

< Looking for a UI signal name "{u_?}_{i}(t)".

Definition at line 261 of file lateq.cpp.

Referenced by makeUISignamesVector().

{
    size_t found;
    string signame;
    
    found = s.find("${u_");
    if (found != string::npos) { 
        signame = s.substr (found+1, 12);
    }
    
    return signame;
}

Here is the caller graph for this function:

char Lateq::getUISigType ( const string &  s) [private]

< Looking for a UI signal name "{u_?}_{i}".

Definition at line 275 of file lateq.cpp.

Referenced by makeUISignamesVector().

{
    size_t found;
    char sigtype = '0';
    
    found = s.find("${u_");
    if (found != string::npos) { 
        sigtype = s.at (found+4);
    }
    
    return sigtype;
}

Here is the caller graph for this function:

bool Lateq::hasNotOnlyEmptyKeys ( multimap< string, string > &  mm) [private]

Find out whether all keys of the multimap are empty or not.

In other words : Check that some UIs have a path (non empty).

In other other words : Check that all UIs are not at top-level.

< Look for pairs with empty keys.

Definition at line 454 of file lateq.cpp.

Referenced by printHierarchy().

{
    typedef multimap<string,string>::iterator MMIT;
    pair<MMIT,MMIT> range;
    range = mm.equal_range(""); 
    bool hasOnlyEmptyPaths = (range.first == mm.begin()) && (range.second == mm.end());
    return !hasOnlyEmptyPaths;
}

Here is the caller graph for this function:

int Lateq::inputs ( ) const [inline]

Definition at line 82 of file lateq.hh.

Referenced by DocCompiler::generateInput().

{ return fNumInputs; }

Here is the caller graph for this function:

string Lateq::makeItemTitle ( const unsigned int  formulasListSize,
const string &  titleName 
) [private]

Definition at line 143 of file lateq.cpp.

References gDocMathStringMap.

Referenced by println().

{
    string item     = "\\item ";
    
    /* Plural handling for titles of sub-sets of formulas. */
    string title    = formulasListSize > 1 ? gDocMathStringMap[titleName + "2"] : gDocMathStringMap[titleName + "1"];
    
    return item + title;
}

Here is the caller graph for this function:

string Lateq::makeSigDomain ( const list< string > &  formulasList) [private]

< No indices for single input neither single output.

< Indices "1" for all other single signal.

Definition at line 154 of file lateq.cpp.

References gDocMathStringMap, getSigName(), and to_string().

Referenced by makeSignamesList().

{
    string signame = "";
    string sigDomain = "";
    
    if (formulasList.size() > 0) {
        string firstEq = *(formulasList.begin());
        signame = getSigName(firstEq);
        
        if(formulasList.size() > 1) {
            sigDomain = " $" + signame + "_i$ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(formulasList.size()) + "]$";
        } else {
            if(signame == "x" || signame == "y") {
                sigDomain = " $" + signame + "$"; 
            } else {
                sigDomain = " $" + signame + "_1$"; 
            }
        }
    } else {
        sigDomain = gDocMathStringMap["emptyformulafield"];
    }
    return sigDomain;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string Lateq::makeSignamesList ( const list< string > &  formulasList,
const string &  ending 
) [private]

Definition at line 179 of file lateq.cpp.

References gDocMathStringMap, and makeSigDomain().

Referenced by println().

{
    if (formulasList.size() > 0) {
        return makeSigDomain(formulasList) + " " + ending;
    } else {
        return " (" + gDocMathStringMap["emptyformulafield"] + ")";
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string Lateq::makeSignamesList ( const vector< list< string > > &  formulasListsVector,
const string &  ending 
) [private]

For all "internal" signals.

Definition at line 189 of file lateq.cpp.

References gDocMathStringMap, and makeSigDomain().

{
    if (formulasListsVector.size() > 0) {
        vector<list<string> >::const_iterator it;
        string signames = "";
        string sep = " ";
        for (it = formulasListsVector.begin(); it != formulasListsVector.end(); ++it) {
            signames += sep + makeSigDomain(*it);
            (it != (formulasListsVector.end() - 2)) ? sep = ", " : sep = " " + gDocMathStringMap["and"] + " ";
        }
        return signames + " " + ending;
    } else {
        return " (" + gDocMathStringMap["emptyformulafield"] + ")";
    }
}

Here is the call graph for this function:

vector< list< string > > Lateq::makeUISignamesVector ( const multimap< string, string > &  field) [private]

Definition at line 232 of file lateq.cpp.

References getUISigName(), and getUISigType().

Referenced by println().

{
    map<char,unsigned int> uiTypesMap;
    vector<list<string> > uiSignamesVector;
    unsigned int vIndex = 0;
    
    multimap<string,string>::const_iterator it;
    
    for (it = field.begin(); it != field.end(); ++it) {
        char type       = getUISigType(it->second);
        string signame  = getUISigName(it->second);
        
        map<char,unsigned int>::iterator uiTypesIt;
        uiTypesIt = uiTypesMap.find(type);
        if( uiTypesIt != uiTypesMap.end()) {
            uiSignamesVector[uiTypesMap[uiTypesIt->second]].push_back(signame);
        } else {
            ++vIndex;
            uiTypesMap.insert(pair<char,unsigned int>(type, vIndex));
            list<string>* tmpList = new(list<string>);
            tmpList->push_back(signame);
            uiSignamesVector.push_back(*tmpList);
        }
    }
    
    return uiSignamesVector;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int Lateq::outputs ( ) const [inline]

Definition at line 83 of file lateq.hh.

Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().

{ return fNumOutputs; }

Here is the caller graph for this function:

void Lateq::printDGroup ( const string &  section,
list< string > &  field,
ostream &  docout 
) [private]

Print a dgroup environment to auto-break long formulas.

Remarks:
The "dgroup" and "dmath" environments belong to the "breqn" LaTeX package. The stared variants "dgroup*" and "dmath*" force unnumbered equations.
Parameters:
[in]sectionThe title to print for these formulas.
[in]fieldThe list of LaTeX formulas.
[out]docoutThe LaTeX output file to print into.

Definition at line 319 of file lateq.cpp.

References tab().

Referenced by println().

{
    if (field.size() > 0) {
        docout << section << endl;
        tab(1,docout); docout << "\\begin{dgroup*}" << endl;
        list<string>::const_iterator s;
        for (s = field.begin(); s != field.end(); ++s) {
            tab(2,docout); docout << "\\begin{" << "dmath*" << "}" << endl;
            tab(3,docout); docout << "\t" << *s << endl;
            tab(2,docout); docout << "\\end{" << "dmath*" << "}" << endl;
        }
        tab(1,docout); docout << "\\end{dgroup*}" << endl;
        docout << endl;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Lateq::printHierarchy ( const string &  section,
multimap< string, string > &  field,
ostream &  docout 
) [private]

Print formulas for user interface signals.

Parameters:
[in]sectionThe title to print for these formulas.
[in]fieldThis multimap contains pairs :
  1. the path_string is printed as a sub-title item, when new;
  2. each latex_string is printed as a preformated row of the supertabular environment (needed to handle long tables).
[out]docoutThe LaTeX output file to print into.
Remarks:
To decide when one should avoid to print an itemize environment, a "global" strategy is applied : in the particular case where ONLY empty paths were detected in the WHOLE container (all UIs are at the top level). In this particular case, UI strings are directly printed, and their (empty!) path is ignored... In the other case, we have to print an itemize environment and manage paths printing (empty AND non-empty paths) as items.
See also:
DocCompiler::prepareIntervallicUI
DocCompiler::prepareBinaryUI

< Manage itemize printing for pathnames.

< Manage latex indentation offset.

Definition at line 359 of file lateq.cpp.

References gDocMathStringMap, hasNotOnlyEmptyKeys(), and tab().

Referenced by println().

{
    if (field.size() > 0) {
        docout << section << endl;

        bool hasSomePaths = hasNotOnlyEmptyKeys(field); 
        unsigned int n; 
                
        if (hasSomePaths) {
            tab(0,docout); docout << "\\begin{itemize}" << endl;
            n = 1;
        } else {
            n = 0;
        }

        multimap<string,string>::iterator it;
        string uidir = "improbable_starting_dirname";
        bool startFlag = true;

        for (it = field.begin(); it != field.end(); ++it) {
            /* Manage supertabular environment bounds and pathname printing. */
            if (it->first != uidir) {
                if (!startFlag) {
                    tab(n+2,docout); docout << "\\end{supertabular}" << endl;
                    tab(n+1,docout); docout << "\\end{center}" << endl;
                } else { 
                    startFlag = false; 
                }
                if (hasSomePaths) {
                    /* Print the current pathname if new and if pathnames requested. */
                    if (it->first != "") {
                        tab(n+0,docout); docout << "\\item \\textsf{" << it->first << "}" << endl;
                    } else { 
                        tab(n+0,docout); docout << "\\item \\emph{" << gDocMathStringMap["rootlevel"] << "}" << endl;
                    }
                }
                tab(n+1,docout); docout << "\\begin{center}" << endl;
                tab(n+2,docout); docout << "\\begin{supertabular}{lll}" << endl;
            }
            /* Print the current formula. */
            tab(n+3,docout); docout << it->second << endl;
            uidir = it->first;
        }
        tab(n+2,docout); docout << "\\end{supertabular}" << endl;
        tab(n+1,docout); docout << "\\end{center}" << endl;
        if (hasSomePaths) {
            tab(n+0,docout); docout << "\\end{itemize}" << endl;
        }
        docout << endl;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Lateq::println ( ostream &  docout)

Top-level method to print a whole set of compiled LaTeX formulas.

Top-level method to print a whole set of compiled LaTeX formulas, corresponding to an <equation> faustdoc tag.

Remarks:
These formulas must have been previously compiled, via the DocCompile class, and stored in Lateq fields as LaTeX strings.

Definition at line 83 of file lateq.cpp.

References compLateqIndexes(), fConstSigsFormulas, fInputSigsFormulas, fOutputSigsFormulas, fParamSigsFormulas, fPrefixSigsFormulas, fRDTblSigsFormulas, fRecurSigsFormulas, fRWTblSigsFormulas, fSelectSigsFormulas, fStoreSigsFormulas, fUISigsFormulas, gDocMathStringMap, makeItemTitle(), makeSignamesList(), makeUISignamesVector(), printDGroup(), printHierarchy(), printMath(), printOneLine(), and to_string().

Referenced by printDocEqn().

{   
    /* 1. Make titles of sub-sets of formulas. */
    string suchthat     = gDocMathStringMap["suchthat"];
    
    string sInputs      = makeItemTitle(fInputSigsFormulas.size(), "inputsigtitle") + makeSignamesList(fInputSigsFormulas, "");
    string sOutputs     = makeItemTitle(fOutputSigsFormulas.size(), "outputsigtitle") + makeSignamesList(fOutputSigsFormulas, suchthat);
    string sConstants   = makeItemTitle(fConstSigsFormulas.size(), "constsigtitle") + makeSignamesList(fConstSigsFormulas, suchthat);
    
    vector<list<string> > UISignamesVector = makeUISignamesVector(fUISigsFormulas);
    string sUIElements  = makeItemTitle(fUISigsFormulas.size(), "uisigtitle") + makeSignamesList(UISignamesVector, suchthat);

    unsigned int internalSigsCount = fParamSigsFormulas.size() + fStoreSigsFormulas.size() + fRecurSigsFormulas.size() + fRDTblSigsFormulas.size() + fRWTblSigsFormulas.size() + fSelectSigsFormulas.size() + fPrefixSigsFormulas.size();
    
    vector<list<string> > internalSigsFormulasList;
    if( ! fParamSigsFormulas.empty() )  internalSigsFormulasList.push_back(fParamSigsFormulas);
    if( ! fStoreSigsFormulas.empty() )  internalSigsFormulasList.push_back(fStoreSigsFormulas);
    if( ! fRecurSigsFormulas.empty() )  internalSigsFormulasList.push_back(fRecurSigsFormulas);
    if( ! fRDTblSigsFormulas.empty() )  internalSigsFormulasList.push_back(fRDTblSigsFormulas);
    if( ! fRWTblSigsFormulas.empty() )  internalSigsFormulasList.push_back(fRWTblSigsFormulas);
    if( ! fSelectSigsFormulas.empty() ) internalSigsFormulasList.push_back(fSelectSigsFormulas);
    if( ! fPrefixSigsFormulas.empty() ) internalSigsFormulasList.push_back(fPrefixSigsFormulas);
    
    string sInternals   = makeItemTitle(internalSigsCount, "intermedsigtitle") + makeSignamesList(internalSigsFormulasList, suchthat);
    
    /* 2. Successively print each Lateq field containing LaTeX formulas, with a title. */
    
    docout << endl << gDocMathStringMap["lateqcomment"] << endl;
    docout << "\\begin{enumerate}" << endl << endl;
    
    printDGroup     (sOutputs, fOutputSigsFormulas, docout);
    printOneLine    (sInputs, docout);
    const string outputsTitle = "\\item " + sOutputs + "\\ $y_i$\\ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(fOutputSigsFormulas.size()) + "]$: ";
    printHierarchy  (sUIElements, fUISigsFormulas, docout);
    
    /* The "Internal signals" item gather several fields, like a "super-item"... */
    if( internalSigsCount > 0 ) {
        docout << sInternals;
    }
    fStoreSigsFormulas.sort(compLateqIndexes);
    printDGroup     ("", fParamSigsFormulas, docout);
    printDGroup     ("", fStoreSigsFormulas, docout);
    printDGroup     ("", fRecurSigsFormulas, docout);
    printDGroup     ("", fRDTblSigsFormulas, docout);
    printMath       ("", fRWTblSigsFormulas, docout);
    printMath       ("", fSelectSigsFormulas, docout);
    printMath       ("", fPrefixSigsFormulas, docout);

    printDGroup     (sConstants, fConstSigsFormulas, docout);
    
    docout << "\\end{enumerate}" << endl << endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Lateq::printMath ( const string &  section,
list< string > &  field,
ostream &  docout 
) [private]

Print formulas for select2, select3 and prefix signals.

Parameters:
[in]sectionThe title to print for these formulas.
[in]fieldThe list of LaTeX arrays (for braces with two lines).
[out]docoutThe LaTeX output file to print into.
See also:
DocCompiler::generateSelect2
DocCompiler::generateSelect3
DocCompiler::generatePrefix

Definition at line 423 of file lateq.cpp.

Referenced by println().

{
    if (field.size() > 0) {
        docout << section;
        docout << "\\begin{displaymath}" << endl;
        list<string>::iterator s;
        for (s = field.begin(); s != field.end(); ++s) {
            docout << *s << endl;       
        }
        docout << "\\end{displaymath}" << endl;
        docout << endl;     
    }
}

Here is the caller graph for this function:

void Lateq::printOneLine ( const string &  section,
ostream &  docout 
) [private]

Print a sorted list of input signals names ("x_i"), on a single line, separated by commas.

Parameters:
[in]sectionThe title to print for these formulas.
[out]docoutThe LaTeX output file to print into.

Definition at line 302 of file lateq.cpp.

Referenced by println().

{
    docout << section << endl << endl;
}

Here is the caller graph for this function:

void Lateq::tab ( int  n,
ostream &  docout 
) const [private]

Simple handling of indentation.

Definition at line 439 of file lateq.cpp.

Referenced by printDGroup(), and printHierarchy().

{ 
    while (n--) docout << '\t'; 
}

Here is the caller graph for this function:


Member Data Documentation

list<string> Lateq::fConstSigsFormulas [private]

Definition at line 93 of file lateq.hh.

Referenced by println().

list<string> Lateq::fInputSigsFormulas [private]

LaTeX formulas to print.

Definition at line 92 of file lateq.hh.

Referenced by println().

const int Lateq::fNumInputs [private]

Definition at line 88 of file lateq.hh.

const int Lateq::fNumOutputs [private]

Definition at line 89 of file lateq.hh.

list<string> Lateq::fOutputSigsFormulas [private]

Definition at line 101 of file lateq.hh.

Referenced by println().

list<string> Lateq::fParamSigsFormulas [private]

Definition at line 94 of file lateq.hh.

Referenced by println().

list<string> Lateq::fPrefixSigsFormulas [private]

Definition at line 100 of file lateq.hh.

Referenced by println().

list<string> Lateq::fRDTblSigsFormulas [private]

Definition at line 97 of file lateq.hh.

Referenced by println().

list<string> Lateq::fRecurSigsFormulas [private]

Definition at line 96 of file lateq.hh.

Referenced by println().

list<string> Lateq::fRWTblSigsFormulas [private]

Definition at line 98 of file lateq.hh.

Referenced by println().

list<string> Lateq::fSelectSigsFormulas [private]

Definition at line 99 of file lateq.hh.

Referenced by println().

list<string> Lateq::fStoreSigsFormulas [private]

Definition at line 95 of file lateq.hh.

Referenced by println().

multimap<string,string> Lateq::fUISigsFormulas [private]

Definition at line 102 of file lateq.hh.

Referenced by println().


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