Commit | Line | Data |
---|---|---|
ff71e543 MK |
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 | *******************************************************************************/ | |
12 | ||
7ce90559 | 13 | package org.eclipse.tracecompass.btf.core.trace; |
ff71e543 | 14 | |
aa353506 AM |
15 | import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; |
16 | ||
ff71e543 MK |
17 | import java.util.Map; |
18 | ||
7ce90559 AM |
19 | import org.eclipse.tracecompass.btf.core.Messages; |
20 | import org.eclipse.tracecompass.btf.core.event.BtfEventType; | |
ff71e543 MK |
21 | |
22 | import com.google.common.collect.ImmutableMap; | |
23 | ||
24 | /** | |
25 | * Entity Types for BTF | |
26 | * | |
27 | * @author Matthew Khouzam | |
28 | */ | |
29 | public final class BtfEventTypeFactory { | |
30 | ||
31 | private BtfEventTypeFactory() {} | |
32 | ||
33 | private static final Map<String, BtfEventType> TYPES; | |
34 | ||
35 | static { | |
36 | ImmutableMap.Builder<String, BtfEventType> builder = new ImmutableMap.Builder<>(); | |
37 | // Environment | |
aa353506 | 38 | builder.put("STI", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_STIName), Messages.BtfTypeId_STIDescr)); //$NON-NLS-1$ |
ff71e543 | 39 | // Software |
aa353506 AM |
40 | builder.put("T", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_TName), Messages.BtfTypeId_TDescr)); //$NON-NLS-1$ |
41 | builder.put("ISR", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ISRName), Messages.BtfTypeId_ISRDescr)); //$NON-NLS-1$ | |
42 | builder.put("R", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_RName), Messages.BtfTypeId_RDescr)); //$NON-NLS-1$ | |
43 | builder.put("IB", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_IBName), Messages.BtfTypeId_IBDescr)); //$NON-NLS-1$ | |
ff71e543 | 44 | // Hardware |
aa353506 AM |
45 | builder.put("ECU", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_ECUName), Messages.BtfTypeId_ECUDescr)); //$NON-NLS-1$ |
46 | builder.put("P", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_PName), Messages.BtfTypeId_PDescr)); //$NON-NLS-1$ | |
47 | builder.put("C", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_CName), Messages.BtfTypeId_CDescr)); //$NON-NLS-1$ | |
ff71e543 | 48 | // Operating system |
aa353506 AM |
49 | builder.put("SCHED", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SCHEDName), Messages.BtfTypeId_SCHEDDescr)); //$NON-NLS-1$ |
50 | builder.put("SIG", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIGName), Messages.BtfTypeId_SIGDescr)); //$NON-NLS-1$ | |
51 | builder.put("SEM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SEMName), Messages.BtfTypeId_SEMDescr)); //$NON-NLS-1$ | |
ff71e543 | 52 | // Information |
aa353506 | 53 | builder.put("SIM", new BtfEventType(nullToEmptyString(Messages.BtfTypeId_SIMName), Messages.BtfTypeId_SIMDescr)); //$NON-NLS-1$ |
ff71e543 MK |
54 | TYPES = builder.build(); |
55 | } | |
56 | ||
57 | /** | |
58 | * Parse the string and get a type id | |
59 | * | |
60 | * @param typeName | |
61 | * the string to parse | |
62 | * @return a BTF trace type, can be null if the string is invalid. | |
63 | */ | |
64 | public static BtfEventType parse(String typeName) { | |
65 | return TYPES.get(typeName); | |
66 | } | |
67 | ||
68 | } |