#include "sistemaautonomo.h"\r
#include "slBrevePluginAPI.h"\r
+\r
+#ifdef DEBUG\r
#include <iostream>\r
+#endif // DEBUG\r
\r
/////////////////////////// CTeoria /////////////////////////\r
\r
-double NoOp(CEntorno&) { return 0.0; } // FIXME (hack horrible porque no puedo usar ptr a fun)\r
-\r
-// pointer{Teoria} TeoriaNew(string, int, int, int)\r
+// pointer{Teoria} TeoriaNew(string, string, int, int)\r
int SAbrTeoriaNew(brEval args[], brEval* result, void* data)\r
{\r
result->set(new CTeoria(\r
BRSTRING(args),\r
- NoOp, // FIXME (no hay puntero a funcion, poner BRINT(args+1))\r
+ BRSTRING(args+1),\r
BRINT(args+2),\r
BRINT(args+3)));\r
return EC_OK;\r
}\r
\r
-// void TeoriaAddDatoInicial(pointer{Teoria}, string, double)\r
-int SAbrTeoriaAddDatoInicial(brEval args[], brEval* result, void* data)\r
+// void TeoriaSetDatoInicial(pointer{Teoria}, string, float)\r
+int SAbrTeoriaSetDatoInicial(brEval args[], brEval* result, void* data)\r
{\r
CTeoria* t = (CTeoria*) BRPOINTER(args);\r
- t->datos_iniciales.add(BRSTRING(args+1), BRINT(args+2));\r
+ t->datos_iniciales.set_val(BRSTRING(args+1), BRDOUBLE(args+2));\r
return EC_OK;\r
}\r
\r
-// void TeoriaAddDatoFinal(pointer{Teoria}, string, double)\r
-int SAbrTeoriaAddDatoFinal(brEval args[], brEval* result, void* data)\r
+// void TeoriaSetDatoFinal(pointer{Teoria}, string, float)\r
+int SAbrTeoriaSetDatoFinal(brEval args[], brEval* result, void* data)\r
{\r
CTeoria* t = (CTeoria*) BRPOINTER(args);\r
- t->datos_finales.add(BRSTRING(args+1), BRINT(args+2));\r
+ t->datos_finales.set_val(BRSTRING(args+1), BRDOUBLE(args+2));\r
return EC_OK;\r
}\r
\r
-// void TeoriaDelete(pointer{Teoria})\r
-int SAbrTeoriaDelete(brEval args[], brEval* result, void* data)\r
+// string TeoriaGetNombre(pointer{Teoria})\r
+int SAbrTeoriaGetNombre(brEval args[], brEval* result, void* data)\r
{\r
- delete (CTeoria*) BRPOINTER(args);\r
+ CTeoria* t = (CTeoria*) BRPOINTER(args);\r
+ result->set(t->nombre.c_str());\r
+ return EC_OK;\r
+}\r
+\r
+// string TeoriaGetAccion(pointer{Teoria})\r
+int SAbrTeoriaGetAccion(brEval args[], brEval* result, void* data)\r
+{\r
+ CTeoria* t = (CTeoria*) BRPOINTER(args);\r
+ result->set(t->funcion.c_str());\r
return EC_OK;\r
}\r
\r
{\r
CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
CTeoria* t = (CTeoria*) BRPOINTER(args+1);\r
- sa->teorias.add(t->nombre.c_str(), *t);\r
+ sa->teorias.add(t->nombre, t);\r
+#ifdef DEBUG\r
+ std::cout << "Agrega teoria " << t->nombre << ":\n";\r
+ std::cout << " .datos_iniciales:\n" << t->datos_iniciales << "\n";\r
+ std::cout << " .datos_finales:\n" << t->datos_finales << "\n";\r
+#endif // DEBUG\r
+ return EC_OK;\r
+}\r
+\r
+// void SistemaAutonomoSetValue(pointer{SistemaAutonomo}, string, float)\r
+int SAbrSistemaAutonomoSetValue(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ sa->p_entorno->datos.set_val(BRSTRING(args+1), BRDOUBLE(args+2));\r
+ return EC_OK;\r
+}\r
+\r
+// void SistemaAutonomoSetDatoFinal(pointer{SistemaAutonomo}, string, float)\r
+int SAbrSistemaAutonomoSetDatoFinal(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ sa->m_datos_finales.set_val(BRSTRING(args+1), BRDOUBLE(args+2));\r
+ return EC_OK;\r
+}\r
+\r
+// void SistemaAutonomoPlan(pointer{SistemaAutonomo})\r
+int SAbrSistemaAutonomoPlan(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ sa->plan();\r
+ return EC_OK;\r
+}\r
+\r
+// bool SistemaAutonomoHasNextTheory(pointer{SistemaAutonomo})\r
+int SAbrSistemaAutonomoHasNextTheory(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ result->set(sa->has_next_theory());\r
+ return EC_OK;\r
+}\r
+\r
+// pointer{Teoria} SistemaAutonomoGetNextTheory(pointer{SistemaAutonomo})\r
+int SAbrSistemaAutonomoGetNextTheory(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ result->set(sa->get_next_theory());\r
+ return EC_OK;\r
+}\r
+\r
+// bool SistemaAutonomoValidateTheory(pointer{SistemaAutonomo}, pointer{Teoria})\r
+int SAbrSistemaAutonomoValidateTheory(brEval args[], brEval* result, void* data)\r
+{\r
+ CSistemaAutonomo* sa = (CSistemaAutonomo*) BRPOINTER(args);\r
+ result->set(sa->validate_theory((CTeoria*) BRPOINTER(args+1)));\r
return EC_OK;\r
}\r
\r
DLLEXPORT void SAbrFunctions(void *data)\r
{\r
brNewBreveCall(data, "TeoriaNew", SAbrTeoriaNew,\r
- AT_POINTER, AT_STRING, AT_INT, AT_INT, AT_INT, 0);\r
- brNewBreveCall(data, "TeoriaAddDatoInicial", SAbrTeoriaAddDatoInicial,\r
+ AT_POINTER, AT_STRING, AT_STRING, AT_INT, AT_INT, 0);\r
+ brNewBreveCall(data, "TeoriaSetDatoInicial", SAbrTeoriaSetDatoInicial,\r
AT_NULL, AT_POINTER, AT_STRING, AT_DOUBLE, 0);\r
- brNewBreveCall(data, "TeoriaAddDatoFinal", SAbrTeoriaAddDatoFinal,\r
+ brNewBreveCall(data, "TeoriaSetDatoFinal", SAbrTeoriaSetDatoFinal,\r
AT_NULL, AT_POINTER, AT_STRING, AT_DOUBLE, 0);\r
- brNewBreveCall(data, "TeoriaDelete", SAbrTeoriaDelete,\r
- AT_NULL, AT_POINTER, 0);\r
+ brNewBreveCall(data, "TeoriaGetNombre", SAbrTeoriaGetNombre,\r
+ AT_STRING, AT_POINTER, 0);\r
+ brNewBreveCall(data, "TeoriaGetAccion", SAbrTeoriaGetAccion,\r
+ AT_STRING, AT_POINTER, 0);\r
brNewBreveCall(data, "SistemaAutonomoNew", SAbrSistemaAutonomoNew,\r
AT_POINTER, 0);\r
brNewBreveCall(data, "SistemaAutonomoAddTeoria", SAbrSistemaAutonomoAddTeoria,\r
AT_NULL, AT_POINTER, AT_POINTER, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoSetValue", SAbrSistemaAutonomoSetValue,\r
+ AT_NULL, AT_POINTER, AT_STRING, AT_DOUBLE, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoSetDatoFinal", SAbrSistemaAutonomoSetDatoFinal,\r
+ AT_NULL, AT_POINTER, AT_STRING, AT_DOUBLE, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoPlan", SAbrSistemaAutonomoPlan,\r
+ AT_NULL, AT_POINTER, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoHasNextTheory", SAbrSistemaAutonomoHasNextTheory,\r
+ AT_INT, AT_POINTER, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoGetNextTheory", SAbrSistemaAutonomoGetNextTheory,\r
+ AT_POINTER, AT_POINTER, 0);\r
+ brNewBreveCall(data, "SistemaAutonomoValidateTheory", SAbrSistemaAutonomoValidateTheory,\r
+ AT_INT, AT_POINTER, AT_POINTER, 0);\r
brNewBreveCall(data, "SistemaAutonomoDelete", SAbrSistemaAutonomoDelete,\r
AT_NULL, AT_POINTER, 0);\r
}\r