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