4 using namespace PlaQui::Model;
10 Simulador::~Simulador()
12 // FIXME REMOVER TODOOOOOO
15 void Simulador::add_pump(const std::string &name)
17 Pump *p = new Pump(name);
20 pump_lst.push_back(p);
24 void Simulador::add_union(const std::string &name)
26 Union *u = new Union(name);
29 union_lst.push_back(u);
33 void Simulador::add_splitter(const std::string &name)
35 Splitter *p = new Splitter(name);
38 split_lst.push_back(p);
42 void Simulador::add_conduct(const std::string &name)
44 Conduct *p = new Conduct(name);
47 conduct_lst.push_back(p);
51 void Simulador::add_exclusa(const std::string &name)
53 Exclusa *p = new Exclusa(name);
55 exclusa_lst.push_back(p);
59 void Simulador::add_tank(const std::string &name)
61 Tank *p = new Tank(name);
65 tank_lst.push_back(p);
69 void Simulador::add_drainage(const std::string &name)
71 Drainage *p = new Drainage(name);
73 drainage_lst.push_back(p);
77 bool Simulador::connect(const std::string &name1, const std::string &name2, int flag)
83 if ((o1 == NULL) || (o2 == NULL)) {
84 // NO SE PUDO CONECTAR!, FALTAN ITEMS!!
89 if (flag == IConector::OUT) {
90 b = o1->connect(o2, IConector::OUT);
91 b = b && o2->connect(o1, IConector::IN);
93 b = o1->connect(o2, IConector::IN);
94 b = b && o2->connect(o1, IConector::OUT);
100 void Simulador::simulate()
103 std::list<Pump *>::iterator i1;
104 for(i1=pump_lst.begin(); i1!=pump_lst.end(); i1++)
108 std::list<PlantItem *>::iterator i2;
109 for(i2=items.begin(); i2!=items.end(); i2++)
113 IConector *Simulador::find(const std::string &name)
115 // Busco el item, aca no me importa de que tipo es!
116 std::list<PlantItem *>::iterator i;
117 for(i=items.begin(); i!=items.end(); i++)
118 if ((*i)->get_name() == name)
123 bool Simulador::pump_deactivate(const std::string &name)
125 // Busco el elemento, usando RTTI :-(
126 Pump *pump = dynamic_cast<Pump *>(find(name));
129 // Ups!, "name" no era un Pump!!!