1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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 * Alexandre Montplaisir - Removed concept of precision
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.core
.timestamp
;
16 import org
.eclipse
.jdt
.annotation
.NonNull
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
20 * The fundamental time reference in the TMF.
22 * It defines a generic timestamp interface in its most basic form:
24 * <li>timestamp = [value] * 10**[scale] +/- [precision]
28 * <li>[value] is an unstructured integer value
29 * <li>[scale] is the magnitude of the value wrt some application-specific
30 * base unit (e.g. the second)
31 * <li>[precision] indicates the error on the value (useful for comparing
32 * timestamps in different scales). Default: 0.
35 * @author Francois Chouinard
40 public interface ITmfTimestamp
extends Comparable
<ITmfTimestamp
> {
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
47 * The millisecond scale factor (10e0)
52 * The millisecond scale factor (10e-3)
54 int MILLISECOND_SCALE
= -3;
57 * The microsecond scale factor (10e-6)
59 int MICROSECOND_SCALE
= -6;
62 * The nanosecond scale factor (10e-9)
64 int NANOSECOND_SCALE
= -9;
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 * @return the timestamp value (magnitude)
76 * @return the timestamp scale (exponent)
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * Normalize (adjust scale and offset) of the timestamp
87 * @param offset the offset to apply to the timestamp value (after scaling)
88 * @param scale the new timestamp scale
89 * @return a new 'adjusted' ITmfTimestamp
91 @NonNull ITmfTimestamp
normalize(long offset
, int scale
);
94 * Returns the difference between [this] and [ts] as a timestamp
96 * @param ts the other timestamp
97 * @return the time difference (this - other) as an ITmfTimestamp
99 @NonNull ITmfTimestamp
getDelta(ITmfTimestamp ts
);
102 * Returns if this timestamp intersects the given time range. Borders are
103 * inclusive (for more fine-grained behavior, you can use
104 * {@link #compareTo(ITmfTimestamp)}.
107 * The time range to compare to
108 * @return True if this timestamp is part of the time range, false if not
110 boolean intersects(TmfTimeRange range
);
112 // ------------------------------------------------------------------------
114 // ------------------------------------------------------------------------
117 int compareTo(ITmfTimestamp ts
);
120 * Format the timestamp as per the format provided
122 * @param format the timestamp formatter
123 * @return the formatted timestamp
125 String
toString(final TmfTimestampFormat format
);