From 2b83ae7c71dc706fb4fd7b4efc4a8ffee8dfe522 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 27 Oct 2008 22:41:06 +0100 Subject: Neues Initialisierung-Framework hinzugef?gt --- src/Core/ConnectionManager.cpp | 9 +++++---- src/Core/ConnectionManager.h | 21 ++++++++++----------- src/Core/RequestHandlers/LogRequestHandler.cpp | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/Core') diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index ff44da3..3d69165 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -42,7 +42,7 @@ namespace Mad { namespace Core { -std::auto_ptr ConnectionManager::connectionManager; +ConnectionManager ConnectionManager::connectionManager; void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) { @@ -129,8 +129,9 @@ void ConnectionManager::configFinished() { } } -ConnectionManager::ConnectionManager() { - Common::RequestManager::init(true); +void ConnectionManager::doInit() { + Common::RequestManager::getRequestManager()->setCore(true); + Common::RequestManager::getRequestManager()->init(); Common::RequestManager::getRequestManager()->registerPacketType(Net::Packet::FS_INFO); Common::RequestManager::getRequestManager()->registerPacketType(Net::Packet::STATUS); @@ -146,7 +147,7 @@ ConnectionManager::ConnectionManager() { Net::Connection::init(); } -ConnectionManager::~ConnectionManager() { +void ConnectionManager::doDeinit() { for(std::list::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con) delete *con; diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h index 29ed280..e9565f9 100644 --- a/src/Core/ConnectionManager.h +++ b/src/Core/ConnectionManager.h @@ -23,13 +23,15 @@ #include #include #include -#include #include #include #include +#include #include +#include + namespace Mad { namespace Net { @@ -41,9 +43,9 @@ class Packet; namespace Core { -class ConnectionManager : private Common::Configurable { +class ConnectionManager : public Common::Initializable, public Common::Configurable { private: - static std::auto_ptr connectionManager; + static ConnectionManager connectionManager; std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; @@ -60,27 +62,24 @@ class ConnectionManager : private Common::Configurable { ConnectionManager(const ConnectionManager &o); ConnectionManager& operator=(const ConnectionManager &o); - ConnectionManager(); + ConnectionManager() {} void handleConnections(std::list &connections); void updateState(const std::string &name, Common::HostInfo::State state); protected: + virtual void doInit(); + virtual void doDeinit(); + virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool handled); virtual void configFinished(); public: static ConnectionManager* getConnectionManager() { - return connectionManager.get(); + return &connectionManager; } - static void init() { - connectionManager = std::auto_ptr(new ConnectionManager()); - } - - ~ConnectionManager(); - void run(); Net::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&); diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp index 6bda627..c2b2fde 100644 --- a/src/Core/RequestHandlers/LogRequestHandler.cpp +++ b/src/Core/RequestHandlers/LogRequestHandler.cpp @@ -19,7 +19,7 @@ #include "LogRequestHandler.h" #include -#include +#include #include "../ConnectionManager.h" #include #include @@ -43,7 +43,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Pac Net::Packets::LogPacket logPacket(packet); try { - Common::RemoteLogger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(), + Common::LogManager::getLogManager()->log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(), ConnectionManager::getConnectionManager()->getDaemonName(connection)); } catch(Common::Exception &e) { -- cgit v1.2.3