Commit | Line | Data |
---|---|---|
53047a66 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others |
53047a66 MK |
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 | *******************************************************************************/ | |
11 | ||
f357bcd4 | 12 | package org.eclipse.tracecompass.ctf.core.event.types; |
53047a66 | 13 | |
a4fa4e36 | 14 | import org.eclipse.jdt.annotation.NonNull; |
f357bcd4 | 15 | import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope; |
53047a66 | 16 | |
9ac2eb62 | 17 | /** |
d37aaa7f | 18 | * A CTF float definition. |
486efb2e | 19 | * |
d37aaa7f FC |
20 | * The definition of a floating point basic data type. It will take the data |
21 | * from a trace and store it (and make it fit) as a double. | |
9ac2eb62 | 22 | * |
d37aaa7f FC |
23 | * @version 1.0 |
24 | * @author Matthew Khouzam | |
25 | * @author Simon Marchi | |
9ac2eb62 | 26 | */ |
a4fa4e36 | 27 | public final class FloatDefinition extends Definition { |
53047a66 MK |
28 | // ------------------------------------------------------------------------ |
29 | // Attributes | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
a4fa4e36 | 32 | private final double fValue; |
53047a66 MK |
33 | |
34 | // ------------------------------------------------------------------------ | |
a511da0d | 35 | // Constructors |
53047a66 MK |
36 | // ------------------------------------------------------------------------ |
37 | ||
9ac2eb62 MK |
38 | /** |
39 | * Constructor | |
40 | * | |
41 | * @param declaration | |
42 | * the parent declaration | |
43 | * @param definitionScope | |
44 | * the parent scope | |
45 | * @param fieldName | |
46 | * the field name | |
a4fa4e36 MK |
47 | * @param value |
48 | * field value | |
49 | * @since 3.0 | |
9ac2eb62 | 50 | */ |
a4fa4e36 MK |
51 | public FloatDefinition(@NonNull FloatDeclaration declaration, |
52 | IDefinitionScope definitionScope, @NonNull String fieldName, double value) { | |
53 | super(declaration, definitionScope, fieldName); | |
54 | fValue = value; | |
53047a66 | 55 | } |
07002e0a | 56 | |
53047a66 | 57 | // ------------------------------------------------------------------------ |
a511da0d | 58 | // Getters/Setters/Predicates |
53047a66 MK |
59 | // ------------------------------------------------------------------------ |
60 | ||
9ac2eb62 | 61 | /** |
a511da0d | 62 | * The value of a float stored, fit into a double. This should be extended |
9ac2eb62 MK |
63 | * for exotic floats if this is necessary. |
64 | * | |
65 | * @return the value of the float field fit into a double. | |
66 | */ | |
53047a66 | 67 | public double getValue() { |
a4fa4e36 | 68 | return fValue; |
53047a66 MK |
69 | } |
70 | ||
9ac2eb62 | 71 | @Override |
53047a66 | 72 | public FloatDeclaration getDeclaration() { |
a4fa4e36 | 73 | return (FloatDeclaration) super.getDeclaration(); |
53047a66 MK |
74 | } |
75 | ||
76 | // ------------------------------------------------------------------------ | |
77 | // Operations | |
78 | // ------------------------------------------------------------------------ | |
79 | ||
53047a66 MK |
80 | @Override |
81 | public String toString() { | |
a4fa4e36 | 82 | return String.valueOf(fValue); |
53047a66 MK |
83 | } |
84 | } |