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 | /** | |
16 | * <b><u>ITmfTimestamp</u></b> | |
17 | * <p> | |
7636a88e | 18 | * The fundamental time reference in the TMF. |
19 | * <p> | |
20 | * It defines a generic timestamp interface in its most basic form: | |
21 | * <ul> | |
22 | * <li>timestamp = [value] * 10**[scale] +/- [precision] | |
23 | * </ul> | |
24 | * Where: | |
25 | * <ul> | |
26 | * <li>[value] is an unstructured integer value | |
27 | * <li>[scale] is the magnitude of the value wrt some application-specific | |
28 | * base unit (e.g. the second) | |
29 | * <li>[precision] indicates the error on the value (useful for comparing | |
30 | * timestamps in different scales). Default: 0. | |
31 | * </ul> | |
5179fc01 | 32 | */ |
4df4581d | 33 | public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> { |
5179fc01 FC |
34 | |
35 | /** | |
36 | * @return the timestamp value (magnitude) | |
37 | */ | |
38 | public long getValue(); | |
39 | ||
40 | /** | |
41 | * @return the timestamp scale (exponent) | |
42 | */ | |
43 | public int getScale(); | |
44 | ||
45 | /** | |
46 | * @return the timestamp precision (measurement tolerance) | |
47 | */ | |
48 | public int getPrecision(); | |
49 | ||
50 | /** | |
51 | * Normalize (adjust scale and offset) of the timerstamp | |
52 | * | |
53 | * @param offset the offset to apply to the timestamp value (after scaling) | |
54 | * @param scale the new timestamp scale | |
55 | * @return a new 'adjusted' ITmfTimestamp | |
56 | */ | |
57 | public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException; | |
58 | ||
59 | /** | |
60 | * Compares [this] and [ts] within timestamp precision | |
61 | * | |
62 | * @param ts the other timestamp | |
63 | * @param withinPrecision consider the precision when testing for equality | |
64 | * @return -1, 0 or 1 (less than, equals, greater than) | |
65 | */ | |
66 | public int compareTo(ITmfTimestamp ts, boolean withinPrecision); | |
67 | ||
68 | /** | |
69 | * Returns the difference between [this] and [ts] as a timestamp | |
70 | * | |
71 | * @param ts the other timestamp | |
72 | * @return the time difference (this - other) as an ITmfTimestamp | |
73 | */ | |
74 | public ITmfTimestamp getDelta(ITmfTimestamp ts); | |
75 | ||
7636a88e | 76 | /** |
77 | * @return a clone of the timestamp | |
78 | */ | |
4df4581d | 79 | public ITmfTimestamp clone(); |
80 | ||
7636a88e | 81 | /* (non-Javadoc) |
82 | * @see java.lang.Comparable#compareTo(java.lang.Object) | |
83 | */ | |
d7dbf09a | 84 | @Override |
4df4581d | 85 | public int compareTo(ITmfTimestamp ts); |
86 | ||
5179fc01 | 87 | } |