Strumenti Utente

Strumenti Sito


magistraleinformaticanetworking:spm:supportorec17

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisione Revisione precedente
Prossima revisione
Revisione precedente
magistraleinformaticanetworking:spm:supportorec17 [09/11/2017 alle 18:55 (6 anni fa)]
Marco Danelutto [Timetable]
magistraleinformaticanetworking:spm:supportorec17 [25/01/2018 alle 14:17 (6 anni fa)] (versione attuale)
Marco Danelutto [Course notes]
Linea 13: Linea 13:
 ==== Course notes ==== ==== Course notes ====
 Course notes (last edition) may be found [[http://backus.di.unipi.it/~marcod/SPM1415/spmSept14.pdf|here]] Course notes (last edition) may be found [[http://backus.di.unipi.it/~marcod/SPM1415/spmSept14.pdf|here]]
 +
 +==== Trivial ff_comp implementation ==== 
 +In case, you may use this code to implement a trivial ff_comp that **only accepts sequential stages**. 
 +
 +<code "ff_comp.hpp"> 
 +#ifndef ff_comp_hpp
 +#define ff_comp_hpp
 +
 +#include <ff/node.hpp>
 +#include <vector>
 +#include <functional>
 +#include <initializer_list>
 +
 +using namespace ff;
 +
 +
 +class ff_comp : public ff_node {
 +protected:
 +  std::vector<ff_node *>stages;
 +  int stageno;
 +public:
 +
 +  ff_comp(ff_node *s1, ff_node *s2) {
 +    stages.push_back(s1);
 +    stages.push_back(s2);
 +    stageno = 2;
 +  }
 +
 +  ff_comp(std::initializer_list<ff_node*> pats) {
 +    stageno = 0;
 +    for(auto i = pats.begin(); i != pats.end(); i++) {
 +      stages.push_back(*i);
 +      stageno++;
 +    }
 +  }
 +
 +
 +  // for cloning
 +
 +  ff_comp() {
 +    stageno=0;
 +    return;
 +  }
 +
 +  void add_stage(ff_node * stage) {
 +    stages.push_back(stage);
 +    stageno++;
 +    return;
 +  }
 +
 +  ff_comp * clone() {
 +    ff_comp * p = new ff_comp();
 +    for(int i=0; i<stageno; i++)
 +      p->add_stage(stages[i]);
 +    return(p);
 +  }
 +  // end of bad idea to clone
 +
 +  void * svc (void * t) {
 +    auto x = stages[0]->svc(t);
 +    for(int i=1; i<stageno; i++)
 +      x = stages[i]->svc(x);
 +    return(x);
 +  }
 +};
 +</code>
 ====== Support material 2017 (recovery edition) ====== ====== Support material 2017 (recovery edition) ======
  
Linea 37: Linea 103:
 | spm17c15 | Cosimo Agati | | spm17c15 | Cosimo Agati |
 | spm17c16 | Elena Bucchianeri | | spm17c16 | Elena Bucchianeri |
 +| spm17c17 | Maria Chiara Cecconi |
 +| spm17c18 | Equi Massimo |
  
  
  
  
magistraleinformaticanetworking/spm/supportorec17.1510253702.txt.gz · Ultima modifica: 09/11/2017 alle 18:55 (6 anni fa) da Marco Danelutto