package org.eclipse.linuxtools.tmf.core.event.matching;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.linuxtools.internal.tmf.core.Activator;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
* The array of traces to match
*/
- private final ITmfTrace[] fTraces;
+ private final Collection<ITmfTrace> fTraces;
/**
* The class to call once a match is found
*/
private final IMatchProcessingUnit fMatches;
- private static final Map<MatchingType, List<ITmfMatchEventDefinition>> fMatchDefinitions = new HashMap<MatchingType, List<ITmfMatchEventDefinition>>();
+ private static final Map<MatchingType, List<ITmfMatchEventDefinition>> fMatchDefinitions = new HashMap<>();
- private final Map<ITmfTrace, ITmfMatchEventDefinition> fMatchMap = new HashMap<ITmfTrace, ITmfMatchEventDefinition>();
+ private final Map<ITmfTrace, ITmfMatchEventDefinition> fMatchMap = new HashMap<>();
/**
* Constructor with multiple traces and a match processing object
* @param tmfEventMatches
* The match processing class
*/
- public TmfEventMatching(ITmfTrace[] traces, IMatchProcessingUnit tmfEventMatches) {
+ public TmfEventMatching(Collection<ITmfTrace> traces, IMatchProcessingUnit tmfEventMatches) {
if (tmfEventMatches == null) {
throw new IllegalArgumentException();
}
*
* @return The traces
*/
- protected ITmfTrace[] getTraces() {
+ protected Collection<? extends ITmfTrace> getTraces() {
return fTraces;
}
*
* @param event
* The event to match
- * @param traceno
- * The number of the trace this event belongs to
+ * @param trace
+ * The trace to which this event belongs
*/
- protected abstract void matchEvent(ITmfEvent event, int traceno);
+ protected abstract void matchEvent(ITmfEvent event, ITmfTrace trace);
/**
* Returns the matching type this class implements
public boolean matchEvents() {
/* Are there traces to match? If no, return false */
- if (!(fTraces.length > 0)) {
+ if (!(fTraces.size() > 0)) {
return false;
}
* would be preferable to have experiment
* </pre>
*/
- for (int i = 0; i < fTraces.length; i++) {
-
- EventMatchingBuildRequest request = new EventMatchingBuildRequest(this, i);
+ for (ITmfTrace trace : fTraces) {
+ EventMatchingBuildRequest request = new EventMatchingBuildRequest(this, trace);
/*
* Send the request to the trace here, since there is probably no
* experiment.
*/
- fTraces[i].sendRequest(request);
+ trace.sendRequest(request);
try {
request.waitForCompletion();
} catch (InterruptedException e) {
class EventMatchingBuildRequest extends TmfEventRequest {
private final TmfEventMatching matching;
- private final int traceno;
+ private final ITmfTrace trace;
- EventMatchingBuildRequest(TmfEventMatching matching, int traceno) {
- super(CtfTmfEvent.class,
+ EventMatchingBuildRequest(TmfEventMatching matching, ITmfTrace trace) {
+ super(ITmfEvent.class,
TmfTimeRange.ETERNITY,
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.FOREGROUND);
+ ITmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.FOREGROUND);
this.matching = matching;
- this.traceno = traceno;
+ this.trace = trace;
}
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
if (event != null) {
- matching.matchEvent(event, traceno);
+ matching.matchEvent(event, trace);
}
}