MyXmlTreeItem* MyXmlTreeItem::createNewChildren() { MyXmlTreeItem *item = new MyXmlTreeItem(this); pushChildren(item); return item; }
DepthFirstStateAction::ResultE DepthFirstStateAction::traverseEnterLeave(void) { ResultE result = NewActionTypes::Continue; Int32 nodePass; // pass over current node UInt32 multiPasses; // requested passes over current node NodePtr pNode; StateRefCountStoreIt itStateRefCount; while((_nodeStack.empty() == false) && !(result & NewActionTypes::Quit)) { pNode = _nodeStack.back().getNode (); nodePass = _nodeStack.back().getPassCount (); itStateRefCount = _nodeStack.back().getStateRefCount(); if(itStateRefCount != _itActiveState) { #ifdef OSG_NEWACTION_STATISTICS getStatistics()->getElem(statStateRestores)->inc(); #endif /* OSG_NEWACTION_STATISTICS */ setState(itStateRefCount); // gained refs: active incRefCount(itStateRefCount); // lost refs: active decRefCount(_itActiveState); _itActiveState = itStateRefCount; } getChildrenList().setParentNode(pNode); if(nodePass > 0) { // positive pass -> enter node #ifdef OSG_NEWACTION_STATISTICS getStatistics()->getElem(statNodesEnter)->inc(); #endif /* OSG_NEWACTION_STATISTICS */ _stateClonedFlag = false; result = enterNode (pNode, static_cast<UInt32>(nodePass - 1)); multiPasses = getNumPasses( ); // only initial pass (nodePass == 1) can request multiPass. if((nodePass == 1) && (multiPasses > 1)) { // remove current node from stack _nodeStack.pop_back(); for(; multiPasses > 1; -- multiPasses) { // gained refs: addtional passs incRefCount(_itActiveState); _nodeStack.push_back( NodeStackEntry(pNode, _itActiveState, multiPasses)); } // readd current node - with negative pass -> leave _nodeStack.push_back( NodeStackEntry(pNode, _itActiveState, -nodePass)); } else { // change current node passCount to negative -> leave _nodeStack.back().setPassCount(-nodePass); } pushChildren(pNode, result); } else { // negative pass -> leave node #ifdef OSG_NEWACTION_STATISTICS getStatistics()->getElem(statNodesLeave)->inc(); #endif /* OSG_NEWACTION_STATISTICS */ _stateClonedFlag = true; result = leaveNode(pNode, static_cast<UInt32>(-nodePass - 1)); _nodeStack.pop_back(); // lost refs: current node decRefCount(_itActiveState); } } return result; }
DepthFirstStateAction::ResultE DepthFirstStateAction::traverseEnter(void) { ResultE result = NewActionTypes::Continue; NodePtr pNode; Int32 nodePass; // pass over current node UInt32 multiPasses; // requested passes over current node StateRefCountStoreIt itStateRefCount; // state for current node while((_nodeStack.empty() == false) && !(result & NewActionTypes::Quit)) { pNode = _nodeStack.back().getNode (); nodePass = _nodeStack.back().getPassCount (); itStateRefCount = _nodeStack.back().getStateRefCount(); #ifdef OSG_NEWACTION_STATISTICS getStatistics()->getElem(statNodesEnter)->inc(); #endif /* OSG_NEWACTION_STATISTICS */ if(itStateRefCount != _itActiveState) { #ifdef OSG_NEWACTION_STATISTICS getStatistics()->getElem(statStateRestores)->inc(); #endif /* OSG_NEWACTION_STATISTICS */ setState(itStateRefCount); // gained refs: active incRefCount(itStateRefCount); // lost refs: active decRefCount(_itActiveState); _itActiveState = itStateRefCount; } _stateClonedFlag = false; getChildrenList().setParentNode(pNode); result = enterNode (pNode, static_cast<UInt32>(nodePass - 1)); multiPasses = getNumPasses( ); _nodeStack.pop_back(); // only initial pass (nodePass == 1) can request multiPasses if((nodePass == 1) && (multiPasses > 1)) { for(; multiPasses > 1; --multiPasses) { // gained refs: additional pass incRefCount(_itActiveState); _nodeStack.push_back( NodeStackEntry(pNode, _itActiveState, multiPasses)); } } pushChildren(pNode, result); // lost refs: current node decRefCount(_itActiveState); } return result; }