From c8e8e01f85d73944f9752bbd3f7746239aec6b9e Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 29 Jul 2009 07:35:47 +0000 Subject: Changed Socket * to Socket & in pentominos query. --- server/src/queryhandlerpentominos.cc | 21 ++++++++++----------- server/src/queryhandlerpentominos.h | 4 ++-- server/src/server.cc | 6 +++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/server/src/queryhandlerpentominos.cc b/server/src/queryhandlerpentominos.cc index 9e82241..c52b36c 100644 --- a/server/src/queryhandlerpentominos.cc +++ b/server/src/queryhandlerpentominos.cc @@ -135,11 +135,10 @@ static std::string getUID(const char *interface) } -QueryHandlerPentominos::QueryHandlerPentominos(TCPSocket *socket, std::string cpr) - : QueryHandler() +QueryHandlerPentominos::QueryHandlerPentominos(TCPSocket &_socket, std::string cpr) + : QueryHandler(), socket(_socket) { this->cpr = cpr; - this->socket = socket; } QueryResult QueryHandlerPentominos::exec(Query &query) @@ -155,7 +154,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" " xsi:schemaLocation=\"http://www.aasimon.org/pentominos schema.xsd\">\n"; #ifndef WITHOUT_PENTOMINOS - socket->write(header, strlen(header)); + socket.write(header, strlen(header)); #endif/*WITHOUT_PENTOMINOS*/ PRACRO_DEBUG(queryhandler, header); @@ -170,8 +169,8 @@ QueryResult QueryHandlerPentominos::exec(Query &query) cpr.c_str(), "pracro", #ifndef WITHOUT_PENTOMINOS - socket->srcaddr().c_str(), - socket->dstaddr().c_str(), + socket.srcaddr().c_str(), + socket.dstaddr().c_str(), #else "127.0.0.1", "127.0.0.1", @@ -179,7 +178,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) (unsigned int)timestamp, uid.c_str()); #ifndef WITHOUT_PENTOMINOS - socket->write(buf, strlen(buf)); + socket.write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ PRACRO_DEBUG(queryhandler, buf); @@ -192,7 +191,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) query.attributes["class"].c_str()); #ifndef WITHOUT_PENTOMINOS - socket->write(buf, strlen(buf)); + socket.write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ PRACRO_DEBUG(queryhandler, buf); @@ -200,7 +199,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) sprintf(buf, ""); #ifndef WITHOUT_PENTOMINOS - socket->write(buf, strlen(buf)); + socket.write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ PRACRO_DEBUG(queryhandler, buf); @@ -213,7 +212,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) ssize_t size; // Read until we've got the entire result. - while((size = socket->read(buf, sizeof(buf))) > 0) { + while((size = socket.read(buf, sizeof(buf))) > 0) { // fwrite(buf, size, 1, stdout); fflush(stdout); if(parser.parse(buf, size)) break; } @@ -246,7 +245,7 @@ int main() return 1; } - QueryHandlerPentominos qh(&s, "2003791613"); + QueryHandlerPentominos qh(s, "2003791613"); Query q1; q1.attributes["device_id"] = "lensmeter"; diff --git a/server/src/queryhandlerpentominos.h b/server/src/queryhandlerpentominos.h index 9cc2cbf..9c56d07 100644 --- a/server/src/queryhandlerpentominos.h +++ b/server/src/queryhandlerpentominos.h @@ -41,14 +41,14 @@ */ class QueryHandlerPentominos : public QueryHandler { public: - QueryHandlerPentominos(TCPSocket *socket, std::string cpr); + QueryHandlerPentominos(TCPSocket &socket, std::string cpr); ~QueryHandlerPentominos() {} // Execute all queries. QueryResult exec(Query &query); private: - TCPSocket *socket; + TCPSocket &socket; std::string cpr; }; diff --git a/server/src/server.cc b/server/src/server.cc index 1bfa2b0..af46119 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -109,7 +109,7 @@ static std::string handleCommits(Transaction *transaction, Database &db, static std::string handleRequest(Transaction *transaction, - TCPSocket *pentominos_socket, + TCPSocket &pentominos_socket, Database &db, JournalWriter &journalwriter, MacroList ¯olist) @@ -251,7 +251,7 @@ static std::string handleRequest(Transaction *transaction, } static std::string handleTransaction(Transaction *transaction, - TCPSocket *pentominos_socket, + TCPSocket &pentominos_socket, Database &db, JournalWriter &journalwriter, MacroList ¯olist) @@ -333,7 +333,7 @@ static void handleConnection(TCPSocket *socket) if(parser->parse(buf, size)) { PRACRO_DEBUG(server, "Got complete XML document %d bytes used, %d bytes in current buffer.\n", parser->usedBytes(), size); - socket->write(handleTransaction(transaction, &pentominos_socket, db, journalwriter, macrolist)); + socket->write(handleTransaction(transaction, pentominos_socket, db, journalwriter, macrolist)); size = size - parser->usedBytes(); delete transaction; transaction = NULL; -- cgit v1.2.3