org.eclipse.viatra.query.runtime.rete.misc

## Class DeltaMonitor<MatchType>

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

- All Implemented Interfaces:
    Clearable, Node, Receiver
  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.

- - ### 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

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.misc.SimpleReceiver

      `mailbox, parent`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.network.BaseNode

      `nodeId, reteContainer, tag, traceInfos`

  - ### 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, Timestamp timestamp)` Updates the receiver with a newly found or lost partial matching.

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

      `appendParent, assignTraceInfo, disconnectFromNetwork, getMailbox, getParents, instantiateMailbox, removeParent`

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

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

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

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

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.rete.network.Receiver

      `batchUpdate`

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

      `acceptPropagatedTraceInfo, getCommunicationTracker, 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,
                             Timestamp timestamp)

      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`