Simplify TmfEvent constructors and update javadoc
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / ITmfTimestamp.java
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 * 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>
30 *
31 * @since 1.0
32 * @version 1.0
33 * @author Francois Chouinard
34 *
35 * @see ITmfEvent
36 * @see TmfTimeRange
37 */
38 public interface ITmfTimestamp extends Cloneable, Comparable<ITmfTimestamp> {
39
40 // ------------------------------------------------------------------------
41 // Getters
42 // ------------------------------------------------------------------------
43
44 /**
45 * @return the timestamp value (magnitude)
46 */
47 public long getValue();
48
49 /**
50 * @return the timestamp scale (exponent)
51 */
52 public int getScale();
53
54 /**
55 * @return the timestamp precision (measurement tolerance)
56 */
57 public int getPrecision();
58
59 // ------------------------------------------------------------------------
60 // Operations
61 // ------------------------------------------------------------------------
62
63 /**
64 * Normalize (adjust scale and offset) of the timerstamp
65 *
66 * @param offset the offset to apply to the timestamp value (after scaling)
67 * @param scale the new timestamp scale
68 * @return a new 'adjusted' ITmfTimestamp
69 */
70 public ITmfTimestamp normalize(long offset, int scale);
71
72 /**
73 * Compares [this] and [ts] within timestamp precision
74 *
75 * @param ts the other timestamp
76 * @param withinPrecision consider the precision when testing for equality
77 * @return -1, 0 or 1 (less than, equals, greater than)
78 */
79 public int compareTo(ITmfTimestamp ts, boolean withinPrecision);
80
81 /**
82 * Returns the difference between [this] and [ts] as a timestamp
83 *
84 * @param ts the other timestamp
85 * @return the time difference (this - other) as an ITmfTimestamp
86 */
87 public ITmfTimestamp getDelta(ITmfTimestamp ts);
88
89 // ------------------------------------------------------------------------
90 // Cloneable
91 // ------------------------------------------------------------------------
92
93 /**
94 * @return a clone of the timestamp
95 */
96 public ITmfTimestamp clone();
97
98 // ------------------------------------------------------------------------
99 // Comparable
100 // ------------------------------------------------------------------------
101
102 /* (non-Javadoc)
103 * @see java.lang.Comparable#compareTo(java.lang.Object)
104 */
105 @Override
106 int compareTo(ITmfTimestamp ts);
107
108 }
This page took 0.032918 seconds and 5 git commands to generate.