1 /**********************************************************************
2 * Copyright (c) 2015 Ericsson and others
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 **********************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
;
12 import org
.eclipse
.jdt
.annotation
.NonNull
;
13 import org
.eclipse
.jdt
.annotation
.Nullable
;
14 import org
.eclipse
.tracecompass
.ctf
.core
.CTFStrings
;
15 import org
.eclipse
.tracecompass
.ctf
.core
.event
.IEventDeclaration
;
16 import org
.eclipse
.tracecompass
.ctf
.core
.event
.IEventDefinition
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
19 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
20 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEventFactory
;
21 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
24 * Factory for {@link LttngUstEvent}.
26 * @author Matthew Khouzam
27 * @author Alexandre Montplaisir
30 public class LttngUstEventFactory
extends CtfTmfEventFactory
{
32 private static final @NonNull LttngUstEventFactory INSTANCE
= new LttngUstEventFactory();
35 * Private constructor.
37 private LttngUstEventFactory() {
41 public static @NonNull LttngUstEventFactory
instance() {
46 public CtfTmfEvent
createEvent(CtfTmfTrace trace
, IEventDefinition eventDef
, @Nullable String fileName
) {
47 /* Prepare what to pass to CtfTmfEvent's constructor */
48 final IEventDeclaration eventDecl
= eventDef
.getDeclaration();
49 final long ts
= eventDef
.getTimestamp();
50 final TmfNanoTimestamp timestamp
= trace
.createTimestamp(trace
.timestampCyclesToNanos(ts
));
52 int sourceCPU
= eventDef
.getCPU();
54 String reference
= (fileName
== null ? NO_STREAM
: fileName
);
56 /* Handle the special case of lost events */
57 if (eventDecl
.getName().equals(CTFStrings
.LOST_EVENT_NAME
)) {
58 return createLostEvent(trace
, eventDef
, eventDecl
, ts
, timestamp
, sourceCPU
, reference
);
61 /* Handle standard event types */
62 return new LttngUstEvent(trace
,
63 ITmfContext
.UNKNOWN_RANK
,
65 reference
, // filename