tmf: Add a method to query an ongoing state's start time
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / statesystem / TransientState.java
index 632612313d35fe39c23a988feadb35a23cd186a8..1fae851b79620611a11ad2f56d6e8c8b38fc4d94 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  * Copyright (c) 2010, 2011 École Polytechnique de Montréal
  * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
  *
@@ -16,6 +16,7 @@ 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;
@@ -67,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);
     }
@@ -88,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();
         }
@@ -270,9 +269,9 @@ class TransientState {
         assert (this.isActive);
 
         for (int i = 0; i < ongoingStateInfo.size(); i++) {
-            if (ongoingStateStartTimes.get(i) >= endTime) {
+            if (ongoingStateStartTimes.get(i) > endTime) {
                 /*
-                 * Handle the cases where trace end >= timetamp of last state
+                 * Handle the cases where trace end > timestamp of last state
                  * change. This can happen when inserting "future" changes.
                  */
                 continue;
@@ -335,4 +334,4 @@ class TransientState {
         return;
     }
 
-}
\ No newline at end of file
+}
This page took 0.025035 seconds and 5 git commands to generate.