From 602c06978f31419b646228e973021e02672fcd11 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Thu, 28 Feb 2013 15:59:09 -0500 Subject: [PATCH] tmf: Add a method to query an ongoing state's start time We can already query a state system's current state value for a given attribute. It's trivial to expose a method to also query the start time of that state. Change-Id: I4b2610709bb0af33b612514007787b20f941f490 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/10757 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann --- .../tmf/core/statesystem/StateSystem.java | 8 ++++++-- .../tmf/core/statesystem/TransientState.java | 18 ++++++++---------- .../tmf/core/statesystem/ITmfStateSystem.java | 13 +++++++++++++ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java index a9d69fea48..cd82f92119 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java @@ -463,14 +463,18 @@ public class StateSystem implements ITmfStateSystemBuilder { return transState.getOngoingStateValue(attributeQuark); } + @Override + public long getOngoingStartTime(int attribute) + throws AttributeNotFoundException { + return transState.getOngoingStartTime(attribute); + } + @Override public void updateOngoingState(ITmfStateValue newValue, int attributeQuark) throws AttributeNotFoundException { transState.changeOngoingStateValue(attributeQuark, newValue); } - - //-------------------------------------------------------------------------- // Regular query methods (sent to the back-end) //-------------------------------------------------------------------------- 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 19ec969c64..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 @@ -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); } @@ -89,17 +91,13 @@ class TransientState { * @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(); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java index 6891dcdb37..d432643e3c 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java @@ -220,6 +220,19 @@ public interface ITmfStateSystem { public ITmfStateValue queryOngoingState(int attributeQuark) throws AttributeNotFoundException; + /** + * Get the start time of the current ongoing state, for the specified + * attribute. + * + * @param attribute + * Quark of the attribute + * @return The current start time of the ongoing state + * @throws AttributeNotFoundException + * If the attribute is invalid + */ + public long getOngoingStartTime(int attribute) + throws AttributeNotFoundException; + /** * Load the complete state information at time 't' into the returned List. * You can then get the intervals for single attributes by using -- 2.34.1