Merge master in TmfTraceModel
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / EnumDefinition.java
1 /*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
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: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.ctf.core.event.types;
14
15 import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
16
17 /**
18 * <b><u>EnumDefinition</u></b>
19 */
20 public class EnumDefinition extends Definition {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26 private final EnumDeclaration declaration;
27
28 private final IntegerDefinition integerValue;
29
30 private String value;
31
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
35
36 public EnumDefinition(EnumDeclaration declaration,
37 IDefinitionScope definitionScope, String fieldName) {
38 super(definitionScope, fieldName);
39
40 this.declaration = declaration;
41
42 integerValue = declaration.getContainerType().createDefinition(
43 definitionScope, fieldName);
44 value = ((Long) integerValue.getValue()).toString();
45 }
46
47 // ------------------------------------------------------------------------
48 // Getters/Setters/Predicates
49 // ------------------------------------------------------------------------
50
51 public String getValue() {
52 return value;
53 }
54
55 public long getIntegerValue() {
56 return integerValue.getValue();
57 }
58
59 public void setIntegerValue(long Value) {
60 integerValue.setValue(Value);
61 value = ((Long) integerValue.getValue()).toString();
62 }
63
64 // ------------------------------------------------------------------------
65 // Operations
66 // ------------------------------------------------------------------------
67
68 @Override
69 public void read(BitBuffer input) {
70 integerValue.read(input);
71 long val = integerValue.getValue();
72
73 // TODO: what to do if the integer value maps to no string for this
74 // integer ?
75 value = declaration.query(val);
76 }
77
78 }
This page took 0.032487 seconds and 5 git commands to generate.