private boolean started = true; /* Don't handle signals until we're ready */
/**
- * Instantiate a new HistoryBuilder helper.
+ * Instantiate a new HistoryBuilder helper. The input -> ss -> backend
+ * relationships should have been set up already.
*
* @param stateChangeInput
- * The input plugin to use. This is required.
+ * The input plugin to use
+ * @param ss
+ * The state system object that will receive the state changes
+ * from the input
* @param backend
- * The back-end storage to use.
+ * The back-end storage to use, which will receive the intervals
+ * from the ss
* @param buildManually
* Should we build this history in-band or not. True means we
* will start the building ourselves and block the caller until
* construction is done. False (out-of-band) means we will start
- * listening for the signal and return immediately. Another
- * signal will be sent when finished.
+ * listening for the signal and return immediately.
*/
- public HistoryBuilder(IStateChangeInput stateChangeInput,
+ public HistoryBuilder(IStateChangeInput stateChangeInput, StateSystem ss,
IStateHistoryBackend backend, boolean buildManually) {
- if (stateChangeInput == null || backend == null) {
+ if (stateChangeInput == null || backend == null || ss == null) {
throw new IllegalArgumentException();
}
+ if (stateChangeInput.getAssignedStateSystem() != ss) {
+ /* Logic check to make sure the input is setup properly */
+ throw new RuntimeException();
+ }
+
sci = stateChangeInput;
hb = backend;
- ss = new StateSystem(hb);
-
- sci.assignTargetStateSystem(ss);
+ this.ss = ss;
if (buildManually) {
TmfSignalManager.deregister(this);
import java.io.IOException;
import org.eclipse.linuxtools.internal.tmf.core.statesystem.HistoryBuilder;
+import org.eclipse.linuxtools.internal.tmf.core.statesystem.StateSystem;
import org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.IStateHistoryBackend;
import org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.InMemoryBackend;
import org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.NullBackend;
public static ITmfStateSystem loadStateHistory(File htFile,
IStateChangeInput htInput, boolean buildManually)
throws TmfTraceException {
- ITmfStateSystem ss;
IStateHistoryBackend htBackend;
/* If the target file already exists, do not rebuild it uselessly */
/* Load an existing history */
try {
htBackend = new HistoryTreeBackend(htFile);
- ss = HistoryBuilder.openExistingHistory(htBackend);
+ ITmfStateSystem ss = HistoryBuilder.openExistingHistory(htBackend);
return ss;
} catch (IOException e) {
/*
return null;
}
try {
- htBackend = new ThreadedHistoryTreeBackend(htFile,
- htInput.getStartTime(), QUEUE_SIZE);
- builder = new HistoryBuilder(htInput, htBackend, buildManually);
+ htBackend = new ThreadedHistoryTreeBackend(htFile, htInput.getStartTime(), QUEUE_SIZE);
+ StateSystem ss = new StateSystem(htBackend);
+ htInput.assignTargetStateSystem(ss);
+ builder = new HistoryBuilder(htInput, ss, htBackend, buildManually);
} catch (IOException e) {
/*
* If it fails here however, it means there was a problem writing to
*/
public static ITmfStateSystem newNullHistory(IStateChangeInput input) {
IStateHistoryBackend backend = new NullBackend();
- HistoryBuilder builder = new HistoryBuilder(input, backend, true);
- ITmfStateSystem ss = builder.getStateSystemQuerier();
- return ss;
+ StateSystem ss = new StateSystem(backend);
+ input.assignTargetStateSystem(ss);
+
+ HistoryBuilder builder = new HistoryBuilder(input, ss, backend, true);
+ return builder.getStateSystemQuerier();
}
/**
public static ITmfStateSystem newInMemHistory(IStateChangeInput input,
boolean buildManually) {
IStateHistoryBackend backend = new InMemoryBackend(input.getStartTime());
- HistoryBuilder builder = new HistoryBuilder(input, backend, buildManually);
+ StateSystem ss = new StateSystem(backend);
+ input.assignTargetStateSystem(ss);
+
+ HistoryBuilder builder = new HistoryBuilder(input, ss, backend, buildManually);
return builder.getStateSystemQuerier();
}
}