/*******************************************************************************
- * Copyright (c) 2011, 2014 Ericsson
+ * Copyright (c) 2011, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
-import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.tmf.core.event.ITmfCustomAttributes;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfModelLookup;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.CtfConstants;
import org.eclipse.tracecompass.tmf.ctf.core.event.lookup.CtfTmfCallsite;
-import org.eclipse.tracecompass.tmf.ctf.core.timestamp.CtfTmfTimestamp;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
/**
* A wrapper class around CTF's Event Definition/Declaration that maps all types
* of Declaration to native Java types.
*
- * @version 1.0
* @author Alexandre Montplaisir
- * @since 2.0
*/
public class CtfTmfEvent extends TmfEvent
implements ITmfSourceLookup, ITmfModelLookup, ITmfCustomAttributes {
private final String fEventName;
private final IEventDeclaration fEventDeclaration;
private final @NonNull EventDefinition fEvent;
- private final String fSource;
private final String fReference;
/** Lazy-loaded field containing the event's payload */
private ITmfEventField fContent;
+ private CtfTmfEventType fCtfTmfEventType;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
/**
* Constructor used by {@link CtfTmfEventFactory#createEvent}
*/
- CtfTmfEvent(CtfTmfTrace trace, long rank, CtfTmfTimestamp timestamp,
+ CtfTmfEvent(CtfTmfTrace trace, long rank, TmfNanoTimestamp timestamp,
String fileName, int cpu, IEventDeclaration declaration, @NonNull EventDefinition eventDefinition) {
super(trace,
rank,
* Content handled with a lazy-loaded field re-implemented in
* getContent().
*/
- null
- );
+ null);
fEventDeclaration = declaration;
fSourceCPU = cpu;
fTypeId = declaration.getId().longValue();
fEventName = declaration.getName();
fEvent = eventDefinition;
- fSource = String.valueOf(cpu);
fReference = fileName;
}
CtfTmfEvent(CtfTmfTrace trace) {
super(trace,
ITmfContext.UNKNOWN_RANK,
- new CtfTmfTimestamp(-1),
+ new TmfNanoTimestamp(-1),
null,
new TmfEventField("", null, new CtfTmfEventField[0])); //$NON-NLS-1$
fSourceCPU = -1;
fEventName = EMPTY_CTF_EVENT_NAME;
fEventDeclaration = null;
fEvent = EventDefinition.NULL_EVENT;
- fSource = null;
fReference = null;
}
return fTypeId;
}
- /**
- * Return this event's source CPU.
- *
- * @return The source CPU
- */
- public String getSource() {
- return fSource;
- }
-
/**
* Return this event's reference
*
@Override
public ITmfEventType getType() {
- CtfTmfEventType ctfTmfEventType = new CtfTmfEventType(fEventName, getContent());
-
- /* Register the event type in the owning trace, but only if there is one */
- CtfTmfTrace trace = getTrace();
- trace.registerEventType(ctfTmfEventType);
+ if (fCtfTmfEventType == null) {
+ fCtfTmfEventType = new CtfTmfEventType(fEventName, getContent());
+
+ /*
+ * Register the event type in the owning trace, but only if there is
+ * one
+ */
+ getTrace().registerEventType(fCtfTmfEventType);
+ }
+ return fCtfTmfEventType;
+ }
- return ctfTmfEventType;
+ @Override
+ public String getName() {
+ return fEventName;
}
- /**
- * @since 2.0
- */
@Override
public Set<String> listCustomAttributes() {
if (fEventDeclaration == null) {
return fEventDeclaration.getCustomAttributes();
}
- /**
- * @since 2.0
- */
@Override
public String getCustomAttribute(String name) {
if (fEventDeclaration == null) {
* Get the call site for this event.
*
* @return the call site information, or null if there is none
- * @since 2.0
*/
@Override
public CtfTmfCallsite getCallsite() {
- CTFCallsite callsite = null;
+ CtfTmfCallsite callsite = null;
CtfTmfTrace trace = getTrace();
- CTFTrace ctfTrace = trace.getCTFTrace();
- /* Should not happen, but it is a good check */
- if (ctfTrace == null) {
- return null;
- }
+
if (getContent() != null) {
ITmfEventField ipField = getContent().getField(CtfConstants.CONTEXT_FIELD_PREFIX + CtfConstants.IP_KEY);
if (ipField != null && ipField.getValue() instanceof Long) {
long ip = (Long) ipField.getValue();
- callsite = ctfTrace.getCallsite(fEventName, ip);
+ callsite = trace.getCallsite(fEventName, ip);
}
}
if (callsite == null) {
- callsite = ctfTrace.getCallsite(fEventName);
- }
- if (callsite != null) {
- return new CtfTmfCallsite(callsite);
+ callsite = trace.getCallsite(fEventName);
}
- return null;
+ return callsite;
}
- /**
- * @since 2.0
- */
@Override
public String getModelUri() {
return getCustomAttribute(CtfConstants.MODEL_URI_KEY);