]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Server/include/plaqui/server/command.h
Se mejora el codo (para que el color siga la curva).
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / command.h
1 // vim: set noexpandtab tabstop=4 shiftwidth=4:
2 //----------------------------------------------------------------------------
3 //                                  PlaQui
4 //----------------------------------------------------------------------------
5 // This file is part of PlaQui.
6 //
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
10 // version.
11 //
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
15 // details.
16 //
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:  sáb nov  8 17:02:44 ART 2003
22 // Autores: Leandro Lucarella <llucare@fi.uba.ar>
23 //----------------------------------------------------------------------------
24 //
25 // $Id$
26 //
27
28 #ifndef PLAQUI_COMMAND_H
29 #define PLAQUI_COMMAND_H
30
31 #include "httperror.h"
32 #include "httprequest.h"
33 #include <socket++/sockstream.h>
34 #include <string>
35 #include <vector>
36 #include <istream>
37 #include <ostream>
38
39 namespace PlaQui {
40
41 namespace Server {
42
43         /// Pedido HTTP.
44         class Command: private HTTPRequest {
45
46                 /////////////////////////////////////////////////////////////////////
47                 // Tipos.
48
49                 public:
50
51                         /// Tipo de métodos HTTP reconocidos.
52                         typedef std::vector<std::string> Arguments;
53
54                 /////////////////////////////////////////////////////////////////////
55                 // Atributos.
56
57                 private:
58
59                         /// Destinatario del comando.
60                         std::string target;
61
62                         /// Comando.
63                         std::string command;
64
65                         /// Lista de argumentos que recibe el comando.
66                         Arguments args;
67
68                 /////////////////////////////////////////////////////////////////////
69                 // Métodos.
70
71                 private:
72
73                         /**
74                          * Construye el URI.
75                          */
76                         void build(void);
77
78                 public:
79
80                         /**
81                          * Destructor.
82                          */
83                         virtual ~Command(void);
84
85                         /**
86                          * Constructor.
87                          */
88                         Command(const std::string& _target = "",
89                                         const std::string& _command = "");
90
91                         /**
92                          * Establece el destino.
93                          */
94                         void set_target(const std::string& _target);
95
96                         /**
97                          * Obtiene el destino.
98                          */
99                         const std::string& get_target(void) const;
100
101                         /**
102                          * Establece el comando.
103                          */
104                         void set_command(const std::string& _command);
105
106                         /**
107                          * Obtiene el comand.
108                          */
109                         const std::string& get_command(void) const;
110
111                         /**
112                          * Establece los argumentos.
113                          */
114                         void set_args(const Arguments& _args);
115
116                         /**
117                          * Obtiene los argumentos.
118                          */
119                         const Arguments& get_args(void) const;
120
121                         /**
122                          * Agrega un argumento.
123                          */
124                         void add_arg(const std::string& arg);
125
126                         /**
127                          * Agrega un argumento.
128                          */
129                         void add_arg(const unsigned& arg);
130
131                         /**
132                          * Obtiene el comando desde un pedido HTTP completo.
133                          */
134                         friend std::istream& operator>>(std::istream& is,
135                                         Command& command) throw(HTTPError, sockerr, ios::failure);
136
137                         /**
138                          * Convierte el comando a un pedido HTTP completo.
139                          */
140                         friend std::ostream& operator<<(std::ostream& os,
141                                         const Command& command) throw(sockerr);
142
143         };
144
145 }
146
147 }
148
149 #endif // PLAQUI_COMMAND_H