tmf: Remove the ITmfEventTableColumns extension point
[deliverable/tracecompass.git] / org.eclipse.tracecompass.btf.core / src / org / eclipse / tracecompass / btf / core / trace / BtfEventAspects.java
1 /*******************************************************************************
2 * Copyright (c) 2014 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 *******************************************************************************/
13
14 package org.eclipse.tracecompass.btf.core.trace;
15
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.tracecompass.btf.core.event.BtfEvent;
18 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
20 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
21
22 import com.google.common.collect.ImmutableList;
23
24 /**
25 * Columns to use in the BTF event table
26 *
27 * @author Alexandre Montplaisir
28 */
29 public final class BtfEventAspects {
30
31 private BtfEventAspects() {}
32
33 @SuppressWarnings("null")
34 private static final @NonNull Iterable<ITmfEventAspect> BTF_ASPECTS = ImmutableList.of(
35 ITmfEventAspect.BaseAspects.TIMESTAMP,
36 new BtfSourceAspect(),
37 new BtfSourceInstanceAspect(),
38 ITmfEventAspect.BaseAspects.EVENT_TYPE,
39 new BtfTargetAspect(),
40 new BtfTargetInstanceAspect(),
41 new BtfEventAspect(),
42 new BtfNotesAspect()
43 );
44
45 /**
46 * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
47 */
48 private static class BtfSourceAspect implements ITmfEventAspect {
49
50 @Override
51 public String getName() {
52 return BtfColumnNames.SOURCE.toString();
53 }
54
55 @Override
56 public String getHelpText() {
57 return EMPTY_STRING;
58 }
59
60 @Override
61 public String resolve(ITmfEvent event) {
62 if (!(event instanceof BtfEvent)) {
63 return EMPTY_STRING;
64 }
65 String ret = ((BtfEvent) event).getSource();
66 return (ret == null ? EMPTY_STRING : ret);
67 }
68
69 @Override
70 public String getFilterId() {
71 return ITmfEvent.EVENT_FIELD_SOURCE;
72 }
73 }
74
75 /**
76 * The "source instance" aspect, whose value comes from the field of the
77 * same name.
78 */
79 private static class BtfSourceInstanceAspect extends TmfEventFieldAspect {
80 public BtfSourceInstanceAspect() {
81 super(BtfColumnNames.SOURCE_INSTANCE.toString(),
82 BtfColumnNames.SOURCE_INSTANCE.toString());
83 }
84 }
85
86 /**
87 * The "target" aspect, taking its value from
88 * {@link ITmfEvent#getReference()}.
89 */
90 private static class BtfTargetAspect implements ITmfEventAspect {
91
92 @Override
93 public String getName() {
94 return BtfColumnNames.TARGET.toString();
95 }
96
97 @Override
98 public String getHelpText() {
99 return EMPTY_STRING;
100 }
101
102 @Override
103 public String resolve(ITmfEvent event) {
104 if (!(event instanceof BtfEvent)) {
105 return EMPTY_STRING;
106 }
107 String ret = ((BtfEvent) event).getReference();
108 return (ret == null ? EMPTY_STRING : ret);
109 }
110
111 @Override
112 public String getFilterId() {
113 return ITmfEvent.EVENT_FIELD_REFERENCE;
114 }
115 }
116
117 /**
118 * The "target instance" aspect, whose value comes from the field of the
119 * same name.
120 */
121 private static class BtfTargetInstanceAspect extends TmfEventFieldAspect {
122 public BtfTargetInstanceAspect() {
123 super(BtfColumnNames.TARGET_INSTANCE.toString(),
124 BtfColumnNames.TARGET_INSTANCE.toString());
125 }
126 }
127
128 /**
129 * The "event" aspect, whose value comes from the field of the same name.
130 */
131 private static class BtfEventAspect extends TmfEventFieldAspect {
132 public BtfEventAspect() {
133 super(BtfColumnNames.EVENT.toString(),
134 BtfColumnNames.EVENT.toString());
135 }
136 }
137
138 /**
139 * The "notes" column, whose value comes from the field of the same name, if
140 * present.
141 */
142 private static class BtfNotesAspect extends TmfEventFieldAspect {
143 public BtfNotesAspect() {
144 super(BtfColumnNames.NOTES.toString(),
145 BtfColumnNames.NOTES.toString());
146 }
147 }
148
149 /**
150 * Return the event aspects defined for BTF traces.
151 *
152 * @return The aspects
153 */
154 public static Iterable<ITmfEventAspect> getAspects() {
155 return BTF_ASPECTS;
156 }
157 }
This page took 0.050959 seconds and 5 git commands to generate.