Пример #1
0
PRUlayer::PRUlayer(xmlpp::TextReader &reader) {
  if (reader.has_attributes()) {
    reader.move_to_first_attribute();
    do {
      if (reader.get_name() == "id")
	name = reader.get_value();
    } while (reader.move_to_next_attribute());
    reader.move_to_element();
  }
  while(reader.read()) {
    string name = reader.get_name();
    if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
	(name == "Layer"))
      break;
    if (reader.get_node_type() != xmlpp::TextReader::Element )
      continue;
    if (name == "StateVariable") {
      if (reader.has_attributes()) {
	reader.move_to_first_attribute();
	do {
	  if (reader.get_name() == "id")
	    stateVariables.push_back(reader.get_value());
	} while (reader.move_to_next_attribute());
	reader.move_to_element();
      }
    } else if (name == "Action") {
      modules.push_back(new PRUmodule(reader));
    } else
      std::cerr << "Unexpected tag " << name << "!" << std::endl;
  } // while reader.read()
} // PRUlayer(reader)
Пример #2
0
/*----------------------------------------------------------------------------*/
void readElement(xmlpp::TextReader& reader,string elem)
{
	do
	{
		reader.read();
	}while(elem!=reader.get_name());
}
Пример #3
0
/*----------------------------------------------------------------------------*/
void XmlParser::buscarElemento(xmlpp::TextReader& reader)
{
	int nodeType = (int)reader.get_node_type();
		   
	//Busca un nodo tipo Elemento.
	while(nodeType!=1 && nodeType!=0)
	{
		reader.read();
		nodeType = (int)reader.get_node_type();
	}
}
Пример #4
0
inline void read_skip_comment(xmlpp::TextReader &reader)
{
    const int line = xml_line(reader.get_current_node());

    do
    {
        if(!reader.read())
            throw xml_eof(line);
    }
    while(reader.get_node_type() == xmlpp::TextReader::Comment);
}
Пример #5
0
/*----------------------------------------------------------------------------*/
void XmlParser::cargarMundo(Mundo* mundo,xmlpp::TextReader& reader)
{
	do
    {   	
		buscarElemento(reader);
		string path = reader.get_attribute(ATRIB_PATH);
		if(path!="")
		{
			mundo->getNiveles()->push(path);
		}	
    }while(reader.read());
}
Пример #6
0
/*----------------------------------------------------------------------------*/
void XmlParser::cargarGrafo(Mapa* mapa,xmlpp::TextReader& reader)
{
	std::string name="";
	do
    {
		buscarElemento(reader);
		name = reader.get_name();
		if(name==ARISTA)
			agregarArista(mapa,reader);
        
    }while(reader.read() && name!=ELEMENTOS);
}
Пример #7
0
PRUmodule::PRUmodule(xmlpp::TextReader &reader) {
  if (reader.has_attributes()) {
    reader.move_to_first_attribute();
    do {
      if (reader.get_name() == "id")
	actionName = reader.get_value();
    } while (reader.move_to_next_attribute());
    reader.move_to_element();
  }
  while(reader.read()) {
    string name = reader.get_name();
    if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
	(name == "Action"))
      break;
    if (reader.get_node_type() != xmlpp::TextReader::Element )
      continue;
    if (name == "Parameter") {
      string pName = "";
      string pDom = "";
      if (reader.has_attributes()) {
	reader.move_to_first_attribute();
	do {
	  if (reader.get_name() == "id")
	    pName = reader.get_value();
	  else if (reader.get_name() == "domain")
	    pDom = reader.get_value();
	} while (reader.move_to_next_attribute());
	reader.move_to_element();
      }
      if (pName == "")
	throw "Parameter with no name!";
      domain_type dom;
      if (pDom != "") {
	if (PRUplus::actionsDomain[pDom].empty())
	  std::cerr << "Empty action domain: " << pDom << std::endl;
	else for (domain_type::const_iterator it=PRUplus::actionsDomain[pDom].begin(); 
	     it!=PRUplus::actionsDomain[pDom].end(); ++it){
	  dom.insert(*it);
	}
      }
      if (reader.has_value())
	dom.insert(reader.get_value());
      else
	readVector(dom,reader);
      parameters[pName] = dom;
      domains[pName] = pDom;
    } else if (name == "Outcome") {
      outcomes.push_back(new PRUoutcome(reader));
    } else
      std::cerr << "Unexpected tag " << name << "!" << std::endl;
  } // while reader.read()
} // PRUmodule(reader)
Пример #8
0
/*----------------------------------------------------------------------------*/
void XmlParser::agregarElementos(Mapa* mapa,xmlpp::TextReader& reader)
{
	do
    {   
		string tipoElemento = reader.get_attribute(ATRIB_TIPO);
		if(tipoElemento==POWER_UP)
			agregarPowerUp(mapa,reader);
		if(tipoElemento==BONUS)
			agregarBonus(mapa,reader);
		if(tipoElemento==CASA_FANTASMAS)
			agregarCasaFantasmas(mapa,reader);
		if(tipoElemento==SALIDA_PACMAN)
			agregarSalidaPacMan(mapa,reader);
				
    }while(reader.read());
	
	//Se agregan las pantillas al mapa
	agregarPastillas(mapa);
}
Пример #9
0
void PRUplus::readXML(xmlpp::TextReader &reader) {
  while(reader.read()) {
    string name = reader.get_name();
    if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
	(name == "pru"))
      break;
    if (reader.get_node_type() != xmlpp::TextReader::Element )
      continue;
    if (name == "pru") {
    } else if (name == "Start") {
    } else if (name == "SVU")
      readVector(stateVariablesInitialAssignments, reader);
    else if (name == "Next")
      readVector(firstEnabledModules, reader, "\n ");
    else if (name == "Layer")
      layers.push_back(new PRUlayer(reader));
    else if (name == "Constraint")
      constraints.push_back(new PRUconstraint(reader));
    else
      std::cerr << "Unexpected tag " << name << "!" << std::endl;
  } // while reader.read()
} // PRUplus(reader)
Пример #10
0
PRUoutcome::PRUoutcome(xmlpp::TextReader &reader) {
  initDefaultValues();
  if (reader.has_attributes()) {
    reader.move_to_first_attribute();
    do {
      if (reader.get_name() == "id")
	name = reader.get_value();
      else if (reader.get_name() == "p")
	probability = atof(reader.get_value().c_str());
    } while (reader.move_to_next_attribute());
    reader.move_to_element();
  }
  while(reader.read()) {
    string name = reader.get_name();
    if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
	(name == "Outcome"))
      break;
    if (reader.get_node_type() != xmlpp::TextReader::Element )
      continue;
    if (name == "Quality") {
      if (reader.has_attributes()) {
	reader.move_to_first_attribute();
	do {
	  if (reader.get_name() == "kind")
	    quality = reader.get_value();
	  else if (reader.get_name() == "param")
	    qualityParameter = atof(reader.get_value().c_str());
	  else if (reader.get_name() == "const")
	    qualityConstant = atof(reader.get_value().c_str());
	} while (reader.move_to_next_attribute());
	reader.move_to_element();
      }
    } else if (name == "Duration") {
      if (reader.has_attributes()) {
	reader.move_to_first_attribute();
	do {
	  if (reader.get_name() == "kind")
	    duration = reader.get_value();
	  else if (reader.get_name() == "param")
	    durationParameter = atof(reader.get_value().c_str());
	  else if (reader.get_name() == "const")
	    durationConstant = atof(reader.get_value().c_str());
	} while (reader.move_to_next_attribute());
	reader.move_to_element();
      }
    } else if (name == "Observe") {
      if (reader.has_value())
	observable = reader.get_value();
      else
	observable = reader.read_string();
    } else if (name == "SVU") {
      readVector(stateVariableUpdate,reader);
    } else if (name == "Final") {
      isFinal = true;
      if (reader.has_attributes()) {
	reader.move_to_first_attribute();
	do {
	  if (reader.get_name() == "label")
	    finalLabel = reader.get_value();
	} while (reader.move_to_next_attribute());
	reader.move_to_element();
      }
    } else if (name == "Next")
      readVector(nextModules,reader,"\n ");
    else
      std::cerr << "Unexpected tag " << name << "!" << std::endl;
  } // while reader.read()
} // PRUoutcome(reader)