btf: Move the plugins to their own sub-directory
[deliverable/tracecompass.git] / btf / org.eclipse.tracecompass.btf.core / src / org / eclipse / tracecompass / btf / core / trace / BtfEventAspects.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Update to new Event Table API
12 * Patrick Tasse - Update for renamed target field
13 *******************************************************************************/
14
15 package org.eclipse.tracecompass.btf.core.trace;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.tracecompass.btf.core.event.BtfEvent;
19 import org.eclipse.tracecompass.common.core.NonNullUtils;
20 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
22 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
23
24 import com.google.common.collect.ImmutableList;
25
26 /**
27 * Columns to use in the BTF event table
28 *
29 * @author Alexandre Montplaisir
30 */
31 public final class BtfEventAspects {
32
33 private BtfEventAspects() {}
34
35 private static final @NonNull Iterable<ITmfEventAspect> BTF_ASPECTS =
36 NonNullUtils.checkNotNull(ImmutableList.of(
37 ITmfEventAspect.BaseAspects.TIMESTAMP,
38 new BtfSourceAspect(),
39 new TmfContentFieldAspect(BtfColumnNames.SOURCE_INSTANCE.toString(), BtfColumnNames.SOURCE_INSTANCE.toString()),
40 ITmfEventAspect.BaseAspects.EVENT_TYPE,
41 new BtfTargetAspect(),
42 new TmfContentFieldAspect(BtfColumnNames.TARGET_INSTANCE.toString(), BtfColumnNames.TARGET_INSTANCE.toString()),
43 new TmfContentFieldAspect(BtfColumnNames.EVENT.toString(), BtfColumnNames.EVENT.toString()),
44 new TmfContentFieldAspect(BtfColumnNames.NOTES.toString(), BtfColumnNames.NOTES.toString())
45 ));
46
47 /**
48 * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
49 */
50 private static class BtfSourceAspect implements ITmfEventAspect {
51
52 @Override
53 public String getName() {
54 return BtfColumnNames.SOURCE.toString();
55 }
56
57 @Override
58 public String getHelpText() {
59 return EMPTY_STRING;
60 }
61
62 @Override
63 public String resolve(ITmfEvent event) {
64 if (!(event instanceof BtfEvent)) {
65 return EMPTY_STRING;
66 }
67 String ret = ((BtfEvent) event).getSource();
68 return (ret == null ? EMPTY_STRING : ret);
69 }
70 }
71
72 /**
73 * The "target" aspect, taking its value from
74 * {@link ITmfEvent#getTarget()}.
75 */
76 private static class BtfTargetAspect implements ITmfEventAspect {
77
78 @Override
79 public String getName() {
80 return BtfColumnNames.TARGET.toString();
81 }
82
83 @Override
84 public String getHelpText() {
85 return EMPTY_STRING;
86 }
87
88 @Override
89 public String resolve(ITmfEvent event) {
90 if (!(event instanceof BtfEvent)) {
91 return EMPTY_STRING;
92 }
93 String ret = ((BtfEvent) event).getTarget();
94 return (ret == null ? EMPTY_STRING : ret);
95 }
96 }
97
98 /**
99 * Return the event aspects defined for BTF traces.
100 *
101 * @return The aspects
102 */
103 public static @NonNull Iterable<ITmfEventAspect> getAspects() {
104 return BTF_ASPECTS;
105 }
106 }
This page took 0.053347 seconds and 5 git commands to generate.