e42f69c372b645b8b42a3969a760c4d1bbca51b2
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / event / matching / TmfEventMatches.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial implementation and API
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.event.matching;
14
15 import java.util.Collection;
16
17 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
18
19 /**
20 * Class that does something with a match.
21 *
22 * This default implementation of the class just counts the matches
23 *
24 * @author Geneviève Bastien
25 */
26 public class TmfEventMatches implements IMatchProcessingUnit {
27
28 private int fMatchCount;
29
30 /**
31 * Constructor
32 */
33 public TmfEventMatches() {
34 fMatchCount = 0;
35 }
36
37 /**
38 * IMatchProcessingUnit overrides
39 */
40 @Override
41 public void init(Collection<ITmfTrace> fTraces) {
42 fMatchCount = 0;
43 }
44
45 @Override
46 public void addMatch(TmfEventDependency match) {
47 fMatchCount++;
48 }
49
50 @Override
51 public void matchingEnded() {
52
53 }
54
55 @Override
56 public int countMatches() {
57 return fMatchCount;
58 }
59
60 /**
61 * Returns the match at the specified index
62 *
63 * @param index
64 * The index of the match to get
65 * @return The match at index or null or not present
66 * @deprecated Matches are not kept anymore, they use up memory for no real reason
67 */
68 @Deprecated
69 public TmfEventDependency getMatch(int index) {
70 return null;
71 }
72
73 @Override
74 public String toString() {
75 return getClass().getSimpleName() + " [ Number of matches found: " + fMatchCount + " ]"; //$NON-NLS-1$ //$NON-NLS-2$
76 }
77
78 }
This page took 0.033121 seconds and 4 git commands to generate.