xmlDocPtr document;
document = xmlParseFile(filename.c_str());
if (document == NULL) {
+ is_load_ok = false;
return;
}
+ is_load_ok = true;
+
/* bien, el archivo se parseo bien! */
xmlNodePtr nodo, items;
nodo = document->children;
// Bien, la planta esta cargada, conectemos todo!!
do_connections(nodo->children);
}
+ xmlFreeDoc(document);
}
Simulator::~Simulator()
{
- // FIXME REMOVER TODOOOOOO
+ std::list<PlantItem *>::iterator i = items.begin();
+ PlantItem *o;
+
+ while (i != items.end()) {
+ o = (*i);
+ items.remove(o);
+ delete o;
+ i = items.begin();
+ }
}
void Simulator::add_pump(const std::string &name, float max_flow, RGB color)
{
Pump *p = new Pump(name);
- // FIXME no va!!
p->set_max_flow(max_flow);
p->set_color(color);
pump_lst.push_back(p);
void Simulator::add_union(const std::string &name, float max_flow)
{
Union *u = new Union(name);
- // FIXME no va!!
u->set_max_flow(max_flow);
union_lst.push_back(u);
items.push_back(u);
void Simulator::add_conduct(const std::string &name, float flujo)
{
Conduct *p = new Conduct(name);
- // FIXME no va!!
p->set_max_flow(flujo);
conduct_lst.push_back(p);
items.push_back(p);
} else if (xmlStrcmp(nodo->name, BAD_CAST"entrega") == 0) {
flujo = atof( (char *)XML_GET_CONTENT(nodo->children) );
} else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) {
- // FIXME !
- color = RGB();
+ color = loadRGB(nodo->children);
}
}
nodo = nodo->next;
std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
int orientacion=0, x, y;
float capacidad, inicial;
- RGB color; // TODO
+ RGB color;
nodo = nodo->children;
while (nodo != NULL) {
capacidad = atoi( (char *)XML_GET_CONTENT(nodo->children) );
} else if (xmlStrcmp(nodo->name, BAD_CAST"inicial") == 0) {
inicial = atof( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"") == 0) {
+ color = loadRGB(nodo->children);
}
}
nodo = nodo->next;
return out.str();;
}
+RGB Simulator::loadRGB(xmlNodePtr nodo)
+{
+ unsigned r,g,b;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0)
+ r = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ if (xmlStrcmp(nodo->name, BAD_CAST"verde")==0)
+ g = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ if (xmlStrcmp(nodo->name, BAD_CAST"azul")==0)
+ b = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ nodo = nodo->next;
+ }
+ return RGB(r,g,b);
+}
+