Example #1
0
void Player_AD::updateChannel(Channel *channel) {
	if (channel->state == kChannelStateParse) {
		parseSlot(channel);
	} else {
		updateSlot(channel);
	}
}
Example #2
0
Node* Parser::parseNode(const xmlDocPtr &_doc, xmlNodePtr _cur, std::map<std::string, std::string> *_map)
{ 
	EnumParser<nodeType> ep;
	std::string name = (const char*)parseAttribute(_cur, "name");
	std::string type = (const char*)parseAttribute(_cur, "type");
	std::string id = (const char*)parseAttribute(_cur, "id");
	nodeType t = ep.parseEnum(type.c_str());
	Node *temp;
	std::map<std::string, std::string> connectionMap;
	_cur = _cur->children;
	if(t == nodeType::GRAPH)
	{
		std::cout<<"node type is graph"<<'\n';
		Graph *temp2 = new Graph();
		temp2->setID(std::stoi(id));
		temp2->setName(name);
		while(_cur != NULL) {
			if( !xmlStrcmp(_cur->name, (const xmlChar *)NODEOUTPUT) ||
			    !xmlStrcmp(_cur->name, (const xmlChar *)NODEINPUT) )
			{
				if ( _map == NULL)
				{	
					temp2->add(parseSlot(temp2, _doc, _cur, &connectionMap));
				}
				else
				{
					temp2->add(parseSlot(temp2, _doc, _cur, _map));
				}

			}
			if(!xmlStrcmp(_cur->name, (const xmlChar *)NODE))
			{
				Node *n = parseNode(_doc, _cur, &connectionMap);
				temp2->addNode(n);
				std::cout<<"added node "<<n->getName()<<"address "<<n<<" ID "<<n->getID()<<'\n';
			}
			_cur = _cur->next;
		}
		if(connectionMap.begin() != connectionMap.end())
		{
			std::map <std::string, std::string>::const_iterator it;
			for(it = connectionMap.begin(); it != connectionMap.end(); it++)
			{
				std::cout<<"connection map "<<it->first<<"  "<<it->second<<'\n';
				makeConnection(temp2, it->first, it->second);
			}
		}
		temp = temp2;
	}
	else
	{
		temp = new Node();
		temp->setName(name);
		temp->setID(std::stoi(id));
		while(_cur != NULL) {
			if(!xmlStrcmp(_cur->name, (const xmlChar *)NODEOUTPUT) ||
			   !xmlStrcmp(_cur->name, (const xmlChar *)NODEINPUT) )
			{
		
				temp->add(parseSlot(temp, _doc, _cur, _map));
			}
			_cur = _cur->next;
		}
	}
	temp->setType(t);
	std::cout<<"parsing node "<<name<<"address "<<temp<<" ID "<<temp->getID()<<'\n';
	return temp;
}