diff options
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java')
-rw-r--r-- | lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java index 1cfa63b3c3..700b0a9d7d 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader; @@ -29,9 +30,9 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; -import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties; import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; +import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties; import org.eclipse.linuxtools.tmf.core.trace.TmfTrace; /** @@ -307,6 +308,63 @@ public class CtfTmfTrace extends TmfTrace return 0; } + /** + * Returns whether or not an event is in the metadata of the trace, + * therefore if it can possibly be in the trace. It does not verify whether + * or not the event is actually in the trace + * + * @param eventName + * The name of the event to check + * @return Whether the event is in the metadata or not + * @since 2.1 + */ + public boolean hasEvent(final String eventName) { + Map<Long, IEventDeclaration> events = fTrace.getEvents(0L); + if (events != null) { + for (IEventDeclaration decl : events.values()) { + if (decl.getName().equals(eventName)) { + return true; + } + } + } + return false; + } + + /** + * Return whether all requested events are in the metadata + * + * @param names + * The array of events to check for + * @return Whether all events are in the metadata + * @since 2.1 + */ + public boolean hasAllEvents(String[] names) { + for (String name : names) { + if (!hasEvent(name)) { + return false; + } + } + return true; + } + + /** + * Returns whether the metadata contains at least one of the requested + * events + * + * @param names + * The array of event names of check for + * @return Whether one of the event is present in trace metadata + * @since 2.1 + */ + public boolean hasAtLeastOneOfEvents(String[] names) { + for (String name : names) { + if (hasEvent(name)) { + return true; + } + } + return false; + } + // ------------------------------------------- // Parser // ------------------------------------------- |