Commit | Line | Data |
---|---|---|
b1baa808 MK |
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 | ||
ce2388e0 FC |
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; | |
aa572e22 | 16 | import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager; |
e5f7f02c | 17 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
ce2388e0 | 18 | |
b1baa808 | 19 | /** |
063f0d27 AM |
20 | * The CTF extension of the TMF event type |
21 | * | |
d09f973b FC |
22 | * @version 1.0 |
23 | * @author Matthew khouzam | |
b1baa808 | 24 | */ |
ce2388e0 FC |
25 | public class CtfTmfEventType extends TmfEventType { |
26 | ||
e5f7f02c MK |
27 | /** |
28 | * CTFTmfEventType context for the event type manager | |
29 | */ | |
aa572e22 | 30 | private static final String CONTEXT_ID = "Ctf Event"; //$NON-NLS-1$ |
063f0d27 | 31 | |
e5f7f02c MK |
32 | private static final String UNKNOWN_TRACE = "unknown"; //$NON-NLS-1$ |
33 | ||
b1baa808 MK |
34 | /** |
35 | * Constructor for CtfTmfEventType. | |
063f0d27 AM |
36 | * |
37 | * @param eventName | |
e5f7f02c MK |
38 | * The event name |
39 | * @param trace | |
40 | * the parent trace | |
063f0d27 | 41 | * @param content |
e5f7f02c MK |
42 | * The event field |
43 | * @since 3.0 | |
b1baa808 | 44 | */ |
e5f7f02c MK |
45 | public CtfTmfEventType(String eventName, ITmfTrace trace, ITmfEventField content) { |
46 | super(computeContextName(trace), eventName, content); | |
ce2388e0 FC |
47 | } |
48 | ||
b1baa808 MK |
49 | /** |
50 | * Method toString. | |
063f0d27 | 51 | * |
b1baa808 MK |
52 | * @return String |
53 | */ | |
ce2388e0 | 54 | @Override |
e30ce12e | 55 | public String toString() { |
b27165ab | 56 | return getName(); |
ce2388e0 | 57 | } |
aa572e22 | 58 | |
9ac2eb62 MK |
59 | /** |
60 | * gets the event type for an event name | |
063f0d27 | 61 | * |
e5f7f02c MK |
62 | * @param trace |
63 | * the parent trace | |
063f0d27 AM |
64 | * @param eventName |
65 | * the event name | |
9ac2eb62 | 66 | * @return the event type |
e5f7f02c MK |
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 | |
9ac2eb62 | 80 | */ |
e5f7f02c MK |
81 | public static String computeContextName(ITmfTrace trace) { |
82 | return CONTEXT_ID + "/" + (trace == null ? UNKNOWN_TRACE : trace.getPath()); //$NON-NLS-1$ | |
aa572e22 | 83 | } |
ce2388e0 | 84 | } |