Commit | Line | Data |
---|---|---|
a52fde77 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 Ericsson |
5df842b3 | 3 | * |
a52fde77 AM |
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 | |
5df842b3 | 8 | * |
a52fde77 AM |
9 | * Contributors: |
10 | * Alexandre Montplaisir - Initial API | |
11 | ******************************************************************************/ | |
12 | ||
e894a508 | 13 | package org.eclipse.tracecompass.statesystem.core.statevalue; |
a52fde77 | 14 | |
e894a508 | 15 | import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; |
6d08acca | 16 | |
a52fde77 AM |
17 | /** |
18 | * This is the interface for using state values and reading their contents. | |
5df842b3 | 19 | * |
2cb26548 | 20 | * @author Alexandre Montplaisir |
a52fde77 | 21 | */ |
f0247a1a | 22 | public interface ITmfStateValue extends Comparable<ITmfStateValue> { |
a52fde77 | 23 | |
b67a2540 AM |
24 | /** |
25 | * The supported types of state values | |
b67a2540 AM |
26 | */ |
27 | public enum Type { | |
28 | /** Null value, for an interval not carrying any information */ | |
29 | NULL, | |
30 | /** 32-bit integer value */ | |
31 | INTEGER, | |
a9cdbafc AM |
32 | /** 64-bit integer value */ |
33 | LONG, | |
ae09c4ad | 34 | /** IEEE 754 double precision number */ |
a3c22e8e | 35 | DOUBLE, |
b67a2540 | 36 | /** Variable-length string value */ |
1cbf1a19 | 37 | STRING, |
b67a2540 | 38 | } |
0e05a268 | 39 | |
a52fde77 | 40 | /** |
b67a2540 AM |
41 | * Each implementation has to define which one (among the supported types) |
42 | * they implement. There could be more than one implementation of each type, | |
43 | * depending on the needs of the different users. | |
5df842b3 | 44 | * |
b67a2540 | 45 | * @return The ITmfStateValue.Type enum representing the type of this value |
a52fde77 | 46 | */ |
57a2a5ca | 47 | Type getType(); |
a52fde77 AM |
48 | |
49 | /** | |
50 | * Only "null values" should return true here | |
5df842b3 | 51 | * |
a52fde77 AM |
52 | * @return True if this type of SV is considered "null", false if it |
53 | * contains a real value. | |
54 | */ | |
57a2a5ca | 55 | boolean isNull(); |
a52fde77 AM |
56 | |
57 | /** | |
58 | * Read the contained value as an 'int' primitive | |
5df842b3 | 59 | * |
a52fde77 AM |
60 | * @return The integer contained in the state value |
61 | * @throws StateValueTypeException | |
62 | * If the contained value cannot be read as an integer | |
63 | */ | |
6dd46830 | 64 | int unboxInt(); |
a52fde77 | 65 | |
1cbf1a19 FR |
66 | /** |
67 | * Read the contained value as a 'long' primitive | |
68 | * | |
69 | * @return The long contained in the state value | |
70 | * @throws StateValueTypeException | |
71 | * If the contained value cannot be read as a long | |
1cbf1a19 | 72 | */ |
6dd46830 | 73 | long unboxLong(); |
a9cdbafc | 74 | |
a3c22e8e AM |
75 | /** |
76 | * Read the contained value as a 'double' primitive | |
77 | * | |
78 | * @return The double contained in the state value | |
79 | * @throws StateValueTypeException | |
80 | * If the contained value cannot be read as a double | |
81 | */ | |
6dd46830 | 82 | double unboxDouble(); |
a3c22e8e | 83 | |
a9cdbafc AM |
84 | /** |
85 | * Read the contained value as a String | |
86 | * | |
87 | * @return The String contained in the state value | |
88 | * @throws StateValueTypeException | |
89 | * If the contained value cannot be read as a String | |
90 | */ | |
6dd46830 | 91 | String unboxStr(); |
f0247a1a | 92 | |
a52fde77 | 93 | } |