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