org.eclipse.incquery.runtime.rete.misc

## Class DeltaMonitor<MatchType>

- java.lang.Object
- - org.eclipse.incquery.runtime.rete.network.BaseNode
  - - org.eclipse.incquery.runtime.rete.misc.SimpleReceiver
    - - org.eclipse.incquery.runtime.rete.misc.DeltaMonitor<MatchType>

- All Implemented Interfaces:
    Node, Receiver, Clearable
  Direct Known Subclasses:
    DefaultDeltaMonitor

      public abstract class DeltaMonitor<MatchType>
      extends SimpleReceiver
      implements Clearable

  A monitoring object that connects to the rete network as a receiver to reflect changes since an arbitrary state acknowledged by the client. Match tuples are represented by a type MatchType.

  Usage. If a new matching is found, it appears in the matchFoundEvents collection, and disappears when that particular matching cannot be found anymore. If the event of finding a match has been processed by the client, it can be removed manually. In this case, when a previously found matching is lost, the Tuple will appear in the matchLostEvents collection, and disappear upon finding the same matching again. "Matching lost" events can also be acknowledged by removing a Tuple from the collection. If the matching is found once again, it will return to matchFoundEvents.

  Technical notes. Does NOT propagate updates! By overriding statelessConvert(), results can be stored to a MatchType. MatchType must provide equals() and hashCode() reflecting its contents. The default implementation (DefaultDeltaMonitor) uses Tuple as MatchType. By overriding statelessFilter(), some tuples can be filtered.

  Author:
    Gabor Bergmann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.util.Collection<MatchType>` | `matchFoundEvents` matches that are newly found
    `java.util.Collection<MatchType>` | `matchLostEvents` matches that are newly lost

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeltaMonitor(ReteContainer reteContainer)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear all partial matchings stored in memory
    `abstract MatchType` | `statelessConvert(Tuple tuple)`
    `boolean` | `statelessFilter(Tuple tuple)` Override this method to provide a lightweight, stateless filter on the tuples
    `void` | `update(Direction direction, Tuple updateElement)` updates the receiver with a newly found or lost partial matching

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.misc.SimpleReceiver

      `appendParent, assignTraceInfo, disconnectFromNetwork, getParents, removeParent`

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.network.BaseNode

      `acceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTag, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.incquery.runtime.rete.network.Node

      `acceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTag`

- - ### Field Detail

    - #### matchFoundEvents

          public java.util.Collection<MatchType> matchFoundEvents

      matches that are newly found

    - #### matchLostEvents

          public java.util.Collection<MatchType> matchLostEvents

      matches that are newly lost

  - ### Constructor Detail

    - #### DeltaMonitor

          public DeltaMonitor(ReteContainer reteContainer)

      Parameters:
        `reteContainer` -

  - ### Method Detail

    - #### statelessFilter

          public boolean statelessFilter(Tuple tuple)

      Override this method to provide a lightweight, stateless filter on the tuples
      Parameters:
        `tuple` - the occurrence that is to be filtered
      Returns:
        true if this tuple should be monitored, false if ignored

    - #### statelessConvert

          public abstract MatchType statelessConvert(Tuple tuple)

    - #### update

          public void update(Direction direction,
                             Tuple updateElement)

      Description copied from interface: `Receiver`
      updates the receiver with a newly found or lost partial matching
      Specified by:
        `update` in interface `Receiver`

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clear all partial matchings stored in memory
      Specified by:
        `clear` in interface `Clearable`