def __init__(self, parent=None, tests=None): ''' Constructor ''' Node.__init__(self, rightParent=parent) HasMemory.__init__(self, None) HasTests.__init__(self, tests)
def delete(self, notifierRemoval=None, notifierUnlinking=None): """ Remove the alpha-memory from the network """ # before to call the Node.delete, # references to this alpha-memory # have to be removed # from all wme object # but wme.delete() # isn't called because a-memory # delete doens't mean fact retract for wme in self.items: wme.unlinkAlphaMemory(self) # before call the Node.delete, # manually remove the parent's reference # to this node (because alpha memory is in # parent.memory slot, not in children if not self.isRightRoot(): if callable(notifierUnlinking): notifierUnlinking(self.rightParent, self) self.rightParent.memory = None if self.rightParent.isLeaf(): self.rightParent.delete(notifierRemoval, notifierUnlinking) self.rightParent = None Node.delete(self, notifierRemoval, notifierUnlinking)
def __init__(self, leftParent, rightParent, partnerCircuitLength): ''' Create the new ncc node ''' Node.__init__(self, rightParent=None, leftParent=leftParent) Memory.__init__(self) self._partner = NccPartnerNode(rightParent, partnerCircuitLength, self)
def __init__(self, leftParent, circuitLenght, nccNode): ''' Build a new NccPartner ''' Node.__init__(self, leftParent=leftParent) self._circuitLength = circuitLenght self._nccNode = nccNode self._buffer = []
def delete(self, notifierRemoval=None, notifierUnlinking=None): if self.isMain: for linkedNode in self._linkedPNodes: linkedNode.delete(notifierRemoval, notifierUnlinking) self._linkedPNodes = [] Memory.delete(self) Node.delete(self, notifierRemoval, notifierUnlinking)
def delete(self, notifierRemoval=None, notifierUnlinking=None): """ Remove the beta-memory from the network """ # first delete all tokens Memory.delete(self) # then i can call parent destructor Node.delete(self, notifierRemoval, notifierUnlinking)
def delete(self, notifierRemoval=None, notifierUnlinking=None): """ Remove this node and the partner from the network """ # notify unlink between ncc and partner #EventManager.trigger(EventManager.E_NODE_UNLINKED, self.get_partner(), self) # then destroy the partner self.partner.delete(notifierRemoval, notifierUnlinking) # and last destroy this node itself Memory.delete(self) Node.delete(self, notifierRemoval, notifierUnlinking)
def delete(self, notifierRemoval=None, notifierUnlinking=None): """ Delete all token in the results buffer and then remove the node from the network. """ while len(self._buffer) > 0: # i use the pop: # token doesn't have # link to results buffer # so i must force the ref removal # from it self._buffer.pop().delete() Node.delete(self, notifierRemoval, notifierUnlinking)
def __init__(self, ruleName, leftParent, network, orClauseCount=None, rhs=None, properties=None, moduleName=None, variables=None): ''' Constructor ''' self._ruleName = ruleName + (("~"+str(orClauseCount)) if orClauseCount is not None else "") self._isMain = (orClauseCount is None) self._network = network self._rhs = rhs self._linkedPNodes = [] self._properties = {"salience": 0, "auto-focus": False} if properties is None or not isinstance(properties, dict) else properties self._moduleName = moduleName if moduleName is not None else network.modulesManager.currentScope.moduleName self._variables = variables if isinstance(variables, dict) else {} Node.__init__(self, leftParent=leftParent) Memory.__init__(self)
def __init__(self, parent=None): ''' Constructor ''' Node.__init__(self, rightParent=parent, leftParent=None) Memory.__init__(self)
def isLeaf(self): return not self.hasMemory() and Node.isLeaf(self)
def __init__(self, rightParent=None, leftParent=None, tests=None): ''' Constructor ''' Node.__init__(self, rightParent, leftParent) HasJoinTests.__init__(self, tests)
def __init__(self, leftParent=None, tests=None): ''' Constructor ''' Node.__init__(self, leftParent=leftParent) HasJoinTests.__init__(self, tests)
def __init__(self, network): ''' Constructor ''' Node.__init__(self) self._network = network