tmf: Add a method to query an ongoing state's start time
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 28 Feb 2013 20:59:09 +0000 (15:59 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 4 Mar 2013 16:09:23 +0000 (11:09 -0500)
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 <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/10757
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bhufmann@gmail.com>
IP-Clean: Bernd Hufmann <bhufmann@gmail.com>

org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/TransientState.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java

index a9d69fea48910ac85a94d768ce3ebe0731dcea27..cd82f921198913a07891bc704d6c6458d1203808 100644 (file)
@@ -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)
     //--------------------------------------------------------------------------
index 19ec969c647a8b0d28b0284c34c7a7ef5fb6e3b5..1fae851b79620611a11ad2f56d6e8c8b38fc4d94 100644 (file)
@@ -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();
         }
index 6891dcdb37d6b7a3105f09df16e6c0cc5b4b2220..d432643e3cb4bd403f0a335c024150bf9bc8eb74 100644 (file)
@@ -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
This page took 0.030027 seconds and 5 git commands to generate.