tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core / src / org / eclipse / linuxtools / internal / lttng / core / event / LttngEventType.java
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
13 package org.eclipse.linuxtools.internal.lttng.core.event;
14
15 import org.eclipse.linuxtools.tmf.core.event.*;
16
17 /**
18 * <b><u>LttngEventType</u></b><p>
19 *
20 * Lttng specific implementation of the TmfEventType.<p>
21 *
22 * This implementation add some attributes to the basic Tmf object.
23 */
24 public class LttngEventType extends TmfEventType {
25
26 private static final String DEFAULT_CONTEXT = "Kernel Trace"; //$NON-NLS-1$
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
38 private String tracefileName = null;
39 private Long cpuId = null;
40 private String markerName = null;
41 private int markerId = -1;
42
43 /**
44 * Default Constructor.<p>
45 *
46 */
47 public LttngEventType() {
48 super();
49 }
50
51 /**
52 * Default Constructor.<p>
53 *
54 */
55 public LttngEventType(String typeId, String[] labels) {
56 super(DEFAULT_CONTEXT, typeId, TmfEventField.makeRoot(labels));
57 }
58
59 /**
60 * Constructor with parameters.<p>
61 *
62 * @param thisTracefileName Tracefile (channel) name in Ltt
63 * @param thisMarkerName Marker name in LTT
64 * @param thisMarkerfieldsName MarkerFields related to this marker
65 */
66 public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, int thisMarkerId, String[] thisMarkerfieldsName) {
67 super(DEFAULT_CONTEXT, thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, TmfEventField.makeRoot(thisMarkerfieldsName)); //$NON-NLS-1$ //$NON-NLS-2$
68
69 tracefileName = thisTracefileName;
70 cpuId = thisCpuId;
71 markerName = thisMarkerName;
72 markerId = thisMarkerId;
73 }
74
75 /**
76 * Copy constructor.<p>
77 *
78 * @param oldType Type we want to copy from
79 */
80 public LttngEventType(LttngEventType oldType) {
81 this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.markerId, oldType.getFieldNames());
82 }
83
84
85 public String getTracefileName() {
86 return tracefileName;
87 }
88
89 public Long getCpuId() {
90 return cpuId;
91 }
92
93 public String getMarkerName() {
94 return markerName;
95 }
96
97 public int getMarkerId() {
98 return markerId;
99 }
100
101 /**
102 * toString() method.
103 *
104 * @return TypeId (channel/marker) of the object
105 */
106 @Override
107 @SuppressWarnings("nls")
108 public String toString() {
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;
113 }
114
115 @Override
116 public LttngEventType clone() {
117 LttngEventType clone = (LttngEventType) super.clone();
118 clone.tracefileName = tracefileName;
119 clone.cpuId = Long.valueOf(cpuId);
120 clone.markerName = markerName;
121 clone.markerId = markerId;
122 return clone;
123 }
124
125 /* (non-Javadoc)
126 * @see java.lang.Object#hashCode()
127 */
128 @Override
129 public int hashCode() {
130 final int prime = 31;
131 int result = super.hashCode();
132 result = prime * result + ((cpuId == null) ? 0 : cpuId.hashCode());
133 result = prime * result + markerId;
134 result = prime * result + ((markerName == null) ? 0 : markerName.hashCode());
135 result = prime * result + ((tracefileName == null) ? 0 : tracefileName.hashCode());
136 return result;
137 }
138
139 /* (non-Javadoc)
140 * @see java.lang.Object#equals(java.lang.Object)
141 */
142 @Override
143 public boolean equals(Object obj) {
144 if (this == obj) {
145 return true;
146 }
147 if (!super.equals(obj)) {
148 return false;
149 }
150 if (!(obj instanceof LttngEventType)) {
151 return false;
152 }
153 LttngEventType other = (LttngEventType) obj;
154 if (cpuId == null) {
155 if (other.cpuId != null) {
156 return false;
157 }
158 } else if (!cpuId.equals(other.cpuId)) {
159 return false;
160 }
161 if (markerId != other.markerId) {
162 return false;
163 }
164 if (markerName == null) {
165 if (other.markerName != null) {
166 return false;
167 }
168 } else if (!markerName.equals(other.markerName)) {
169 return false;
170 }
171 if (tracefileName == null) {
172 if (other.tracefileName != null) {
173 return false;
174 }
175 } else if (!tracefileName.equals(other.tracefileName)) {
176 return false;
177 }
178 return true;
179 }
180
181 }
This page took 0.036152 seconds and 5 git commands to generate.