Class ConsumerChoicePointFrame

  • All Implemented Interfaces:
    LPAgendaEntry, LPInterpreterState

    public class ConsumerChoicePointFrame
    extends GenericTripleMatchFrame
    implements LPAgendaEntry, LPInterpreterState
    Frame in the LPInterpreter's control stack used to represent matching to the results of a tabled predicate. Conventionally the system state which finds and tables the goal results is called the generator and states which require those results are called consumers.

    This is used in the inner loop of the interpreter and so is a pure data structure not an abstract data type and assumes privileged access to the interpreter state.

    • Constructor Detail

      • ConsumerChoicePointFrame

        public ConsumerChoicePointFrame​(LPInterpreter interpreter)
        Constructor.
        Parameters:
        interpreter - the parent interpreter whose state is to be preserved here, its arg stack defines the parameters for the target goal
    • Method Detail

      • init

        public void init​(LPInterpreter interpreter)
        Initialize the choice point state.
        Overrides:
        init in class GenericTripleMatchFrame
        Parameters:
        interpreter - the parent interpreter whose state is to be preserved here, its arg stack defines the parameters for the target goal
      • preserveState

        public void preserveState​(java.util.List<Node> trail)
        Preserve the state of an interpreter into this frame.
      • restoreState

        public void restoreState​(LPInterpreter interp)
        Restore the state of an interpreter from this frame
      • nextMatch

        public StateFlag nextMatch​(LPInterpreter interpreter)
        Find the next result triple and bind the result vars appropriately.
        Parameters:
        interpreter - the calling interpreter whose trail should be used
        Returns:
        FAIL if there are no more matches and the generator is closed, SUSPEND if there are no more matches but the generator could generate more, SATISFIED if a match has been found.
      • isReady

        public boolean isReady()
        Return true if this choice point could usefully be restarted.
        Specified by:
        isReady in interface LPAgendaEntry
      • setReady

        public void setReady()
        Called by generator when there are more results available.
      • close

        public void close()
        Description copied from class: FrameObject
        Close the frame actively. This frees any internal resources, frees this frame and frees the frame to which this is linked.
        Overrides:
        close in class FrameObject
      • setFinished

        public void setFinished()
        Notify that this consumer choice point has finished consuming all the results of a closed generator.
      • pump

        public void pump()
        Reactivate this choice point to return new results.
        Specified by:
        pump in interface LPAgendaEntry
      • getGenerator

        public Generator getGenerator()
        Return the generator associated with this entry (might be the entry itself)
        Specified by:
        getGenerator in interface LPAgendaEntry
      • getConsumingContext

        public LPInterpreterContext getConsumingContext()
        Return the interpeter context which is reading the results of this consumer.