Commit | Line | Data |
---|---|---|
8c8bf09f 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: | |
1f506a43 | 10 | * Francois Chouinard - Initial API and implementation |
8c8bf09f ASL |
11 | *******************************************************************************/ |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
15 | /** | |
16 | * <b><u>TmfTraceEvent</u></b> | |
17 | * <p> | |
18 | * A trace event associates a source code line to an event. The intent is to | |
19 | * provide the capability to open an editor at the line of code that produced | |
20 | * the event. | |
21 | * <p> | |
22 | * TODO: Concept is still a bit vague and should be aligned with the CDT | |
23 | * source lookup service. | |
cbd4ad82 | 24 | * TODO: Consider composition instead of extension |
8c8bf09f ASL |
25 | */ |
26 | public class TmfTraceEvent extends TmfEvent { | |
27 | ||
cbd4ad82 | 28 | // ------------------------------------------------------------------------ |
8c8bf09f | 29 | // Attributes |
cbd4ad82 | 30 | // ------------------------------------------------------------------------ |
8c8bf09f ASL |
31 | |
32 | private final String fSourcePath; | |
33 | private final String fFileName; | |
28b94d61 | 34 | private final int fLineNumber; |
8c8bf09f | 35 | |
cbd4ad82 | 36 | // ------------------------------------------------------------------------ |
8c8bf09f | 37 | // Constructors |
cbd4ad82 | 38 | // ------------------------------------------------------------------------ |
8c8bf09f | 39 | |
1f506a43 | 40 | /** |
28b94d61 FC |
41 | * @param originalTS |
42 | * @param effectiveTS | |
1f506a43 FC |
43 | * @param source |
44 | * @param type | |
45 | * @param content | |
46 | * @param reference | |
28b94d61 FC |
47 | * @param path |
48 | * @param file | |
49 | * @param line | |
1f506a43 FC |
50 | */ |
51 | public TmfTraceEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, | |
28b94d61 | 52 | TmfEventType type, TmfEventReference reference, String path, String file, int line) |
1f506a43 | 53 | { |
28b94d61 | 54 | super(originalTS, effectiveTS, source, type, reference); |
1f506a43 | 55 | fSourcePath = path; |
28b94d61 | 56 | fFileName = file; |
1f506a43 FC |
57 | fLineNumber = line; |
58 | } | |
59 | ||
8c8bf09f ASL |
60 | /** |
61 | * @param timestamp | |
62 | * @param source | |
63 | * @param type | |
64 | * @param content | |
65 | * @param reference | |
28b94d61 FC |
66 | * @param path |
67 | * @param file | |
68 | * @param line | |
8c8bf09f ASL |
69 | */ |
70 | public TmfTraceEvent(TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, | |
28b94d61 | 71 | TmfEventReference reference, String path, String file, int line) |
8c8bf09f | 72 | { |
28b94d61 | 73 | super(timestamp, source, type, reference); |
8c8bf09f | 74 | fSourcePath = path; |
28b94d61 | 75 | fFileName = file; |
8c8bf09f ASL |
76 | fLineNumber = line; |
77 | } | |
78 | ||
28b94d61 FC |
79 | /** |
80 | * @param other | |
81 | */ | |
82 | public TmfTraceEvent(TmfTraceEvent other) { | |
83 | super(other); | |
84 | fSourcePath = other.fSourcePath; | |
85 | fFileName = other.fFileName; | |
86 | fLineNumber = other.fLineNumber; | |
87 | } | |
88 | ||
cbd4ad82 | 89 | // ------------------------------------------------------------------------ |
8c8bf09f | 90 | // Accessors |
cbd4ad82 | 91 | // ------------------------------------------------------------------------ |
8c8bf09f ASL |
92 | |
93 | /** | |
94 | * @return | |
95 | */ | |
96 | public String getSourcePath() { | |
97 | return fSourcePath; | |
98 | } | |
99 | ||
100 | /** | |
101 | * @return | |
102 | */ | |
103 | public String getFileName() { | |
104 | return fFileName; | |
105 | } | |
106 | ||
107 | /** | |
108 | * @return | |
109 | */ | |
110 | public int getLineNumber() { | |
111 | return fLineNumber; | |
112 | } | |
113 | ||
cbd4ad82 FC |
114 | // ------------------------------------------------------------------------ |
115 | // Object | |
116 | // ------------------------------------------------------------------------ | |
28b94d61 | 117 | |
28b94d61 | 118 | @Override |
cbd4ad82 FC |
119 | public int hashCode() { |
120 | int result = super.hashCode(); | |
121 | result = 37 * result + ((fSourcePath != null) ? fSourcePath.hashCode() : 0); | |
122 | result = 37 * result + ((fFileName != null) ? fFileName.hashCode() : 0); | |
123 | result = 37 * result + fLineNumber; | |
124 | return result; | |
125 | } | |
126 | ||
127 | @Override | |
128 | public boolean equals(Object other) { | |
2fb2eb37 FC |
129 | if (other instanceof TmfEvent) { |
130 | return super.equals(other); | |
131 | } | |
cbd4ad82 FC |
132 | if (!(other instanceof TmfTraceEvent)) { |
133 | return false; | |
134 | } | |
135 | // TmfTraceEvent o = (TmfTraceEvent) other; | |
136 | return false; | |
28b94d61 FC |
137 | } |
138 | ||
139 | // TODO: Proper format | |
140 | @Override | |
141 | public String toString() { | |
cbd4ad82 | 142 | return "[TmfTraceEvent(" + fSourcePath + "," + fFileName + "," + fLineNumber + ")]"; |
28b94d61 FC |
143 | } |
144 | ||
8c8bf09f | 145 | } |