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
1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11
12 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
13
14 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
15 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
16 import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
17 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
18
19 /**
20 * The CTF extension of the TMF event type
21 *
22 * @version 1.0
23 * @author Matthew khouzam
24 */
25 public class CtfTmfEventType extends TmfEventType {
26
27 /**
28 * CTFTmfEventType context for the event type manager
29 */
30 private static final String CONTEXT_ID = "Ctf Event"; //$NON-NLS-1$
31
32 private static final String UNKNOWN_TRACE = "unknown"; //$NON-NLS-1$
33
34 /**
35 * Constructor for CtfTmfEventType.
36 *
37 * @param eventName
38 * The event name
39 * @param trace
40 * the parent trace
41 * @param content
42 * The event field
43 * @since 3.0
44 */
45 public CtfTmfEventType(String eventName, ITmfTrace trace, ITmfEventField content) {
46 super(computeContextName(trace), eventName, content);
47 }
48
49 /**
50 * Method toString.
51 *
52 * @return String
53 */
54 @Override
55 public String toString() {
56 return getName();
57 }
58
59 /**
60 * gets the event type for an event name
61 *
62 * @param trace
63 * the parent trace
64 * @param eventName
65 * the event name
66 * @return the event type
67 * @since 3.0
68 */
69 public static CtfTmfEventType get(CtfTmfTrace trace, String eventName) {
70 return (CtfTmfEventType) TmfEventTypeManager.getInstance().getType(computeContextName(trace), eventName);
71 }
72
73 /**
74 * Get the context name of a ctf trace
75 *
76 * @param trace
77 * the trace
78 * @return the context name
79 * @since 3.0
80 */
81 public static String computeContextName(ITmfTrace trace) {
82 return CONTEXT_ID + "/" + (trace == null ? UNKNOWN_TRACE : trace.getPath()); //$NON-NLS-1$
83 }
84 }
This page took 0.044238 seconds and 5 git commands to generate.