diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-11-20 00:33:28 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-11-20 00:33:28 +0100 |
commit | 0a1df98c0420e9ac097622f2bddcd73a6488ed52 (patch) | |
tree | 65f5eaa940bcf5d8c38b88b4fd369cfee43a4a7f /src/Core | |
parent | 854421e2c144ab6454d67beb6640579ad13f1a1f (diff) | |
download | mad-0a1df98c0420e9ac097622f2bddcd73a6488ed52.tar mad-0a1df98c0420e9ac097622f2bddcd73a6488ed52.zip |
SingletonPtr hinzugefuegt
Diffstat (limited to 'src/Core')
-rw-r--r-- | src/Core/ConnectionManager.cpp | 9 | ||||
-rw-r--r-- | src/Core/ConnectionManager.h | 14 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index 7df9e8b..833e2e6 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -42,7 +42,7 @@ namespace Mad { namespace Core { -ConnectionManager ConnectionManager::connectionManager; +Common::SingletonPtr<ConnectionManager> ConnectionManager::connectionManager; void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) { @@ -129,9 +129,8 @@ void ConnectionManager::configFinished() { } } -void ConnectionManager::doInit() { +ConnectionManager::ConnectionManager() { Common::RequestManager::get()->setCore(true); - Common::RequestManager::get()->init(); Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>(Net::Packet::FS_INFO); Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS); @@ -147,7 +146,7 @@ void ConnectionManager::doInit() { Net::Connection::init(); } -void ConnectionManager::doDeinit() { +ConnectionManager::~ConnectionManager() { for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con) delete *con; @@ -183,7 +182,7 @@ void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& con void ConnectionManager::run() { // TODO Logging - Net::FdManager::getFdManager()->run(); + Net::FdManager::get()->run(); handleConnections(daemonConnections); handleConnections(clientConnections); diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h index c17bae5..86c342c 100644 --- a/src/Core/ConnectionManager.h +++ b/src/Core/ConnectionManager.h @@ -27,8 +27,8 @@ #include <Common/Configurable.h> #include <Common/Exception.h> #include <Common/HostInfo.h> -#include <Common/Initializable.h> #include <Common/RequestManager.h> +#include <Common/SingletonPtr.h> #include <Net/IPAddress.h> @@ -45,7 +45,7 @@ namespace Core { class ConnectionManager : public Common::Configurable { private: - static ConnectionManager connectionManager; + static Common::SingletonPtr<ConnectionManager> connectionManager; std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; @@ -62,22 +62,20 @@ class ConnectionManager : public Common::Configurable { ConnectionManager(const ConnectionManager &o); ConnectionManager& operator=(const ConnectionManager &o); - ConnectionManager() {} - void handleConnections(std::list<Net::ServerConnection*> &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: + ConnectionManager(); + virtual ~ConnectionManager(); + static ConnectionManager* get() { - return &connectionManager; + return connectionManager.get(); } void run(); |