Esempio n. 1
0
Boolean FTT1pnode::go(void){
	FTT1pSubnode *sub=(FTT1pSubnode*)itsSubnodes->NthItem(currentNode);
	if(!sub){
		nodeErr(32);
	}
	Boolean returnVal=TRUE,advanceToNextNode=FALSE;

#ifdef Frank_GenuineMac
	TRY{
#endif
		if(!sub->run()){
			advanceToNextNode=TRUE;
			if(!sub->func){
				// the subnode has terminated voluntarily
				if(newPres){
					// the fat lady is singing!
					// ownership of newPres passes
					// to the driver and the distinguished
					// subnode is removed from the list.
					// Control passes to the driver.

					newPresDispose=FALSE;
					removeSubnode();
					returnVal=FALSE;
				}
				else{
					// the  distinguished relator is not a consequence
					// this can only be positively determined if the group
					// generated by the other relators is finite.  The node
					// is removed from this list.  Control passes to driver
					// if there are no nodes on the list.

					returnVal=removeSubnode();
				}
			}
		}
#ifdef Frank_GenuineMac
	}
	CATCH{
		if(gLastError==memFullErr){
			NO_PROPAGATE;
			
			// The subnode has run out of memory.  If no other subnodes
			// are suspended, then the subnode failed while using all
			// available memory.  In this case, the node is removed
			// and the the algorithm is compromised.  
			
			// If there are other active subnodes, then the subnode is
			// disposed and reinitialized and the list of subnodes
			// is updated.  This frees up memory for the remaining active
			// subnodes and gives the current subnode a chance to run
			// again at a future date and perhaps have better luck.
			
			long num=itsSubnodes->numItems;
			Boolean otherNodeSuspended=FALSE;
			for(long i=1;i<=num && !otherNodeSuspended; ++i){
				FTT1pSubnode *aSubnode;
				aSubnode=(FTT1pSubnode*)itsSubnodes->NthItem(i);
				if(i!=currentNode){
					otherNodeSuspended= aSubnode->func!=0;
				}
			}
			if(otherNodeSuspended){
				long distinguishedRel=sub->distinguishedRel;
				delete sub;sub=0;
				sub= new FTT1pSubnode(this,currentPres,distinguishedRel,timeLimit);
				itsSubnodes->SetItem(&sub,currentNode);
			}
			else{
				returnVal=removeSubnode();
			}
		}
	}
	ENDTRY;
#endif

	if(advanceToNextNode){
		++currentNode;
		if(currentNode>itsSubnodes->numItems) currentNode=1;
	}
	return returnVal;
}
Esempio n. 2
0
File: Node.cpp Progetto: Sudoka/D3
 void Node::removeSubnode(String name)
 {
     Node * node = &getSubnode(name);
     removeSubnode(node);
 }