From 98871795be266e4ea8b4662737ac618ebee0fb79 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 20 Oct 2003 02:59:28 +0000 Subject: [PATCH] - Agrego los primeros archivos pertenecientes al modelo. Nada funcional ni clarificados aun. - Sigo actualizando el diagrama de clases --- Model/include/elementoplanta.h | 46 ++++++++++++++++++++ Model/include/iconector.h | 74 +++++++++++++++++++++++++++++++++ Model/include/rgb.h | 35 ++++++++++++++++ Model/src/elementoplanta.cpp | 26 ++++++++++++ Model/src/iconector.cpp | 70 +++++++++++++++++++++++++++++++ docs/clases.dia | Bin 4655 -> 4659 bytes 6 files changed, 251 insertions(+) create mode 100644 Model/include/elementoplanta.h create mode 100644 Model/include/iconector.h create mode 100644 Model/include/rgb.h create mode 100644 Model/src/elementoplanta.cpp create mode 100644 Model/src/iconector.cpp diff --git a/Model/include/elementoplanta.h b/Model/include/elementoplanta.h new file mode 100644 index 0000000..502c265 --- /dev/null +++ b/Model/include/elementoplanta.h @@ -0,0 +1,46 @@ + + +#ifndef _ELEMENTO_PLANTA_H_ +#define _ELEMENTO_PLANTA_H_ + +#include "iconector.h" +#include "rgb.h" + +namespace PlaQui { + +class ElementoPlanta:public IConector { +public: + /// Constructor + ElementoPlanta(); + virtual ~ElementoPlanta(); + + // FIXME: ver que parametros seran necesarios + virtual void send_fluid() {} + virtual void receive_fluid() {} + + /// Hace que los elementos de la plata actualicen su flujo en esta etapa + virtual void update() = 0; + /// Hace la simulación de esta iteración + virtual void simulate() = 0; + + /// Setea el nuevo color del fluido + void setColor(const RGB &c) { fluid_color = c; } + /// Retorna el actual color del fluido + const RGB &getColor() { return fluid_color; } + + /// Recibe un mensage + virtual void recieve_msg(int msg, IConector *who); + + /// Mensages manejados por los elementos de la planta + enum { + MSG_QUERY_MAX_FLOW = IConector::MSG_LAST, ///< pregunta por el maximo flujo + MSG_LAST + }; +protected: + RGB fluid_color; +}; + +} + +#endif + diff --git a/Model/include/iconector.h b/Model/include/iconector.h new file mode 100644 index 0000000..bbb3c25 --- /dev/null +++ b/Model/include/iconector.h @@ -0,0 +1,74 @@ + + +#ifndef _I_CONECTOR_H_ +#define _I_CONECTOR_H_ + +#include + +namespace PlaQui { + +/** Conector genérico de elementos + */ +class IConector { +public: + /// Constructor + IConector(); + /// Destructor + virtual ~IConector(); + + /** Envía un mensage a los elementos conectados + * + * Esvía un mensage a los elementos conectados a la entrada o + * a la salida. + * \param where Donde enviar el mensage, IConector::IN o IConector::OUT + * \param msg Mensage a enviar + * \return Respuesta al mensage. Se interpreta dependiendo del mensage + */ + int send_msg(int where, int msg); + + /// Recive un mensage + virtual void recieve_msg(int msg, IConector *who); + + /** Conecta un objeto con otro + * + * \param place IConector::IN o IConecor::OUT para conectar a la entrada o salida. + * \param obj Objeto a conectar + * \return true si se pudo conectar + */ + bool connect(IConector *obj, int place); + + /// Constantes de posición donde conectar + enum { + IN, ///< conectar a la entrada + OUT ///< conectar a la salida + }; + + /** Mensages a este nivel + * + * Las clases descendientes que quieran definir sus mensajes deben utilizar + * el valor de IConector::MSG_LAST como valor para el primer msg, a fin + * de evitar solapamiento de mensajes. + * Por ejemplo, si tenemos una clase B con un mensaje TEST se declararía + * como : + * \verbatim + * class B:public IConector { + * enum { + * MSG_TEST=IConector::MSG_LAST, + * MSG_LAST + * }; + * \endverbatim + */ + enum { + MSG_DISCONECT=0, ///< Desconectar el objeto que envía el mensaje + MSG_LAST + }; +protected: + std::list entradas; + std::list salidas; + unsigned int cant_entradas; + unsigned int cant_salidas; +}; + +} + +#endif // _I_CONECTOR_H_ diff --git a/Model/include/rgb.h b/Model/include/rgb.h new file mode 100644 index 0000000..4a851e0 --- /dev/null +++ b/Model/include/rgb.h @@ -0,0 +1,35 @@ + + +#ifndef _RGB_H_ +#define _RGB_H_ + +typedef unsigned char color; + +/** Representación de un color en codificación RGB */ +class RGB { +public: + RGB() { my_r=my_g=my_b=0; } + RGB(color _r, color _g, color _b) { + my_r = _r; + my_g = _g; + my_b = _b; + } + + RGB &operator = (const RGB &c) { + if (this == &c) return (*this); + my_r = c.r(); + my_g = c.g(); + my_b = c.b(); + return (*this); + } + + color r() const { return my_r; } + color g() const { return my_g; } + color b() const { return my_b; } + +private: + color my_r, my_g, my_b; +}; + +#endif // _RGB_H_ + diff --git a/Model/src/elementoplanta.cpp b/Model/src/elementoplanta.cpp new file mode 100644 index 0000000..244ea6e --- /dev/null +++ b/Model/src/elementoplanta.cpp @@ -0,0 +1,26 @@ + + +#include "elementoplanta.h" + +using namespace PlaQui; + +ElementoPlanta::ElementoPlanta() +{ +} + +ElementoPlanta::~ElementoPlanta() +{ +} + +void ElementoPlanta::recieve_msg(int msg, IConector *who) +{ + switch (msg) { + case MSG_QUERY_MAX_FLOW: + /// TODO + return; + break; + default: + IConector::recieve_msg(msg, who); + } +} + diff --git a/Model/src/iconector.cpp b/Model/src/iconector.cpp new file mode 100644 index 0000000..778da63 --- /dev/null +++ b/Model/src/iconector.cpp @@ -0,0 +1,70 @@ + + +#include "iconector.h" + +using namespace PlaQui; + +IConector::IConector() +{ + cant_entradas = cant_salidas = 0; +} + +IConector::~IConector() +{ + // Limpio las listas. Los objetos no se destruyen!! + entradas.clear(); + salidas.clear(); +} + +int IConector::send_msg(int where, int msg) +{ + // Recorro toda la lista y envío el mensage a cada + // elemento conectado + std::list::iterator it; + switch (where) { + case IN: + for(it=entradas.begin(); it!=entradas.end(); it++) + (*it)->recieve_msg(msg, this); + break; + case OUT: + for(it=salidas.begin(); it!=salidas.end(); it++) + (*it)->recieve_msg(msg, this); + } + + // TODO : ver el tema de los valores de retorno!! + return 0; +} + +void IConector::recieve_msg(int msg, IConector *who) +{ + // Manejo los mensages que yo conozco + switch (msg) { + case MSG_DISCONECT: + // FIXME: sacar el elemento who de la lista! + return; + } +} + +bool IConector::connect(IConector *obj, int place) +{ + switch (place) { + case IN: + if (entradas.size() <= cant_entradas) { + entradas.push_back(obj); + cant_entradas++; + } else { + return false; // no se pudo conectar! + } + case OUT: + if (salidas.size() <= cant_salidas) { + salidas.push_back(obj); + cant_salidas++; + } else { + return false; // no se pudo conectar! + } +} + + // se pudo conectar sin problemas + return true; +} + diff --git a/docs/clases.dia b/docs/clases.dia index 4ab224cdf9d926be1c85775a5e604a5dae33092e..afa02f86e531a0b1f431e8dd5fefa912106b36d9 100644 GIT binary patch literal 4659 zcmV-363p!%iwFP!000001MOXHbK5o&{+?gKb7%VD#(@dG^VFo1xG#4zxn8G9KXp19 zScGM!6ru1Xi90v$@MG2S?w&eD+Ngv%kUr%Z#lIct@JcpI#hY6vg^)Cnuji zeIm(a&I*x{BrZwLPyWM_gq^^klcSf{-yN}n)xTgxk;P|a!Htxy_=}@6w)kV2i876v zcPvCAGUFplUL1XOUi~>bdHK!BjrX>TTC+9Jwo+DWk;ibYxLogC+kKz>ySbFZm2~;? zt2ewTc=lC&+vb;pbSPFVTgGW4F5@hzKZ-?MXXxiR(;y?!AS2TtBhKe*krf$>i$>0w z5D8~#E$W;lIUg!3U$6weh+F!Y#4&Bx9xCQME(+16Op%pbLCB{#DlQs1aaz9 z_iW2J;(6E8y?$}`ofpm3lMdCdF5jisN$dQYuuGmb!hR5GB#w;caWn>A4-;qa`J!kP z{`H@4jOWH_!t(s+YE^(WA&y=g{mbn5Bp?EOd-FNhV*8Xm5*|Mf$Y6(*g3ivi2D2zw zx=i>+R^V2`+?nOT-^b5QV!A^m^MtSF3z4PUxqlBeD`D52{+ez3#8DD+!}YJ^1jHID zre)Fk$Eir+>4`DxRu0P@7t$Pdgu>(E**RPA5kkRuS3E6tB#sco&R{fKXjnqZ^*ZBu zKHpx*^~n?fF<1eyaItOfY7Y|31Yn$}EOi=tRxn z6>b#-Bk#2q$>mC9>x+1ya=VdtTgX*LzU;hL&cHUex7qs%s@`z)2dmv+;9W-EL`v*h zJWLXd{mM0nykW5#7)+0P=b8~ ztk29dzKHopj+Ty={>UwTAyUaU(8|%u4{PO}M!g*~+^EIbdp$<@n7H^K@wS-c4!;;U z+l=^Pl5)v1Jzvdl-~aUPms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