| 1 | package de.uka.ipd.sdq.pipesandfilters.framework.filters; |
| 2 | |
| 3 | import de.uka.ipd.sdq.pipesandfilters.framework.PipeData; |
| 4 | |
| 5 | /** |
| 6 | * A simple example filter that drops the first n incoming data elements. All |
| 7 | * following elements are passed forward. This filter serves as a simple warm up |
| 8 | * filter to skip the first n measurements of the experiment run. |
| 9 | * |
| 10 | * @author Baum |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | public class SimpleWarmUpFilter extends Filter { |
| 15 | |
| 16 | private int skip; |
| 17 | private int skipCount = 0; |
| 18 | |
| 19 | /** |
| 20 | * The constructor of a SimpleWarmUpFilter |
| 21 | * |
| 22 | * @param skip |
| 23 | * The number of elements to be dropped at the start. |
| 24 | */ |
| 25 | public SimpleWarmUpFilter(int skip) { |
| 26 | super(); |
| 27 | this.skip = skip; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * This method handles incoming data. The data is dropped if it belongs to |
| 32 | * the first n incoming data elements, else it is forwarded to the next pipe |
| 33 | * element. |
| 34 | */ |
| 35 | public void processData(PipeData p) { |
| 36 | if (skipCount >= skip) { |
| 37 | forwardData(p); |
| 38 | } else { |
| 39 | skipCount++; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | } |