Commit | Line | Data |
---|---|---|
83051fc3 | 1 | /********************************************************************** |
55846ac5 | 2 | * Copyright (c) 2013, 2014 Ericsson |
83051fc3 BH |
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 | * Simon Delisle - Initial API and implementation | |
11 | * Bernd Hufmann - Updated to enum definition | |
55846ac5 | 12 | * Jonathan Rajotte - Updated enum definition for lttng machine interface |
83051fc3 BH |
13 | **********************************************************************/ |
14 | ||
8e8c0226 | 15 | package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl; |
83051fc3 BH |
16 | |
17 | /** | |
18 | * Constants for buffer type. | |
19 | * | |
20 | * @author Simon Delisle | |
21 | * @author Bernd Hufmann | |
22 | */ | |
23 | ||
24 | public enum BufferType { | |
25 | // ------------------------------------------------------------------------ | |
26 | // Enum definition | |
27 | // ------------------------------------------------------------------------ | |
28 | /** | |
29 | * Buffer type : per UID | |
30 | */ | |
55846ac5 | 31 | BUFFER_PER_UID("per UID", "PER_UID"), //$NON-NLS-1$ //$NON-NLS-2$ |
83051fc3 BH |
32 | /** |
33 | * Buffer type : per PID | |
34 | */ | |
55846ac5 | 35 | BUFFER_PER_PID("per PID", "PER_PID"), //$NON-NLS-1$ //$NON-NLS-2$ |
83051fc3 BH |
36 | /** |
37 | * Buffer type : shared | |
38 | */ | |
39 | BUFFER_SHARED("shared"), //$NON-NLS-1$ | |
40 | /** | |
41 | * If the LTTng version doesn't show the buffer type | |
42 | */ | |
43 | BUFFER_TYPE_UNKNOWN("information not unavailable"); //$NON-NLS-1$ | |
44 | ||
45 | // ------------------------------------------------------------------------ | |
46 | // Attributes | |
47 | // ------------------------------------------------------------------------ | |
48 | /** | |
49 | * Name of enum | |
50 | */ | |
51 | private final String fInName; | |
52 | ||
55846ac5 JRJ |
53 | /** |
54 | * Name of the machine interface enum | |
55 | */ | |
56 | private final String fInMiName; | |
57 | ||
83051fc3 BH |
58 | // ------------------------------------------------------------------------ |
59 | // Constuctors | |
60 | // ------------------------------------------------------------------------ | |
61 | ||
62 | /** | |
63 | * Private constructor | |
55846ac5 JRJ |
64 | * |
65 | * @param name | |
66 | * the name of state | |
83051fc3 | 67 | */ |
55846ac5 JRJ |
68 | private BufferType(String name, String miName) { |
69 | fInName = name; | |
70 | fInMiName = miName; | |
71 | } | |
72 | ||
83051fc3 BH |
73 | private BufferType(String name) { |
74 | fInName = name; | |
55846ac5 | 75 | fInMiName = ""; //$NON-NLS-1$ |
83051fc3 BH |
76 | } |
77 | ||
78 | // ------------------------------------------------------------------------ | |
79 | // Accessors | |
80 | // ------------------------------------------------------------------------ | |
81 | /** | |
82 | * @return state name | |
83 | */ | |
84 | public String getInName() { | |
85 | return fInName; | |
86 | } | |
55846ac5 JRJ |
87 | |
88 | /** | |
89 | * @return machine interface buffer name | |
90 | */ | |
91 | public String getInMiName() { | |
92 | return fInMiName; | |
93 | } | |
94 | ||
95 | // / | |
96 | // ------------------------------------------------------------------------ | |
97 | // Utility function | |
98 | // ------------------------------------------------------------------------- | |
99 | /** | |
100 | * @param name | |
101 | * the string representation of the type | |
102 | * @return enum BufferType of the corresponding type | |
103 | */ | |
104 | public static BufferType valueOfString(String name) { | |
105 | if (name == null) { | |
106 | throw new IllegalArgumentException(); | |
107 | } | |
108 | for (BufferType bufferType : BufferType.values()) { | |
109 | boolean isEqual = bufferType.getInName().equalsIgnoreCase(name) || bufferType.getInMiName().equalsIgnoreCase(name); | |
110 | if (isEqual) { | |
111 | return bufferType; | |
112 | } | |
113 | } | |
114 | return BUFFER_TYPE_UNKNOWN; | |
115 | } | |
83051fc3 | 116 | } |