java.lang.Object
org.eclipse.tracecompass.incubator.scripting.core.analysis.ScriptedAnalysis

public class ScriptedAnalysis extends Object
Analysis class that can be used with the scripts. It provides an event iterator, as well as backends to store data. Scripts can thus parse events and fill the backend appropriately.
Author:
Geneviève Bastien
  • Method Details

    • getStateSystem

      public @Nullable ITmfStateSystemBuilder getStateSystem(@ScriptParameter(defaultValue="false") boolean useExisting)
      Get a state system to go with this analysis. If an analysis of the same name already exists, it can be re-used instead of re-created.
      Parameters:
      useExisting - if true, any state system with the same name for the trace will be reused, otherwise, a new state system will be created
      Returns:
      A state system builder
    • getEventIterator

      public ScriptEventsIterator getEventIterator()
      Get an iterator to iterate chronologically through the events of the trace. To reduce overhead of passing all events to/from the script when only a subset of events is requested, the ScriptEventsIterator.addEvent(String) method can be used to set the events to filter. Thus, to iterate through a trace in a scripted analysis, one can just do the following snippet (javascript)
       var iter = analysis.getEventIterator();
      
       var event = null;
       while (iter.hasNext()) {
      
           event = iter.next();
      
           // Do something with the event
       }
       
      Returns:
      The event iterator, starting from the first event
    • getTrace

      public ITmfTrace getTrace()
      Get the trace, not to be used by scripts.
      Returns:
      The trace
    • getName

      public String getName()
      Get the name of this analysis, not to be used by scripts
      Returns:
      The name of the analysis
    • complete

      public void complete()
      Make sure the analysis is complete and the state system, if any, is closed. It will close the state system at the end time of the trace if is has not been closed previously. If no state system was requested through the getStateSystem(boolean) before hand, nothing will happen.
    • isComplete

      public boolean isComplete()
      Get whether this analysis is complete, ie, if a state systemw as requested by the getStateSystem(boolean) method, then the state system has been closed.
      Returns:
      Whether the analysis is complete and the state system was closed