From 7234fe326d16d6bf9f4374a09ddc6ef790e6723f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 18 Jun 2009 22:03:02 +0200 Subject: Globale Variablen durch Application-Klasse ersetzt --- src/madc.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/madc.cpp') diff --git a/src/madc.cpp b/src/madc.cpp index ea32f2f..55c2be7 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -18,12 +18,12 @@ */ #include "Core/ConfigManager.h" -#include "Core/Logger.h" -#include "Core/ThreadManager.h" #include "Common/ClientConnection.h" #include "Common/RequestManager.h" #include "Common/Requests/IdentifyRequest.h" + +#include "Client/Application.h" #include "Client/CommandParser.h" #include "Client/InformationManager.h" @@ -48,12 +48,11 @@ int main(int argc, char *argv[]) { std::exit(1); } - Core::ThreadManager::get()->init(); - Client::InformationManager::get()->init(); + Client::Application application; - Core::ConfigManager::get()->finish(); + application.getConfigManager()->finish(); - Common::ClientConnection *connection = new Common::ClientConnection; + Common::ClientConnection *connection = new Common::ClientConnection(&application); try { connection->connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(argv[1]), 6666)); @@ -62,32 +61,32 @@ int main(int argc, char *argv[]) { connection->waitWhileConnecting(); - Common::RequestManager::get()->registerConnection(connection); + application.getRequestManager()->registerConnection(connection); { - boost::shared_ptr request(new Common::Requests::IdentifyRequest); - Common::RequestManager::get()->sendRequest(connection, request); + boost::shared_ptr request(new Common::Requests::IdentifyRequest(&application)); + application.getRequestManager()->sendRequest(connection, request); request->wait(); } std::cerr << " connected." << std::endl; std::cerr << "Receiving host list..." << std::flush; - Client::InformationManager::get()->updateDaemonList(connection); - Client::InformationManager::get()->waitWhileUpdating(); + application.getInformationManager()->updateDaemonList(connection); + application.getInformationManager()->waitWhileUpdating(); std::cerr << " done." << std::endl << std::endl; - Client::CommandParser::get()->setConnection(connection); + Client::CommandParser commandParser(&application, connection); - while(connection->isConnected() && !Client::CommandParser::get()->willDisconnect()) { + while(connection->isConnected() && !commandParser.willDisconnect()) { char *cmd = readline("mad> "); if(!cmd) { - Client::CommandParser::get()->requestDisconnect(); + commandParser.requestDisconnect(); } else if(*cmd) { - Client::CommandParser::get()->parse(cmd); + commandParser.parse(cmd); add_history(cmd); } else continue; @@ -95,15 +94,13 @@ int main(int argc, char *argv[]) { connection->waitWhileConnected(); - Common::RequestManager::get()->unregisterConnection(connection); + application.getRequestManager()->unregisterConnection(connection); } catch(Core::Exception &e) { - Core::Logger::logf(Core::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str()); + application.logf(Core::LoggerBase::CRITICAL, "Connection error: %s", e.strerror().c_str()); } delete connection; - Core::Initializable::deinit(); - return 0; } -- cgit v1.2.3