Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made 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: | |
10 | * William Bourque (wbourque@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
6c13869b | 13 | package org.eclipse.linuxtools.lttng.core.event; |
5d10d135 | 14 | |
6c13869b | 15 | import org.eclipse.linuxtools.tmf.core.event.*; |
5d10d135 ASL |
16 | |
17 | /** | |
07d9e2ee FC |
18 | * <b><u>LttngEventType</u></b><p> |
19 | * | |
20 | * Lttng specific implementation of the TmfEventType.<p> | |
21 | * | |
5d10d135 ASL |
22 | * This implementation add some attributes to the basic Tmf object. |
23 | */ | |
24 | public class LttngEventType extends TmfEventType { | |
28b94d61 | 25 | |
cbbcc354 | 26 | private static final String DEFAULT_CONTEXT = "Kernel Trace"; //$NON-NLS-1$ |
4bf17f4a | 27 | private static final String DEFAULT_TYPE_ID = "Kernel Trace"; //$NON-NLS-1$ |
28 | // These should match the column names in LTTng Events Table | |
29 | public static final String TIMESTAMP_LABEL = "Timestamp"; //$NON-NLS-1$ | |
30 | public static final String TRACE_LABEL = "Trace"; //$NON-NLS-1$ | |
31 | public static final String MARKER_LABEL = "Marker"; //$NON-NLS-1$ | |
32 | public static final String CONTENT_LABEL = "Content"; //$NON-NLS-1$ | |
33 | private static final String[] DEFAULT_LABELS = { | |
34 | TIMESTAMP_LABEL, TRACE_LABEL, MARKER_LABEL, CONTENT_LABEL | |
35 | }; | |
36 | public static final LttngEventType DEFAULT_EVENT_TYPE = new LttngEventType(DEFAULT_TYPE_ID, DEFAULT_LABELS); | |
37 | ||
28b94d61 FC |
38 | private String tracefileName = null; |
39 | private Long cpuId = null; | |
40 | private String markerName = null; | |
b12f4544 | 41 | private int markerId = -1; |
5d10d135 ASL |
42 | |
43 | /** | |
28b94d61 | 44 | * Default Constructor.<p> |
5d10d135 | 45 | * |
28b94d61 FC |
46 | */ |
47 | public LttngEventType() { | |
48 | super(); | |
49 | } | |
50 | ||
4bf17f4a | 51 | /** |
52 | * Default Constructor.<p> | |
53 | * | |
54 | */ | |
55 | public LttngEventType(String typeId, String[] labels) { | |
4c564a2d | 56 | super(DEFAULT_CONTEXT, typeId, TmfEventField.makeRoot(labels)); |
4bf17f4a | 57 | } |
58 | ||
28b94d61 FC |
59 | /** |
60 | * Constructor with parameters.<p> | |
07d9e2ee | 61 | * |
28b94d61 FC |
62 | * @param thisTracefileName Tracefile (channel) name in Ltt |
63 | * @param thisMarkerName Marker name in LTT | |
64 | * @param thisMarkerfieldsName MarkerFields related to this marker | |
5d10d135 | 65 | */ |
b12f4544 | 66 | public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, int thisMarkerId, String[] thisMarkerfieldsName) { |
4c564a2d | 67 | super(DEFAULT_CONTEXT, thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, TmfEventField.makeRoot(thisMarkerfieldsName)); //$NON-NLS-1$ //$NON-NLS-2$ |
5d10d135 | 68 | |
28b94d61 FC |
69 | tracefileName = thisTracefileName; |
70 | cpuId = thisCpuId; | |
71 | markerName = thisMarkerName; | |
b12f4544 | 72 | markerId = thisMarkerId; |
5d10d135 ASL |
73 | } |
74 | ||
3fbd810a | 75 | /** |
07d9e2ee | 76 | * Copy constructor.<p> |
3fbd810a | 77 | * |
07d9e2ee | 78 | * @param oldType Type we want to copy from |
3fbd810a FC |
79 | */ |
80 | public LttngEventType(LttngEventType oldType) { | |
4c564a2d | 81 | this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.markerId, oldType.getFieldNames()); |
3fbd810a FC |
82 | } |
83 | ||
5d10d135 | 84 | |
28b94d61 FC |
85 | public String getTracefileName() { |
86 | return tracefileName; | |
5d10d135 ASL |
87 | } |
88 | ||
28b94d61 | 89 | public Long getCpuId() { |
5d10d135 ASL |
90 | return cpuId; |
91 | } | |
92 | ||
93 | public String getMarkerName() { | |
94 | return markerName; | |
95 | } | |
96 | ||
b12f4544 FC |
97 | public int getMarkerId() { |
98 | return markerId; | |
99 | } | |
100 | ||
5d10d135 ASL |
101 | /** |
102 | * toString() method. | |
103 | * | |
28b94d61 | 104 | * @return TypeId (channel/marker) of the object |
5d10d135 | 105 | */ |
6d848cce | 106 | @Override |
3b38ea61 | 107 | @SuppressWarnings("nls") |
6d848cce | 108 | public String toString() { |
28b94d61 FC |
109 | // *** TODO *** |
110 | // This is used as-it in the events view, so we won't change its format. | |
111 | // ...but maybe we should? | |
112 | return tracefileName + "/" + cpuId.toString() + "/" + markerName; | |
5d10d135 | 113 | } |
1a971e96 FC |
114 | |
115 | @Override | |
116 | public LttngEventType clone() { | |
117 | LttngEventType clone = (LttngEventType) super.clone(); | |
118 | clone.tracefileName = new String(tracefileName); | |
119 | clone.cpuId = new Long(cpuId); | |
120 | clone.markerName = new String(markerName); | |
b12f4544 | 121 | clone.markerId = markerId; |
1a971e96 FC |
122 | return clone; |
123 | } | |
124 | ||
5d10d135 | 125 | } |