Example #1
0
bool DAGraph::explore(int vertex, bool *visited){
	
	visited[vertex] = true;
	preVisit(vertex);
	std::list<StarLink*> &linksList = (nodes_[vertex])->outLinks;
	int index = -1;
	bool backEdgeDetected = false;
	StarLink* link = NULL;
	for(std::list<StarLink*>::iterator it = linksList.begin(); it != linksList.end(); ++it){
		link = *it;
		index = link->getNodeToIndex();
		if (checkPositiveFlow(link->getIndex())) {
			handleExploredLink(link);
			if ((nodes_[index])->pre == 0) {
				backEdgeDetected = explore(index, visited);
				if (backEdgeDetected) return true;
			}
			if ((nodes_[index])->pre > 0 && (nodes_[index])->post == 0) {
				return handleBackEdge(link);
			}
		} 
	}
	postVisit(vertex);
	return false;
};
Example #2
0
//this will match up file.smil#id lists to each NavPoint and PageTarget
//it will also index the text in the SMIL files (since it's parsing them already)
void amis::dtb::nav::ResolveSmilDataVisitor::resolve(amis::dtb::nav::NavModel* pModel, amis::dtb::Spine* pSpine, bool resolveNavNodeAudioData)
{
	if (pSpine == NULL)
		return;

	mpPreviousNavNode = NULL;
	//this is the map of NavNodes to smil ids (one id to many nodes)
	//an id in section 1.1 is in section 1.1 and not in section 1
	//an id in any section may also be referenced by a page node
	mpMap = new NodeRefMap;

	//a map of text ids and the smil files they occur in
	mpTextMap = new StringMap;

	unsigned int i = 0;
	//build a giant list of smil files and their element IDs
	for (int i = 0; i<pSpine->getNumberOfSmilFiles(); i++)
	{
		if (mThreadYielder != 0) mThreadYielder->peekAndPump();

		NavNodeList* p_nav_nodes = NULL;
		//find out which nav nodes refer to this smil file
		//then we'll send the list to the smil parser, and the nodes will
		//have their audio data filled in (this data isn't built into the NCC files)
		if (resolveNavNodeAudioData == true)
		{
			//who = which nav nodes
			WhoRefersToThisSmilFile who_visitor;
			p_nav_nodes = who_visitor.findOut(pModel, pSpine->getSmilFilePath(i));
		}
		const ambulant::net::url* smilfile = pSpine->getSmilFilePath(i);
		amis::io::QuickDataSmilFileReader quick_reader;
		//get all the ids and text src's from this smil file.  also fill in the audio data for the nav nodes.
		//big id list is a list of all SMIL element IDs
		//text map is a map of the smilfile name and the text src in it
		//p_nav_nodes is a list of pointers to nav nodes that refer to this smil file
		quick_reader.readFromFile(smilfile, &mBigIdList, mpTextMap, p_nav_nodes);

		//this deletes a pointer to a list of pointers, not the nodes themselves
		if (p_nav_nodes != NULL)
			delete p_nav_nodes;
	}

	
	//first, resolve the node-smil ranges for the nav map
	if (pModel->getNavMap() != NULL)
	{
		mpPreviousNavNode = NULL;
		pModel->getNavMap()->acceptDepthFirst(this);
		//grab data for the last one
		preVisit(NULL);
	}
	
	//then, resolve the node-smil ranges for the page list
	if (pModel->hasPages())
	{
		mpPreviousNavNode = NULL;
		pModel->getPageList()->acceptDepthFirst(this);
		//grab data for the last one
		preVisit(NULL);
	}
	//then, resolve for the nav lists
	for (i = 0; i<pModel->getNumberOfNavLists(); i++)
	{
		mpPreviousNavNode = NULL;
		pModel->getNavList(i)->acceptDepthFirst(this);
		//ranges aren't yet supported for nav targets, so there's no need to call preVisit(NULL)
	}

	pModel->setSmilIdNodeMap(mpMap);
	
}