Beispiel #1
0
 def right_activation(self, wme):
     """
     :type wme: rete.WME
     """
     for t in self.items:
         if self.perform_join_test(t, wme):
             if not t.join_results:
                 Token.delete_token_and_descendents(t)
             jr = NegativeJoinResult(t, wme)
             t.join_results.append(jr)
             wme.negative_join_result.append(jr)
Beispiel #2
0
    def delete_node_and_any_unused_ancestors(cls, node):
        """
		:type node: BetaNode
		"""
        if isinstance(node, JoinNode):
            node.amem.successors.remove(node)
        else:
            for item in node.items:
                Token.delete_token_and_descendents(item)
        node.parent.children.remove(node)
        if not node.parent.children:
            cls.delete_node_and_any_unused_ancestors(node.parent)
Beispiel #3
0
 def remove_wme(cls, wme):
     """
     :type wme: WME
     """
     for am in wme.amems:
         am.items.remove(wme)
     for t in wme.tokens:
         Token.delete_token_and_descendents(t)
     for jr in wme.negative_join_result:
         jr.owner.join_results.remove(jr)
         if not jr.owner.join_results:
             for child in jr.owner.node.children:
                 child.left_activation(jr.owner, None)
Beispiel #4
0
 def left_activation(self, t, w, binding=None):
     """
     :type w: rete.WME
     :type t: rete.Token
     :type binding: dict
     """
     new_result = Token(t, w, self, binding)
     owners_t = t
     owners_w = w
     for i in range(self.number_of_conditions):
         owners_w = owners_t.wme
         owners_t = owners_t.parent
     for token in self.ncc_node.items:
         if token.parent == owners_t and token.wme == owners_w:
             token.ncc_results.append(new_result)
             new_result.owner = token
             Token.delete_token_and_descendents(token)
     self.new_result_buffer.append(new_result)