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