LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfEventType.java
index b841800ff9cce47d57ec1fa48bf14a2b4fcb8208..80c97adc469b9a3864ac30350e261096a5f860c7 100644 (file)
@@ -13,29 +13,72 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 
 /**
+ * The CTF extension of the TMF event type
+ *
+ * @version 1.0
+ * @author Matthew khouzam
  */
 public class CtfTmfEventType extends TmfEventType {
 
+    /**
+     * CTFTmfEventType context for the event type manager
+     */
+    private static final String CONTEXT_ID = "Ctf Event"; //$NON-NLS-1$
+
+    private static final String UNKNOWN_TRACE = "unknown"; //$NON-NLS-1$
+
     /**
      * Constructor for CtfTmfEventType.
-     * @param contextId String
-     * @param eventName String
-     * @param content ITmfEventField
+     *
+     * @param eventName
+     *            The event name
+     * @param trace
+     *            the parent trace
+     * @param content
+     *            The event field
+     * @since 3.0
      */
-    public CtfTmfEventType(String contextId, String eventName,
-            ITmfEventField content) {
-        super(contextId, eventName, content);
+    public CtfTmfEventType(String eventName, ITmfTrace trace, ITmfEventField content) {
+        super(computeContextName(trace), eventName, content);
     }
 
     /**
      * Method toString.
+     *
      * @return String
      */
     @Override
-    public String toString()
-    {
-        return this.getName();
+    public String toString() {
+        return getName();
+    }
+
+    /**
+     * gets the event type for an event name
+     *
+     * @param trace
+     *            the parent trace
+     * @param eventName
+     *            the event name
+     * @return the event type
+     * @since 3.0
+     */
+    public static CtfTmfEventType get(CtfTmfTrace trace, String eventName) {
+        return (CtfTmfEventType) TmfEventTypeManager.getInstance().getType(computeContextName(trace), eventName);
+    }
+
+    /**
+     * Get the context name of a ctf trace
+     *
+     * @param trace
+     *            the trace
+     * @return the context name
+     * @since 3.0
+     */
+    public static String computeContextName(ITmfTrace trace) {
+        return CONTEXT_ID + "/" + (trace == null ? UNKNOWN_TRACE : trace.getPath()); //$NON-NLS-1$
     }
 }
This page took 0.025075 seconds and 5 git commands to generate.