X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Finternal%2Ftmf%2Fcore%2Fstatesystem%2FTransientState.java;h=1fae851b79620611a11ad2f56d6e8c8b38fc4d94;hb=602c06978f31419b646228e973021e02672fcd11;hp=020c863cfa845f06087def780c072b26b29ac942;hpb=18ab1d186c51dac1018b11bcb8dd72d7df8dad2e;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java index 020c863cfa..1fae851b79 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2012 Ericsson + * Copyright (c) 2012, 2013 Ericsson * Copyright (c) 2010, 2011 École Polytechnique de Montréal * Copyright (c) 2010, 2011 Alexandre Montplaisir - * + * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * *******************************************************************************/ package org.eclipse.linuxtools.internal.tmf.core.statesystem; @@ -16,12 +16,12 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; +import org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.IStateHistoryBackend; import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException; import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException; import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException; import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval; import org.eclipse.linuxtools.tmf.core.interval.TmfStateInterval; -import org.eclipse.linuxtools.tmf.core.statesystem.IStateHistoryBackend; import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue; import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue; @@ -29,14 +29,14 @@ import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue; * The Transient State is used to build intervals from punctual state changes. It * contains a "state info" vector similar to the "current state", except here we * also record the start time of every state stored in it. - * + * * We can then build StateInterval's, to be inserted in the State History when * we detect state changes : the "start time" of the interval will be the * recorded time we have here, and the "end time" will be the timestamp of the * new state-changing event we just read. - * + * * @author alexmont - * + * */ class TransientState { @@ -68,16 +68,18 @@ class TransientState { return latestTime; } - ITmfStateValue getOngoingStateValue(int index) - throws AttributeNotFoundException { - + ITmfStateValue getOngoingStateValue(int index) throws AttributeNotFoundException { checkValidAttribute(index); return ongoingStateInfo.get(index); } + long getOngoingStartTime(int index) throws AttributeNotFoundException { + checkValidAttribute(index); + return ongoingStateStartTimes.get(index); + } + void changeOngoingStateValue(int index, ITmfStateValue newValue) throws AttributeNotFoundException { - checkValidAttribute(index); ongoingStateInfo.set(index, newValue); } @@ -85,21 +87,17 @@ class TransientState { /** * Return the "ongoing" value for a given attribute as a dummy interval * whose end time = -1 (since we don't know its real end time yet). - * + * * @param quark * @throws AttributeNotFoundException */ - ITmfStateInterval getOngoingInterval(int quark) - throws AttributeNotFoundException { - + ITmfStateInterval getOngoingInterval(int quark) throws AttributeNotFoundException { checkValidAttribute(quark); return new TmfStateInterval(ongoingStateStartTimes.get(quark), -1, quark, ongoingStateInfo.get(quark)); } - private void checkValidAttribute(int quark) - throws AttributeNotFoundException { - + private void checkValidAttribute(int quark) throws AttributeNotFoundException { if (quark > ongoingStateInfo.size() - 1 || quark < 0) { throw new AttributeNotFoundException(); } @@ -109,10 +107,10 @@ class TransientState { * Batch method of changeOngoingStateValue(), updates the complete * ongoingStateInfo in one go. BE VERY CAREFUL WITH THIS! Especially with * the sizes of both arrays. - * + * * Note that the new ongoingStateInfo will be a shallow copy of * newStateInfo, so that last one must be already instantiated and all. - * + * * @param newStateInfo * The List of StateValues to replace the old ongoingStateInfo * one. @@ -147,10 +145,10 @@ class TransientState { * Ask if the state information about attribute 'quark' at time 'time' is * present in the Builder as it is right now. If it's not, it's either in * the History Tree, or not in the system at all. - * + * * Note that this method does not return the value itself (we don't even * look for it, we can know by just looking at the timestamp) - * + * * @param time * The timestamp to look for * @param quark @@ -165,7 +163,7 @@ class TransientState { /** * This is the lower-level method that will be called by the * StateHistorySystem (with already-built StateValues and timestamps) - * + * * @param index * The index in the vectors (== the quark of the attribute) * @param value @@ -174,28 +172,28 @@ class TransientState { * The timestamp associated with this state change * @throws TimeRangeException * @throws AttributeNotFoundException - * @throws StateValueTypeException + * @throws StateValueTypeException */ synchronized void processStateChange(long eventTime, ITmfStateValue value, int index) throws TimeRangeException, AttributeNotFoundException, StateValueTypeException { assert (this.isActive); - + byte expectedSvType = stateValueTypes.get(index); checkValidAttribute(index); - - /* + + /* * Make sure the state value type we're inserting is the same as the * one registered for this attribute. */ if (expectedSvType == -1) { - /* + /* * The value hasn't been used yet, set it to the value * we're currently inserting (which might be null/-1 again). */ stateValueTypes.set(index, value.getType()); } else if ((value.getType() != -1) && (value.getType() != expectedSvType)) { - /* + /* * We authorize inserting null values in any type of attribute, * but for every other types, it needs to match our expectations! */ @@ -234,7 +232,7 @@ class TransientState { /** * Run a "get state at time" query on the Transient State only. - * + * * @param stateInfo * The stateInfo object in which we will put our relevant * information @@ -271,10 +269,10 @@ class TransientState { assert (this.isActive); for (int i = 0; i < ongoingStateInfo.size(); i++) { - if (ongoingStateStartTimes.get(i) == endTime) { + if (ongoingStateStartTimes.get(i) > endTime) { /* - * Handle this rare case where trace end == timetamp of last - * state change + * Handle the cases where trace end > timestamp of last state + * change. This can happen when inserting "future" changes. */ continue; } @@ -301,7 +299,7 @@ class TransientState { /** * Simply returns if this Transient State is currently being used or not - * + * * @return */ boolean isActive() { @@ -314,7 +312,7 @@ class TransientState { /** * Debugging method that prints the contents of both 'ongoing...' vectors - * + * * @param writer */ void debugPrint(PrintWriter writer) { @@ -336,4 +334,4 @@ class TransientState { return; } -} \ No newline at end of file +}