1 | package de.uka.ipd.sdq.pipesandfilters.framework; |
2 | |
3 | import java.util.Iterator; |
4 | import java.util.Vector; |
5 | |
6 | import javax.measure.Measure; |
7 | import javax.measure.quantity.Quantity; |
8 | |
9 | /** |
10 | * This class represents the Data objects which are passed and transformed |
11 | * through the pipe and filter chain. Basically it contains a Vector |
12 | * (resultTuple) with Measure objects. Information about the structure and the |
13 | * metrics of the Vector is initially passed through the chain as an instance of |
14 | * MetaDataInit using the initialize method of the Filters. |
15 | * |
16 | * @author Faber |
17 | * @author Baum |
18 | */ |
19 | |
20 | public class PipeData implements Iterable<Measure<?, ? extends Quantity>> { |
21 | |
22 | private final Vector<Measure<?, ? extends Quantity>> resultTuple; |
23 | |
24 | /** |
25 | * The constructor of a pipe data element. |
26 | * |
27 | * @param resultTuple |
28 | * A vector holding the measurement result tuple. |
29 | */ |
30 | public PipeData(Vector<Measure<?, ? extends Quantity>> resultTuple) { |
31 | this.resultTuple = resultTuple; |
32 | } |
33 | |
34 | /** |
35 | * Returns the size of the resultTuple. |
36 | * |
37 | * @return Size of the resultTuple. |
38 | */ |
39 | public int getTupleSize() { |
40 | return resultTuple.size(); |
41 | } |
42 | |
43 | /** |
44 | * Returns the Measure for a given index position from the resultTuple. |
45 | * |
46 | * @param index |
47 | * Identifies the element from the resultTuple. |
48 | * @return The Measure for the index position or null if the index position |
49 | * is invalid. |
50 | */ |
51 | public Measure<?, ? extends Quantity> getTupleElement(int index) { |
52 | return resultTuple.get(index); |
53 | } |
54 | |
55 | /** |
56 | * The iterator method of PipeData |
57 | * |
58 | * @return An iterator of the result tuple. |
59 | */ |
60 | public Iterator<Measure<?, ? extends Quantity>> iterator() { |
61 | return resultTuple.iterator(); |
62 | } |
63 | |
64 | } |