From 0a1df98c0420e9ac097622f2bddcd73a6488ed52 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 20 Nov 2008 00:33:28 +0100 Subject: SingletonPtr hinzugefuegt --- src/Client/InformationManager.cpp | 12 +++++------- src/Client/InformationManager.h | 17 +++++++---------- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src/Client') diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 37835c1..a2f67cb 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -28,7 +28,7 @@ namespace Mad { namespace Client { -InformationManager InformationManager::informationManager; +Common::SingletonPtr InformationManager::informationManager; void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) { @@ -44,8 +44,8 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection Net::Packets::HostStatePacket hostStatePacket(packet); - std::map::iterator host = informationManager.daemons.find(hostStatePacket.getName()); - if(host != informationManager.daemons.end()) + std::map::iterator host = informationManager.get()->daemons.find(hostStatePacket.getName()); + if(host != informationManager.get()->daemons.end()) host->second.setState(hostStatePacket.getState()); else Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host."); @@ -56,13 +56,11 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection } -void InformationManager::doInit() { - Common::RequestManager::get()->init(); - +InformationManager::InformationManager() : updating(false) { Common::RequestManager::get()->registerPacketType(Net::Packet::DAEMON_STATE_UPDATE); } -void InformationManager::doUninit() { +InformationManager::~InformationManager() { Common::RequestManager::get()->unregisterPacketType(Net::Packet::DAEMON_STATE_UPDATE); } diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h index 4acde37..1464e2f 100644 --- a/src/Client/InformationManager.h +++ b/src/Client/InformationManager.h @@ -24,8 +24,8 @@ #include #include -#include #include +#include namespace Mad { @@ -40,7 +40,7 @@ class HostListPacket; namespace Client { -class InformationManager : public Common::Initializable { +class InformationManager { private: class DaemonStateUpdateRequest : public Common::RequestHandler { protected: @@ -50,7 +50,7 @@ class InformationManager : public Common::Initializable { DaemonStateUpdateRequest() {} }; - static InformationManager informationManager; + static Common::SingletonPtr informationManager; std::map daemons; @@ -60,19 +60,16 @@ class InformationManager : public Common::Initializable { InformationManager(const InformationManager &o); InformationManager& operator=(const InformationManager &o); - InformationManager() : updating(false) {} - void daemonListRequestFinished(const Common::Request &request); - protected: - virtual void doInit(); - virtual void doUninit(); - public: static InformationManager* get() { - return &informationManager; + return informationManager.get(); } + InformationManager(); + virtual ~InformationManager(); + void updateDaemonList(Net::Connection *con); bool isUpdating() const { -- cgit v1.2.3