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