Commit | Line | Data |
---|---|---|
5179fc01 FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 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 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.core.event; | |
14 | ||
15 | /** | |
7636a88e | 16 | * The fundamental time reference in the TMF. |
17 | * <p> | |
18 | * It defines a generic timestamp interface in its most basic form: | |
19 | * <ul> | |
20 | * <li>timestamp = [value] * 10**[scale] +/- [precision] | |
21 | * </ul> | |
22 | * Where: | |
23 | * <ul> | |
24 | * <li>[value] is an unstructured integer value | |
25 | * <li>[scale] is the magnitude of the value wrt some application-specific | |
26 | * base unit (e.g. the second) | |
27 | * <li>[precision] indicates the error on the value (useful for comparing | |
28 | * timestamps in different scales). Default: 0. | |
29 | * </ul> | |
d337369a | 30 | * |
d337369a FC |
31 | * @version 1.0 |
32 | * @author Francois Chouinard | |
f7703ed6 FC |
33 | * |
34 | * @see ITmfEvent | |
d337369a | 35 | * @see TmfTimeRange |
5179fc01 | 36 | */ |
0316808c | 37 | public interface ITmfTimestamp extends Comparable<ITmfTimestamp> { |
5179fc01 | 38 | |
a4115405 FC |
39 | // ------------------------------------------------------------------------ |
40 | // Getters | |
41 | // ------------------------------------------------------------------------ | |
42 | ||
5179fc01 FC |
43 | /** |
44 | * @return the timestamp value (magnitude) | |
45 | */ | |
46 | public long getValue(); | |
47 | ||
48 | /** | |
49 | * @return the timestamp scale (exponent) | |
50 | */ | |
51 | public int getScale(); | |
52 | ||
53 | /** | |
54 | * @return the timestamp precision (measurement tolerance) | |
55 | */ | |
56 | public int getPrecision(); | |
57 | ||
a4115405 FC |
58 | // ------------------------------------------------------------------------ |
59 | // Operations | |
60 | // ------------------------------------------------------------------------ | |
61 | ||
5179fc01 FC |
62 | /** |
63 | * Normalize (adjust scale and offset) of the timerstamp | |
64 | * | |
65 | * @param offset the offset to apply to the timestamp value (after scaling) | |
66 | * @param scale the new timestamp scale | |
67 | * @return a new 'adjusted' ITmfTimestamp | |
68 | */ | |
b9e37ffd | 69 | public ITmfTimestamp normalize(long offset, int scale); |
5179fc01 FC |
70 | |
71 | /** | |
72 | * Compares [this] and [ts] within timestamp precision | |
73 | * | |
74 | * @param ts the other timestamp | |
75 | * @param withinPrecision consider the precision when testing for equality | |
76 | * @return -1, 0 or 1 (less than, equals, greater than) | |
77 | */ | |
78 | public int compareTo(ITmfTimestamp ts, boolean withinPrecision); | |
79 | ||
80 | /** | |
085d898f | 81 | * Returns the difference between [this] and [ts] as a timestamp |
5179fc01 FC |
82 | * |
83 | * @param ts the other timestamp | |
84 | * @return the time difference (this - other) as an ITmfTimestamp | |
85 | */ | |
86 | public ITmfTimestamp getDelta(ITmfTimestamp ts); | |
87 | ||
7636a88e | 88 | /** |
89 | * @return a clone of the timestamp | |
90 | */ | |
4df4581d | 91 | public ITmfTimestamp clone(); |
085d898f | 92 | |
a4115405 FC |
93 | // ------------------------------------------------------------------------ |
94 | // Comparable | |
95 | // ------------------------------------------------------------------------ | |
96 | ||
7636a88e | 97 | /* (non-Javadoc) |
98 | * @see java.lang.Comparable#compareTo(java.lang.Object) | |
99 | */ | |
d7dbf09a | 100 | @Override |
b9e37ffd | 101 | int compareTo(ITmfTimestamp ts); |
4df4581d | 102 | |
5179fc01 | 103 | } |