tmf: Make TmfEventFieldAspect independent of event content
[deliverable/tracecompass.git] / org.eclipse.tracecompass.gdbtrace.core / src / org / eclipse / tracecompass / internal / gdbtrace / core / trace / GdbEventAspects.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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.gdbtrace.core.trace;
14
15 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
19 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
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 * Event table column definition for GDB traces.
28 *
29 * @author Alexandre Montplaisir
30 */
31 public final class GdbEventAspects {
32
33 private GdbEventAspects() {}
34
35 private static final @NonNull Iterable<ITmfEventAspect> GDB_ASPECTS =
36 checkNotNull(ImmutableList.of(
37 new TmfContentFieldAspect(GdbTraceEventContent.TRACE_FRAME, GdbTraceEventContent.TRACE_FRAME),
38 new TmfContentFieldAspect(GdbTraceEventContent.TRACEPOINT, GdbTraceEventContent.TRACEPOINT),
39 new GdbFileAspect()
40 ));
41
42 private static class GdbFileAspect implements ITmfEventAspect {
43
44 @Override
45 public String getName() {
46 return "File"; //$NON-NLS-1$
47 }
48
49 @Override
50 public String getHelpText() {
51 return EMPTY_STRING;
52 }
53
54 @Override
55 public String resolve(ITmfEvent event) {
56 if (!(event instanceof GdbTraceEvent)) {
57 return EMPTY_STRING;
58 }
59 String ret = ((GdbTraceEvent) event).getReference();
60 return (ret == null ? EMPTY_STRING : ret);
61 }
62 }
63
64 /**
65 * Get the event aspects specific to GDB traces.
66 *
67 * @return The set of aspects
68 */
69 public static @NonNull Iterable<ITmfEventAspect> getAspects() {
70 return GDB_ASPECTS;
71 }
72 }
This page took 0.032587 seconds and 5 git commands to generate.