Remove unused directory
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / TmfEvent.java
... / ...
CommitLineData
1/*******************************************************************************
2 * Copyright (c) 2009, 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: Francois Chouinard - Initial API and implementation
10 * Francois Chouinard - Updated as per TMF Event Model 1.0
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.core.event;
14
15import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
16
17/**
18 * <b><u>TmfEvent</u></b>
19 * <p>
20 * The basic event structure in the TMF. In its canonical form, an event has:
21 * <ul>
22 * <li>a normalized timestamp
23 * <li>a source (reporter)
24 * <li>a type
25 * <li>a content
26 * </ul>
27 * For convenience, a free-form reference field is also provided. It could be
28 * used as e.g. a location marker in the event stream to distinguish between
29 * otherwise identical events.
30 *
31 * Notice that for performance reasons TmfEvent is NOT immutable. If a copy of
32 * the event is needed, use the copy constructor.
33 */
34public class TmfEvent extends TmfDataEvent implements Cloneable {
35
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
39
40 protected TmfTimestamp fTimestamp;
41
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45
46 /**
47 * Default constructor
48 */
49 public TmfEvent() {
50 }
51
52 /**
53 * Full constructor
54 *
55 * @param trace the parent trace
56 * @param rank the vent rank (in the trace)
57 * @param timestamp the event timestamp
58 * @param source the event source
59 * @param type the event type
60 * @param reference the event reference
61 */
62 public TmfEvent(ITmfTrace<?> trace, long rank, TmfTimestamp timestamp, String source,
63 TmfEventType type, String reference) {
64 super(trace, rank, source, type, null, reference);
65 fTimestamp = timestamp;
66 }
67
68 /**
69 * Constructor - no rank
70 */
71 public TmfEvent(ITmfTrace<?> parentTrace, TmfTimestamp timestamp, String source,
72 TmfEventType type, String reference) {
73 this(parentTrace, -1, timestamp, source, type, reference);
74 }
75
76 /**
77 * Constructor - no trace, no rank
78 */
79 public TmfEvent(TmfTimestamp timestamp, String source, TmfEventType type, String reference) {
80 this(null, -1, timestamp, source, type, reference);
81 }
82
83 /**
84 * Copy constructor
85 *
86 * @param event the original event
87 */
88 public TmfEvent(TmfEvent event) {
89 super(event);
90 fTimestamp = event.fTimestamp != null ? new TmfTimestamp(event.fTimestamp) : null;
91 }
92
93 // ------------------------------------------------------------------------
94 // ITmfEvent
95 // ------------------------------------------------------------------------
96
97 /**
98 * @return the effective event timestamp
99 */
100 public TmfTimestamp getTimestamp() {
101 return fTimestamp;
102 }
103
104 // ------------------------------------------------------------------------
105 // Cloneable
106 // ------------------------------------------------------------------------
107
108 @Override
109 public TmfEvent clone() {
110 TmfEvent clone = null;
111 clone = (TmfEvent) super.clone();
112 clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null;
113 return clone;
114 }
115
116 // ------------------------------------------------------------------------
117 // Object
118 // ------------------------------------------------------------------------
119
120 @Override
121 public int hashCode() {
122 final int prime = 31;
123 int result = super.hashCode();
124 result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
125 return result;
126 }
127
128 @Override
129 public boolean equals(Object obj) {
130 if (this == obj)
131 return true;
132 if (!super.equals(obj))
133 return false;
134 if (getClass() != obj.getClass())
135 return false;
136 TmfEvent other = (TmfEvent) obj;
137 if (fTimestamp == null) {
138 if (other.fTimestamp != null)
139 return false;
140 } else if (!fTimestamp.equals(other.fTimestamp))
141 return false;
142 return true;
143 }
144
145 @Override
146 @SuppressWarnings("nls")
147 public String toString() {
148 return "TmfEvent [fTimestamp=" + fTimestamp + ", fTrace=" + fTrace + ", fRank=" + fRank
149 + ", fSource=" + fSource + ", fType=" + fType + ", fContent=" + fContent
150 + ", fReference=" + fReference + "]";
151 }
152
153}
This page took 0.02397 seconds and 5 git commands to generate.