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
.tracecompass
.ctf
.core
.CTFStrings
;
14 import org
.eclipse
.tracecompass
.ctf
.core
.event
.EventDefinition
;
15 import org
.eclipse
.tracecompass
.ctf
.core
.event
.IEventDeclaration
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
18 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEventFactory
;
20 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
23 * Factory for {@link LttngUstEvent}.
25 * @author Matthew Khouzam
26 * @author Alexandre Montplaisir
29 public class LttngUstEventFactory
extends CtfTmfEventFactory
{
31 private static final @NonNull LttngUstEventFactory INSTANCE
= new LttngUstEventFactory();
34 * Private constructor.
36 private LttngUstEventFactory() {
40 public static @NonNull LttngUstEventFactory
instance() {
45 public CtfTmfEvent
createEvent(CtfTmfTrace trace
, EventDefinition eventDef
, String fileName
) {
46 /* Prepare what to pass to CtfTmfEvent's constructor */
47 final IEventDeclaration eventDecl
= eventDef
.getDeclaration();
48 final long ts
= eventDef
.getTimestamp();
49 final TmfNanoTimestamp timestamp
= trace
.createTimestamp(trace
.timestampCyclesToNanos(ts
));
51 int sourceCPU
= eventDef
.getCPU();
53 String reference
= (fileName
== null ? NO_STREAM
: fileName
);
55 /* Handle the special case of lost events */
56 if (eventDecl
.getName().equals(CTFStrings
.LOST_EVENT_NAME
)) {
57 return createLostEvent(trace
, eventDef
, eventDecl
, ts
, timestamp
, sourceCPU
, reference
);
60 /* Handle standard event types */
61 return new LttngUstEvent(trace
,
62 ITmfContext
.UNKNOWN_RANK
,
64 reference
, // filename