]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se eliminan los namespaces en los cuerpos de las definiones de los metodos que
authorLeandro Lucarella <llucax@gmail.com>
Thu, 23 Oct 2003 02:21:07 +0000 (02:21 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Thu, 23 Oct 2003 02:21:07 +0000 (02:21 +0000)
eran redundantes y se mejoran algunos mensajes de DEBUG.

Server/src/controlclient.cpp
Server/src/controlserver.cpp
Server/src/receiver.cpp
Server/src/request.cpp
Server/src/runnable.cpp
Server/src/server.cpp
Server/src/serverconnection.cpp
Server/src/tcpserver.cpp
Server/src/transmitter.cpp

index fd0fdba9e922e3df779ac0cec15b0033af451381..3ceaa9f4ae53cf3c4439095bee27ddf2ce82da32 100644 (file)
@@ -37,7 +37,7 @@ PlaQui::Server::ControlClient::~ControlClient(void) {
 }
 
 PlaQui::Server::ControlClient::ControlClient(std::string host, int port):
-               PlaQui::Server::Connection(sockbuf::sock_stream) {
+               Connection(sockbuf::sock_stream) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": host" << host
                << " | port = " << port << std::endl;
index 753255ede4e7cf3acfd101ddfc44d0dc35f4f453..0587bc17f052d0d69e9cfdaf79b1aae9b108ce4a 100644 (file)
@@ -40,7 +40,7 @@ PlaQui::Server::ControlServer::~ControlServer(void) {
 }
 
 PlaQui::Server::ControlServer::ControlServer(const sockbuf::sockdesc& sd):
-               PlaQui::Server::ServerConnection(sd) {
+               ServerConnection(sd) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": sd = " << sd.sock << std::endl;
 #endif // DEBUG
index c64eaad235e905bd7fe88ebaa735a9a73a390503..9667e8c4b326b9d1ef178cadd304c3ab7fe543f1 100644 (file)
@@ -37,7 +37,7 @@ PlaQui::Server::Receiver::~Receiver(void) {
 }
 
 PlaQui::Server::Receiver::Receiver(int port, std::string host):
-               PlaQui::Server::ServerConnection(sockbuf::sock_dgram) {
+               ServerConnection(sockbuf::sock_dgram) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": port = " << port
                << " | host = " << host << std::endl;
index 9e6aadf07d3bac689b012e423ba224b0101462f9..f40c9f9e2f7608b70b573aea7ba8905ebda93426 100644 (file)
@@ -70,7 +70,7 @@ void PlaQui::Server::Request::set_request(const std::string& req,
        std::cerr << __FILE__ << ": req = " << req << " | host = " << host
                << " | port = " << port << std::endl;
 #endif // DEBUG
-       PlaQui::Server::String request(req);
+       String request(req);
        (*this)["REMOTE_HOST"] = host;
        std::stringstream ss;
        ss << port;
@@ -81,9 +81,8 @@ void PlaQui::Server::Request::set_request(const std::string& req,
                throw "HTTP/1.1 501 Method Not Implemented";
        }
        // Averiguo método.
-       std::string::size_type pos = request.find_first_of(
-                       PlaQui::Server::String::SPACE_CHARS);
-       PlaQui::Server::String method = request.substr(0, pos); 
+       std::string::size_type pos = request.find_first_of(String::SPACE_CHARS);
+       String method = request.substr(0, pos); 
        if ((method.to_upper() == "GET") || (method.to_upper() == "POST")) {
                (*this)["REQUEST_METHOD"] = method;
        } else {
@@ -98,13 +97,13 @@ void PlaQui::Server::Request::set_request(const std::string& req,
                throw "HTTP/1.1 400 Bad Request";
        }
        // Si tiene más espacios, tengo la URI y el protocolo (o un error).
-       pos = request.find_first_of(PlaQui::Server::String::SPACE_CHARS);
+       pos = request.find_first_of(String::SPACE_CHARS);
        if (pos != std::string::npos) {
                // Si el resto es un protocolo válido, agrego más variables.
-               PlaQui::Server::String protocol = request.substr(pos + 1);
+               String protocol = request.substr(pos + 1);
                protocol = protocol.trim();
-               if ((PlaQui::Server::String(protocol).to_upper() == "HTTP/1.0")
-                               || (PlaQui::Server::String(protocol).to_upper() == "HTTP/1.1")) {
+               if ((String(protocol).to_upper() == "HTTP/1.0")
+                               || (String(protocol).to_upper() == "HTTP/1.1")) {
                        (*this)["SERVER_PROTOCOL"] = protocol;
                // Si no es un error.
                } else {
index 0c6b477306347ffd64f012fc5b43817b7094bf5d..7fd410535c9c6893145182e8a3b3f358636eb4fc 100644 (file)
@@ -34,7 +34,8 @@
 
 PlaQui::Server::Runnable::~Runnable(void) {
 #ifdef DEBUG
-       std::cerr << __FILE__ << ": destructor." << std::endl;
+       std::cerr << __FILE__ << ": destructor(this = " << this << ")"
+               << std::endl;
 #endif // DEBUG
 }
 
@@ -44,9 +45,10 @@ PlaQui::Server::Runnable::Runnable(void): thread(0), stop(false) {
 #endif // DEBUG
 }
 
-void PlaQui::Server::Runnable::static_run(PlaQui::Server::Runnable* runner) {
+void PlaQui::Server::Runnable::static_run(Runnable* runner) {
 #ifdef DEBUG
-       std::cerr << __FILE__ << ": runner = " << runner << std::endl;
+       std::cerr << __FILE__ << ": static_run(runner = " << runner << ")"
+               << std::endl;
 #endif // DEBUG
        runner->real_run();
        runner->signal_finished().emit();
@@ -55,7 +57,7 @@ void PlaQui::Server::Runnable::static_run(PlaQui::Server::Runnable* runner) {
 
 void PlaQui::Server::Runnable::run(bool detach) {
 #ifdef DEBUG
-       std::cerr << __FILE__ << ": detach = " << detach << std::endl;
+       std::cerr << __FILE__ << ": run(detach = " << detach << ")" << std::endl;
 #endif // DEBUG
        // Si vamos a correr la tarea en un thread.
        if (detach) {
@@ -66,9 +68,7 @@ void PlaQui::Server::Runnable::run(bool detach) {
                // Corremos el thread en una funcion estática para poder destruirlo al
                // finalizar, pasandole el puntero al objeto.
                thread = Glib::Thread::create(
-                               SigC::bind<Runnable*>(
-                                       SigC::slot(&PlaQui::Server::Runnable::static_run),
-                                       this),
+                               SigC::bind<Runnable*>(SigC::slot(&Runnable::static_run), this),
                                true);
        // Si no corremos la tarea normalmente.
        } else {
@@ -79,7 +79,7 @@ void PlaQui::Server::Runnable::run(bool detach) {
 
 void PlaQui::Server::Runnable::finish(bool attach) {
 #ifdef DEBUG
-       std::cerr << __FILE__ << ": attach = " << attach << std::endl;
+       std::cerr << __FILE__ << ": finish(attach = " << attach << ")" << std::endl;
 #endif // DEBUG
        // TODO - necesita un mutex?
        stop = true;
index 8f33449f4904a5d6fa971e1ce2faba79b1c44a65..134bcf517f9f1d386c1d8a75ea648c744a651e5d 100644 (file)
@@ -40,7 +40,7 @@ PlaQui::Server::Server::~Server(void) {
 }
 
 PlaQui::Server::Server::Server(int port):
-               PlaQui::Server::TCPServer(port) {
+               TCPServer(port) {
 #ifdef DEBUG
        std::cerr << __FILE__ <<  ": port = " << port << std::endl;
 #endif // DEBUG
@@ -56,19 +56,18 @@ bool PlaQui::Server::Server::start_transmission(std::string host, int port) {
        return false;
 }
                        
-PlaQui::Server::Connection*
-PlaQui::Server::Server::new_connection(const sockbuf::sockdesc& sd) {
+PlaQui::Server::Connection* PlaQui::Server::Server::new_connection(
+               const sockbuf::sockdesc& sd) {
 #ifdef DEBUG
        std::cerr << __FILE__ <<  ": new_connection(sd = " << sd.sock << ")"
                << std::endl;
 #endif // DEBUG
-       PlaQui::Server::ControlServer* conn = new PlaQui::Server::ControlServer(sd);
+       ControlServer* connection = new ControlServer(sd);
        // TODO verificar si el new se hace bien? no creo.
-       conn->signal_command_received().connect(
-                       SigC::slot_class(*this,
-                               &PlaQui::Server::Server::on_control_command_received));
+       connection->signal_command_received().connect(
+                       SigC::slot_class(*this, &Server::on_control_command_received));
        // TODO: 
-       return conn;
+       return connection;
 }
 
 /// \todo Implementar.
index a5cbea395c15b7e041060120801cbba87e5a812e..6cbe0f3d7a4a35b0d91799c078d48ab6ac7f1e70 100644 (file)
@@ -38,14 +38,14 @@ PlaQui::Server::ServerConnection::~ServerConnection(void) {
 }
 
 PlaQui::Server::ServerConnection::ServerConnection(const sockbuf::sockdesc& sd):
-               PlaQui::Server::Connection(sd) {
+               Connection(sd) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": sd = " << sd.sock << std::endl;
 #endif // DEBUG
 }
 
 PlaQui::Server::ServerConnection::ServerConnection(sockbuf::type type):
-               PlaQui::Server::Connection(type) {
+               Connection(type) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": type = " << type << std::endl;
 #endif // DEBUG
index c00a8b6457455bc8396120ade7bbf55eafbffd0b..413122464a6b263b54762937d2a83296cc11a8a9 100644 (file)
@@ -55,36 +55,54 @@ PlaQui::Server::TCPServer::TCPServer(int port):
 }
 
 void PlaQui::Server::TCPServer::on_connection_finished(
-               PlaQui::Server::Connection* connection) {
+               Connection* connection) {
 #ifdef DEBUG
        std::cerr << __FILE__ <<  ": on_connection_finished(connection = "
                << connection << ")" << std::endl;
 #endif // DEBUG
        // TODO: poner lock.
        connections.remove(connection);
+#ifdef DEBUG
+       std::cerr << __FILE__ <<  ": lista de conexiones" << std::endl;
+       for (ConnectionList::const_iterator i = connections.begin();
+                       i != connections.end(); i++) {
+               std::cerr << "\t " << *i << std::endl;
+       }
+#endif // DEBUG
        // TODO: sacar lock.
 }
 
 void PlaQui::Server::TCPServer::real_run(void) {
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": real_run" << std::endl;
+       std::cerr << __FILE__ <<  ": real_run()" << std::endl;
 #endif // DEBUG
-       PlaQui::Server::Connection* conn;
+       Connection* connection;
        while (!stop) {
                // TODO: ver tema de timeout o como salir de un accept().
                // Forma grasa de salir del accept: crear conexion que salga al toque.
-               conn = new_connection(socket.accept());
+               connection = new_connection(socket.accept());
+#ifdef DEBUG
+       std::cerr << __FILE__ <<  ": real_run(): connection = " << connection
+               << std::endl;
+#endif // DEBUG
                // TODO: poner lock.
-               connections.push_back(conn);
+               connections.push_back(connection);
+#ifdef DEBUG
+       std::cerr << __FILE__ <<  ": real_run(): lista de conexiones" << std::endl;
+       for (ConnectionList::const_iterator i = connections.begin();
+                       i != connections.end(); i++) {
+               std::cerr << "\t " << *i << std::endl;
+       }
+#endif // DEBUG
                // TODO: sacar lock.
                // TODO: esto va en Server::new_connection()
                // Conecto la señal para cuando termina una conexión, borrarla.
-               conn->signal_finished().connect(
-                               SigC::bind<PlaQui::Server::Connection*>(
+               connection->signal_finished().connect(
+                               SigC::bind<Connection*>(
                                        SigC::slot_class(*this,
-                                               &PlaQui::Server::TCPServer::on_connection_finished),
-                                       conn));
-               conn->run();
+                                               &TCPServer::on_connection_finished),
+                                       connection));
+               connection->run();
        }
 }
 
index 268f2168baaeb7c9fa7d425b59ac1c38e9d0139b..75f622d018e1d6bc831c470fb18647f46b6141d7 100644 (file)
@@ -40,7 +40,7 @@ PlaQui::Server::Transmitter::~Transmitter(void) {
 
 /// \todo debría conectarse en real_run() (?)
 PlaQui::Server::Transmitter::Transmitter(std::string host, int port):
-               PlaQui::Server::Connection(sockbuf::sock_dgram) {
+               Connection(sockbuf::sock_dgram) {
 #ifdef DEBUG
        std::cerr << __FILE__ << ": host = " << host
                << " | port = " << port << std::endl;