Commit | Line | Data |
---|---|---|
5c82e602 AM |
1 | /********************************************************************** |
2 | * Copyright (c) 2015 Ericsson and others | |
3 | * | |
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 | **********************************************************************/ | |
9 | ||
10 | package org.eclipse.tracecompass.lttng2.ust.core.trace; | |
11 | ||
12 | import org.eclipse.jdt.annotation.NonNull; | |
df2597e0 | 13 | import org.eclipse.jdt.annotation.Nullable; |
5c82e602 | 14 | import org.eclipse.tracecompass.ctf.core.CTFStrings; |
5c82e602 | 15 | import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; |
e8ece272 | 16 | import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; |
b2c971ec | 17 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; |
5c82e602 AM |
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; | |
22 | ||
23 | /** | |
24 | * Factory for {@link LttngUstEvent}. | |
25 | * | |
26 | * @author Matthew Khouzam | |
27 | * @author Alexandre Montplaisir | |
28 | * @since 2.0 | |
29 | */ | |
ac52feb8 | 30 | public final class LttngUstEventFactory extends CtfTmfEventFactory { |
5c82e602 AM |
31 | |
32 | private static final @NonNull LttngUstEventFactory INSTANCE = new LttngUstEventFactory(); | |
33 | ||
34 | /** | |
35 | * Private constructor. | |
36 | */ | |
37 | private LttngUstEventFactory() { | |
38 | super(); | |
39 | } | |
40 | ||
41 | public static @NonNull LttngUstEventFactory instance() { | |
42 | return INSTANCE; | |
43 | } | |
44 | ||
45 | @Override | |
e8ece272 | 46 | public CtfTmfEvent createEvent(CtfTmfTrace trace, IEventDefinition eventDef, @Nullable String fileName) { |
5c82e602 AM |
47 | /* Prepare what to pass to CtfTmfEvent's constructor */ |
48 | final IEventDeclaration eventDecl = eventDef.getDeclaration(); | |
49 | final long ts = eventDef.getTimestamp(); | |
b2c971ec | 50 | final ITmfTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts)); |
5c82e602 AM |
51 | |
52 | int sourceCPU = eventDef.getCPU(); | |
53 | ||
54 | String reference = (fileName == null ? NO_STREAM : fileName); | |
55 | ||
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); | |
59 | } | |
60 | ||
61 | /* Handle standard event types */ | |
62 | return new LttngUstEvent(trace, | |
63 | ITmfContext.UNKNOWN_RANK, | |
64 | timestamp, | |
65 | reference, // filename | |
66 | sourceCPU, | |
67 | eventDecl, | |
68 | eventDef); | |
69 | } | |
70 | } |