ss: Move all debugPrint() methods to the test stubs
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / statesystem / core / backend / IStateHistoryBackend.java
CommitLineData
a52fde77 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2012, 2014 Ericsson
a52fde77
AM
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5df842b3 5 *
a52fde77
AM
6 * All rights reserved. This program and the accompanying materials are
7 * made available under the terms of the Eclipse Public License v1.0 which
8 * accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
5df842b3 10 *
a52fde77
AM
11 *******************************************************************************/
12
e894a508 13package org.eclipse.tracecompass.statesystem.core.backend;
a52fde77
AM
14
15import java.io.File;
16import java.io.FileInputStream;
a52fde77
AM
17import java.util.List;
18
feea3b3c 19import org.eclipse.jdt.annotation.NonNull;
aa353506 20import org.eclipse.jdt.annotation.Nullable;
e894a508
AM
21import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
22import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
23import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
24import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
a52fde77
AM
25
26/**
27 * The main difference between StateSystem and StateHistorySystem is that SHS
28 * allows 'seeking' back in time to reload a Current State at a previous time.
29 * "How to go back in time" is defined by the implementation of the
30 * HistoryBackend.
5df842b3 31 *
a52fde77
AM
32 * A StateHistorySystem contains one and only one HistoryBackend. If you want to
33 * use a paradigm with more than one provider (eg. more or less precision
34 * depending on what's asked by the user), implement one wrapper HistoryBackend
35 * which can then contain your 2-3 other backends underneath.
5df842b3 36 *
bcec0116 37 * @author Alexandre Montplaisir
a52fde77
AM
38 */
39public interface IStateHistoryBackend {
40
b2f62cb5
AM
41 /**
42 * Get the ID of the state system that populates this backend.
43 *
44 * @return The state system's ID.
dbc7991d 45 * @since 1.0
b2f62cb5
AM
46 */
47 @NonNull String getSSID();
48
a52fde77
AM
49 /**
50 * Get the start time of this state history. This is usually the same as the
51 * start time of the originating trace.
5df842b3 52 *
a52fde77
AM
53 * @return The start time
54 */
57a2a5ca 55 long getStartTime();
a52fde77
AM
56
57 /**
58 * Get the current end time of the state history. It will change as the
59 * history is being built.
5df842b3 60 *
a52fde77
AM
61 * @return The end time
62 */
57a2a5ca 63 long getEndTime();
a52fde77
AM
64
65 /**
66 * Main method to insert state intervals into the history.
5df842b3 67 *
a52fde77
AM
68 * @param stateStartTime
69 * The start time of the interval
70 * @param stateEndTime
71 * The end time of the interval
72 * @param quark
73 * The quark of the attribute this interval refers to
74 * @param value
75 * The StateValue represented by this interval
76 * @throws TimeRangeException
77 * If the start or end time are invalid
78 */
79 // FIXME change to IStateInterval?
57a2a5ca 80 void insertPastState(long stateStartTime, long stateEndTime,
aa353506 81 int quark, @NonNull ITmfStateValue value) throws TimeRangeException;
a52fde77
AM
82
83 /**
84 * Indicate to the provider that we are done building the history (so it can
85 * close off, stop threads, etc.)
5df842b3 86 *
a52fde77
AM
87 * @param endTime
88 * The end time to assign to this state history. It could be
89 * farther in time than the last state inserted, for example.
90 * @throws TimeRangeException
91 * If the requested time makes no sense.
92 */
57a2a5ca 93 void finishedBuilding(long endTime) throws TimeRangeException;
a52fde77
AM
94
95 /**
96 * It is the responsibility of the backend to define where to save the
97 * Attribute Tree (since it's only useful to "reopen" an Attribute Tree if
98 * we have the matching History).
5df842b3 99 *
a52fde77
AM
100 * This method defines where to read for the attribute tree when opening an
101 * already-existing history. Refer to the file format documentation.
5df842b3 102 *
a52fde77
AM
103 * @return A FileInputStream object pointing to the correct file/location in
104 * the file where to read the attribute tree information.
105 */
57a2a5ca 106 FileInputStream supplyAttributeTreeReader();
a52fde77
AM
107
108 // FIXME change to FOS too?
5df842b3
AM
109 /**
110 * Supply the File object to which we will write the attribute tree. The
111 * position in this file is supplied by -TreeWriterFilePosition.
112 *
113 * @return The target File
114 */
57a2a5ca 115 File supplyAttributeTreeWriterFile();
a52fde77 116
5df842b3
AM
117 /**
118 * Supply the position in the file where we should write the attribute tree
119 * when asked to.
120 *
121 * @return The file position (we will seek() to it)
122 */
57a2a5ca 123 long supplyAttributeTreeWriterFilePosition();
a52fde77 124
36bf82a2
AM
125 /**
126 * Delete any generated files or anything that might have been created by
127 * the history backend (either temporary or save files). By calling this, we
128 * return to the state as it was before ever building the history.
5df842b3 129 *
36bf82a2
AM
130 * You might not want to call automatically if, for example, you want an
131 * index file to persist on disk. This could be limited to actions
132 * originating from the user.
133 */
57a2a5ca 134 void removeFiles();
36bf82a2 135
1a4205d9
AM
136 /**
137 * Notify the state history back-end that the trace is being closed, so it
138 * should release its file descriptors, close its connections, etc.
139 */
57a2a5ca 140 void dispose();
1a4205d9 141
3b7f5abe
AM
142 // ------------------------------------------------------------------------
143 // Query methods
144 // ------------------------------------------------------------------------
a52fde77
AM
145
146 /**
147 * Complete "give me the state at a given time" method 'currentStateInfo' is
148 * an "out" parameter, that is, write to it the needed information and
149 * return. DO NOT 'new' currentStateInfo, it will be lost and nothing will
150 * be returned!
5df842b3 151 *
a52fde77
AM
152 * @param currentStateInfo
153 * List of StateValues (index == quark) to fill up
154 * @param t
155 * Target timestamp of the query
5df842b3
AM
156 * @throws TimeRangeException
157 * If the timestamp is outside of the history/trace
3b7f5abe
AM
158 * @throws StateSystemDisposedException
159 * If the state system is disposed while a request is ongoing.
a52fde77 160 */
aa353506 161 void doQuery(@NonNull List<@Nullable ITmfStateInterval> currentStateInfo, long t)
3b7f5abe 162 throws TimeRangeException, StateSystemDisposedException;
a52fde77
AM
163
164 /**
165 * Some providers might want to specify a different way to obtain just a
166 * single StateValue instead of updating the whole list. If the method to
167 * use is the same, then feel free to just implement this as a wrapper using
168 * doQuery().
5df842b3 169 *
a52fde77
AM
170 * @param t
171 * The target timestamp of the query.
172 * @param attributeQuark
173 * The single attribute for which you want the state interval
ed48dc75
PT
174 * @return The state interval matching this timestamp/attribute pair, or
175 * null if it was not found
a52fde77
AM
176 * @throws TimeRangeException
177 * If the timestamp was invalid
3b7f5abe
AM
178 * @throws StateSystemDisposedException
179 * If the state system is disposed while a request is ongoing.
a52fde77 180 */
57a2a5ca 181 ITmfStateInterval doSingularQuery(long t, int attributeQuark)
ed48dc75 182 throws TimeRangeException, StateSystemDisposedException;
5df842b3 183
a52fde77 184}
This page took 0.113227 seconds and 5 git commands to generate.