Commit | Line | Data |
---|---|---|
9447c7ee | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2014, 2015 Ericsson |
9447c7ee AM |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * 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.tmf.core.event.aspect; | |
14 | ||
15 | import org.eclipse.jdt.annotation.Nullable; | |
16 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
17 | ||
18 | /** | |
19 | * Event aspect representing the CPU of a trace event. Trace types that do have | |
20 | * the notion of CPU can use this to expose it in their traces. | |
21 | * | |
22 | * TODO Move to an eventualy kernel-trace-specific plugin. | |
23 | * | |
24 | * @author Alexandre Montplaisir | |
25 | */ | |
26 | public abstract class TmfCpuAspect implements ITmfEventAspect { | |
27 | ||
28 | @Override | |
29 | public final String getName() { | |
30 | return Messages.getMessage(Messages.AspectName_CPU); | |
31 | } | |
32 | ||
33 | @Override | |
34 | public final String getHelpText() { | |
35 | return Messages.getMessage(Messages.AspectHelpText_CPU); | |
36 | } | |
37 | ||
52293ccd GB |
38 | /** |
39 | * Returns the CPU number of the CPU on which this event was executed or | |
2a28075c | 40 | * {@code null} if the CPU is not available for an event. |
52293ccd | 41 | */ |
9447c7ee | 42 | @Override |
2a28075c | 43 | public abstract @Nullable Integer resolve(ITmfEvent event); |
9447c7ee AM |
44 | |
45 | @Override | |
46 | public boolean equals(@Nullable Object other) { | |
47 | /* | |
48 | * Consider all sub-instance of this type "equal", so that they get | |
49 | * merged in a single CPU column/aspect. | |
50 | */ | |
51 | if (other instanceof TmfCpuAspect) { | |
52 | return true; | |
53 | } | |
54 | return false; | |
55 | } | |
56 | ||
57 | @Override | |
58 | public int hashCode() { | |
59 | return getName().hashCode(); | |
60 | } | |
61 | } |