1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.timestamp
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
18 * The fundamental time reference in the TMF.
20 * It defines a generic timestamp interface in its most basic form:
22 * <li>timestamp = [value] * 10**[scale] +/- [precision]
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.
33 * @author Francois Chouinard
40 public interface ITmfTimestamp
extends Comparable
<ITmfTimestamp
> {
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
47 * The millisecond scale factor (10e0)
50 public static final int SECOND_SCALE
= 0;
53 * The millisecond scale factor (10e-3)
56 public static final int MILLISECOND_SCALE
= -3;
59 * The microsecond scale factor (10e-6)
62 public static final int MICROSECOND_SCALE
= -6;
65 * The nanosecond scale factor (10e-9)
68 public static final int NANOSECOND_SCALE
= -9;
70 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
75 * @return the timestamp value (magnitude)
77 public long getValue();
80 * @return the timestamp scale (exponent)
82 public int getScale();
85 * @return the timestamp precision (measurement tolerance)
87 public int getPrecision();
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
94 * Normalize (adjust scale and offset) of the timestamp
96 * @param offset the offset to apply to the timestamp value (after scaling)
97 * @param scale the new timestamp scale
98 * @return a new 'adjusted' ITmfTimestamp
100 public ITmfTimestamp
normalize(long offset
, int scale
);
103 * Compares [this] and [ts] within timestamp precision
105 * @param ts the other timestamp
106 * @param withinPrecision consider the precision when testing for equality
107 * @return -1, 0 or 1 (less than, equals, greater than)
109 public int compareTo(ITmfTimestamp ts
, boolean withinPrecision
);
112 * Returns the difference between [this] and [ts] as a timestamp
114 * @param ts the other timestamp
115 * @return the time difference (this - other) as an ITmfTimestamp
117 public ITmfTimestamp
getDelta(ITmfTimestamp ts
);
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 * @see java.lang.Comparable#compareTo(java.lang.Object)
127 int compareTo(ITmfTimestamp ts
);
130 * Format the timestamp as per the format provided
132 * @param format the timestamp formatter
133 * @return the formatted timestamp
136 public String
toString(final TmfTimestampFormat format
);