Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
pipe.h
1 /*
2  * pipe.h
3  *
4  * Author: Steffen Ernsting <s.ernsting@uni-muenster.de>
5  *
6  * -------------------------------------------------------------------------------
7  *
8  * The MIT License
9  *
10  * Copyright 2014 Steffen Ernsting <s.ernsting@uni-muenster.de>,
11  * Herbert Kuchen <kuchen@uni-muenster.de.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is
18  * furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  *
31  */
32 
33 #pragma once
34 
35 #include "muesli.h"
36 #include "curry.h"
37 #include "process.h"
38 
39 namespace msl {
40 
41 /* TODO: Beschreibung Überarbeiten! Kommt noch aus Skeleton.h
42  Diese Klasse konstruiert eine Pipeline aus den uebergebenen
43  Prozessen. Ein Prozess kann ein beliebiges Konstrukt aus
44  verschachtelten taskparallelen Skeletten sein. Ein solches
45  Konstrukt hat mindestens einen Eingang (entrances[0]) und
46  Ausgang (exits[0]) zum Empfangen bzw. zum Senden von Daten.
47  Dies entspricht in gewissem Sinne einer Blackbox- Sichtweise.
48  Wie das Konstrukt intern aus anderen Prozessen zusammengesetzt
49  bzw. verknuepft ist, interessiert hier nicht weiter. Es wird
50  lediglich eine Schnittstelle zur Kommunikation mit einem
51  Prozess definiert. Die interne Verknpfung (hier als Pipeline)
52  wird ueber predecessors[] und successors[] erreicht. Der
53  Eingang des Pipe-Konstrukts ist der Eingang des ersten
54  Konstrukts in der Pipe (entrance = p1.getEntrance()) und der
55  Ausgang ist entsprechend der Ausgang des letzten Konstrukts
56  in der Pipe (exit = p3.getExit()). Um die Verkettung zu
57  erreichen muss das erste Konstrukt in der Pipe an den Eingang
58  des zweiten Konstrukts in der Pipe Daten schicken, das zweite
59  Konstrukt in der Pipe an den Eingang des dritten Konstruks usw.
60  (p1.setOut(p2.getEntrance()), p2.setOut(p3.getEntrance())...).
61  Nun muss den Konstrukten noch mitgeteilt werden, von welchem
62  Ausgang eines anderen Konstrukt es Daten empfangen kann. Also
63  Konstrukt 2 erwartet Daten von K1, K3 von K2 etc.
64  (p2.setIn(p1.getExit()),...).
65  */
66 
67 class Pipe: public detail::Process
68 {
69 
70 public:
71 
72  // Constructor for a pipe with two stages
73  Pipe(Process& p1, Process& p2);
74 
75  // Constructor for a pipe with three stages
76  Pipe(Process& p1, Process& p2, Process& p3);
77 
78  // sets successors of the pipe
79  inline void setSuccessors(const std::vector<ProcessorNo>& drn);
80 
81  // sets predecessors of the pipe
82  inline void setPredecessors(const std::vector<ProcessorNo>& src);
83 
84  // start all processes within the pipe
85  void start();
86 
87  // zeigt auf, welche Prozesse in der Pipe haengen
88  void show() const;
89 
90 protected:
91 
92 private:
93  std::vector<Process*> p;
94  int length;
95 
96 };
97 
98 }
99 
100 #include "../src/pipe.cpp"
Definition: process.h:44
Definition: pipe.h:67
Contains global definitions such as macros, functions, enums and classes, and constants in order to c...