Change type of event source from TmfEventSource to String
[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,
ce970a71 63 TmfEventType type, TmfEventReference reference) {
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,
ce970a71 72 TmfEventType type, TmfEventReference reference) {
73 this(parentTrace, -1, timestamp, source, type, reference);
12c155f5 74 }
8c8bf09f 75
12c155f5 76 /**
ce970a71 77 * Constructor - no trace, no rank
12c155f5 78 */
99005796 79 public TmfEvent(TmfTimestamp timestamp, String source, TmfEventType type,
ce970a71 80 TmfEventReference reference) {
81 this(null, -1, timestamp, source, type, reference);
12c155f5 82 }
8c8bf09f 83
12c155f5 84 /**
ce970a71 85 * Copy constructor
86 *
87 * @param event the original event
12c155f5 88 */
ce970a71 89 public TmfEvent(TmfEvent event) {
90 super(event);
91 fTimestamp = event.fTimestamp != null ? new TmfTimestamp(event.fTimestamp) : null;
12c155f5 92 }
8c8bf09f 93
ce970a71 94 // ------------------------------------------------------------------------
95 // ITmfEvent
96 // ------------------------------------------------------------------------
8c8bf09f 97
12c155f5 98 /**
ce970a71 99 * @return the effective event timestamp
12c155f5 100 */
ce970a71 101 public TmfTimestamp getTimestamp() {
102 return fTimestamp;
12c155f5 103 }
1f506a43 104
ce970a71 105 // ------------------------------------------------------------------------
106 // Cloneable
107 // ------------------------------------------------------------------------
cbd4ad82 108
ce970a71 109 @Override
110 public TmfEvent clone() {
111 TmfEvent clone = null;
112 clone = (TmfEvent) super.clone();
113 clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null;
114 return clone;
12c155f5 115 }
c76c54bb 116
12c155f5 117 // ------------------------------------------------------------------------
cbd4ad82
FC
118 // Object
119 // ------------------------------------------------------------------------
28b94d61 120
12c155f5 121 @Override
cbd4ad82 122 public int hashCode() {
ce970a71 123 final int prime = 31;
124 int result = super.hashCode();
125 result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
cbd4ad82
FC
126 return result;
127 }
128
129 @Override
ce970a71 130 public boolean equals(Object obj) {
131 if (this == obj)
132 return true;
133 if (!super.equals(obj))
12c155f5 134 return false;
ce970a71 135 if (getClass() != obj.getClass())
136 return false;
137 TmfEvent other = (TmfEvent) obj;
138 if (fTimestamp == null) {
139 if (other.fTimestamp != null)
0c841e0f 140 return false;
ce970a71 141 } else if (!fTimestamp.equals(other.fTimestamp))
142 return false;
0c841e0f 143 return true;
cbd4ad82 144 }
28b94d61 145
12c155f5 146 @Override
3b38ea61 147 @SuppressWarnings("nls")
12c155f5 148 public String toString() {
ce970a71 149 return "TmfEvent [fTimestamp=" + fTimestamp + ", fTrace=" + fTrace + ", fRank=" + fRank
150 + ", fSource=" + fSource + ", fType=" + fType + ", fContent=" + fContent
151 + ", fReference=" + fReference + "]";
12c155f5 152 }
f9673903 153
8c8bf09f 154}
This page took 0.039388 seconds and 5 git commands to generate.