Fix for supplementary comments on TmftimestampFormat implementation
[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 * @version 2.0
32 * @author Francois Chouinard
33 *
34 * @see ITmfEvent
35 * @see TmfTimeRange
36 */
37 public interface ITmfTimestamp extends Comparable<ITmfTimestamp> {
38
39 // ------------------------------------------------------------------------
40 // Constants
41 // ------------------------------------------------------------------------
42
43 /**
44 * The millisecond scale factor (10e0)
45 * @since 2.0
46 */
47 public static final int SECOND_SCALE = 0;
48
49 /**
50 * The millisecond scale factor (10e-3)
51 * @since 2.0
52 */
53 public static final int MILLISECOND_SCALE = -3;
54
55 /**
56 * The microsecond scale factor (10e-6)
57 * @since 2.0
58 */
59 public static final int MICROSECOND_SCALE = -6;
60
61 /**
62 * The nanosecond scale factor (10e-9)
63 * @since 2.0
64 */
65 public static final int NANOSECOND_SCALE = -9;
66
67 // ------------------------------------------------------------------------
68 // Getters
69 // ------------------------------------------------------------------------
70
71 /**
72 * @return the timestamp value (magnitude)
73 */
74 public long getValue();
75
76 /**
77 * @return the timestamp scale (exponent)
78 */
79 public int getScale();
80
81 /**
82 * @return the timestamp precision (measurement tolerance)
83 */
84 public int getPrecision();
85
86 // ------------------------------------------------------------------------
87 // Operations
88 // ------------------------------------------------------------------------
89
90 /**
91 * Normalize (adjust scale and offset) of the timestamp
92 *
93 * @param offset the offset to apply to the timestamp value (after scaling)
94 * @param scale the new timestamp scale
95 * @return a new 'adjusted' ITmfTimestamp
96 */
97 public ITmfTimestamp normalize(long offset, int scale);
98
99 /**
100 * Compares [this] and [ts] within timestamp precision
101 *
102 * @param ts the other timestamp
103 * @param withinPrecision consider the precision when testing for equality
104 * @return -1, 0 or 1 (less than, equals, greater than)
105 */
106 public int compareTo(ITmfTimestamp ts, boolean withinPrecision);
107
108 /**
109 * Returns the difference between [this] and [ts] as a timestamp
110 *
111 * @param ts the other timestamp
112 * @return the time difference (this - other) as an ITmfTimestamp
113 */
114 public ITmfTimestamp getDelta(ITmfTimestamp ts);
115
116 /**
117 * @return a clone of the timestamp
118 */
119 public ITmfTimestamp clone();
120
121 // ------------------------------------------------------------------------
122 // Comparable
123 // ------------------------------------------------------------------------
124
125 /* (non-Javadoc)
126 * @see java.lang.Comparable#compareTo(java.lang.Object)
127 */
128 @Override
129 int compareTo(ITmfTimestamp ts);
130
131 /**
132 * Format the timestamp as per the format provided
133 *
134 * @param format the timestamp formatter
135 * @return the formatted timestamp
136 * @since 2.0
137 */
138 public String toString(final TmfTimestampFormat format);
139
140 }
This page took 0.033273 seconds and 5 git commands to generate.