Move alltests plugin to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / linuxtools / tmf / core / timestamp / ITmfTimestamp.java
CommitLineData
5179fc01 1/*******************************************************************************
61759503 2 * Copyright (c) 2012, 2013 Ericsson
f8177ba2 3 *
5179fc01
FC
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
f8177ba2 8 *
5179fc01
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
3bd46eef
AM
13package org.eclipse.linuxtools.tmf.core.timestamp;
14
15import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
5179fc01
FC
16
17/**
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>
f8177ba2 32 *
d337369a 33 * @author Francois Chouinard
3bd46eef
AM
34 * @version 2.0
35 * @since 2.0
f8177ba2 36 *
f7703ed6 37 * @see ITmfEvent
d337369a 38 * @see TmfTimeRange
5179fc01 39 */
0316808c 40public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
5179fc01 41
f8177ba2
FC
42 // ------------------------------------------------------------------------
43 // Constants
44 // ------------------------------------------------------------------------
45
46 /**
47 * The millisecond scale factor (10e0)
f8177ba2 48 */
d96e9054 49 public static final int SECOND_SCALE = 0;
f8177ba2
FC
50
51 /**
52 * The millisecond scale factor (10e-3)
f8177ba2 53 */
d96e9054 54 public static final int MILLISECOND_SCALE = -3;
f8177ba2
FC
55
56 /**
57 * The microsecond scale factor (10e-6)
f8177ba2 58 */
d96e9054 59 public static final int MICROSECOND_SCALE = -6;
f8177ba2
FC
60
61 /**
62 * The nanosecond scale factor (10e-9)
f8177ba2 63 */
d96e9054 64 public static final int NANOSECOND_SCALE = -9;
f8177ba2 65
a4115405
FC
66 // ------------------------------------------------------------------------
67 // Getters
68 // ------------------------------------------------------------------------
69
5179fc01
FC
70 /**
71 * @return the timestamp value (magnitude)
72 */
57a2a5ca 73 long getValue();
5179fc01
FC
74
75 /**
76 * @return the timestamp scale (exponent)
77 */
57a2a5ca 78 int getScale();
5179fc01
FC
79
80 /**
81 * @return the timestamp precision (measurement tolerance)
82 */
57a2a5ca 83 int getPrecision();
5179fc01 84
a4115405
FC
85 // ------------------------------------------------------------------------
86 // Operations
87 // ------------------------------------------------------------------------
88
5179fc01 89 /**
f8177ba2
FC
90 * Normalize (adjust scale and offset) of the timestamp
91 *
5179fc01
FC
92 * @param offset the offset to apply to the timestamp value (after scaling)
93 * @param scale the new timestamp scale
94 * @return a new 'adjusted' ITmfTimestamp
95 */
57a2a5ca 96 ITmfTimestamp normalize(long offset, int scale);
5179fc01
FC
97
98 /**
99 * Compares [this] and [ts] within timestamp precision
f8177ba2 100 *
5179fc01
FC
101 * @param ts the other timestamp
102 * @param withinPrecision consider the precision when testing for equality
103 * @return -1, 0 or 1 (less than, equals, greater than)
104 */
57a2a5ca 105 int compareTo(ITmfTimestamp ts, boolean withinPrecision);
5179fc01
FC
106
107 /**
085d898f 108 * Returns the difference between [this] and [ts] as a timestamp
f8177ba2 109 *
5179fc01
FC
110 * @param ts the other timestamp
111 * @return the time difference (this - other) as an ITmfTimestamp
112 */
57a2a5ca 113 ITmfTimestamp getDelta(ITmfTimestamp ts);
5179fc01 114
1de55ea2
AM
115 /**
116 * Returns if this timestamp intersects the given time range. Borders are
117 * inclusive (for more fine-grained behavior, you can use
118 * {@link #compareTo(ITmfTimestamp)}.
119 *
120 * @param range
121 * The time range to compare to
122 * @return True if this timestamp is part of the time range, false if not
123 */
57a2a5ca 124 boolean intersects(TmfTimeRange range);
1de55ea2 125
a4115405
FC
126 // ------------------------------------------------------------------------
127 // Comparable
128 // ------------------------------------------------------------------------
129
d7dbf09a 130 @Override
b9e37ffd 131 int compareTo(ITmfTimestamp ts);
4df4581d 132
f8177ba2
FC
133 /**
134 * Format the timestamp as per the format provided
135 *
136 * @param format the timestamp formatter
137 * @return the formatted timestamp
138 * @since 2.0
139 */
57a2a5ca 140 String toString(final TmfTimestampFormat format);
f8177ba2 141
5179fc01 142}
This page took 0.06046 seconds and 5 git commands to generate.