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/Client | |
parent | 854421e2c144ab6454d67beb6640579ad13f1a1f (diff) | |
download | mad-0a1df98c0420e9ac097622f2bddcd73a6488ed52.tar mad-0a1df98c0420e9ac097622f2bddcd73a6488ed52.zip |
SingletonPtr hinzugefuegt
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/InformationManager.cpp | 12 | ||||
-rw-r--r-- | src/Client/InformationManager.h | 17 |
2 files changed, 12 insertions, 17 deletions
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::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<std::string, Common::HostInfo>::iterator host = informationManager.daemons.find(hostStatePacket.getName()); - if(host != informationManager.daemons.end()) + std::map<std::string, Common::HostInfo>::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<DaemonStateUpdateRequest>(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 <memory> #include <Common/HostInfo.h> -#include <Common/Initializable.h> #include <Common/Request.h> +#include <Common/SingletonPtr.h> 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> informationManager; std::map<std::string, Common::HostInfo> 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<Net::Packets::HostListPacket> &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 { |