1 // vim: set noexpandtab tabstop=4 shiftwidth=4:
2 //----------------------------------------------------------------------------
4 //----------------------------------------------------------------------------
5 // This file is part of PlaQui.
7 // PlaQui is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the Free Software
9 // Foundation; either version 2 of the License, or (at your option) any later
12 // PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 // You should have received a copy of the GNU General Public License along
18 // with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple
19 // Place, Suite 330, Boston, MA 02111-1307 USA
20 //----------------------------------------------------------------------------
21 // Creado: Sat Oct 18 18:18:36 2003
22 // Autores: Leandro Lucarella <llucare@fi.uba.ar>
23 //----------------------------------------------------------------------------
28 #ifndef PLAQUI_SERVER_H
29 #define PLAQUI_SERVER_H
31 #include "plaqui/server/tcpserver.h"
32 #include "plaqui/server/controlserver.h"
33 #include "plaqui/server/transmitter.h"
34 #include "plaqui/server/plant.h"
35 #include "plaqui/server/command.h"
36 #include <socket++/sockinet.h>
45 * Servidor de plantas químicas.
46 * Maneja múltiples conexiones, de control o de transmisión.
48 class Server: public TCPServer {
54 /// Lista de plantas químicas.
55 typedef std::map<std::string, Plant*> PlantList;
61 // Plantas disponibles en el servidor.
64 /// Mutex para las plantas.
65 Glib::Mutex plants_mutex;
72 * Obtiene una nueva \ref Connection "conexión".
74 * \param sd Descriptor del socket de la nueva conexión.
76 * \return Nueva conexión.
78 virtual Connection* new_connection(const sockbuf::sockdesc& sd);
81 * Maneja el comando server/status.
83 HTTPResponse* cmd_server_status(void) const;
86 * Maneja el comando connection/list.
88 HTTPResponse* cmd_connection_list(void);
91 * Maneja el comando connection/stop.
93 HTTPResponse* cmd_connection_stop(const Command& command);
96 * Maneja el comando transmission/list.
98 HTTPResponse* cmd_transmission_list(void);
101 * Maneja el comando transmission/start.
103 HTTPResponse* cmd_transmission_start(const Command& command);
106 * Maneja el comando transmission/stop.
108 HTTPResponse* cmd_transmission_stop(const Command& command);
111 * Maneja el comando plant/list.
113 HTTPResponse* cmd_plant_list(void);
116 * Maneja el comando plant/get.
118 HTTPResponse* cmd_plant_get(const Command& command);
121 * Maneja el comando plant/get.
123 HTTPResponse* cmd_plant_set(const Command& command);
126 * Maneja el comando plant/stop.
128 HTTPResponse* cmd_plant_stop(const Command& command);
135 virtual ~Server(void);
140 * \param port Puerto en el cual escuchar.
142 Server(const std::string& plant_filename,
143 const Connection::Port& port = 7522);
146 * Maneja los comandos recibidos por las conexiones.
148 void on_control_command_received(const Command& command,
149 ControlServer* controlserver);
152 * Se encarga de borrar una planta de la lista cuando finaliza.
154 * \param connection Conexión a eliminar.
156 void on_plant_finished(const char* plant);
159 * Envia el estado de una planta cuando esta se actualiza.
161 * \param plant Planta actualizada.
163 void on_plant_updated(const Plant* const);
171 #endif // PLAQUI_SERVER_H