diff options
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/InformationManager.cpp | 6 | ||||
-rw-r--r-- | src/Client/InformationManager.h | 19 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index a2f67cb..cef0ce1 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -28,7 +28,7 @@ namespace Mad { namespace Client { -Common::SingletonPtr<InformationManager> InformationManager::informationManager; +InformationManager InformationManager::informationManager; void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) { @@ -56,11 +56,11 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection } -InformationManager::InformationManager() : updating(false) { +void InformationManager::doInit() { Common::RequestManager::get()->registerPacketType<DaemonStateUpdateRequest>(Net::Packet::DAEMON_STATE_UPDATE); } -InformationManager::~InformationManager() { +void InformationManager::doDeinit() { Common::RequestManager::get()->unregisterPacketType(Net::Packet::DAEMON_STATE_UPDATE); } diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h index 1464e2f..80dab9f 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 { +class InformationManager : public Common::Initializable { private: class DaemonStateUpdateRequest : public Common::RequestHandler { protected: @@ -50,7 +50,7 @@ class InformationManager { DaemonStateUpdateRequest() {} }; - static Common::SingletonPtr<InformationManager> informationManager; + static InformationManager informationManager; std::map<std::string, Common::HostInfo> daemons; @@ -60,16 +60,19 @@ class InformationManager { 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 doDeinit(); + public: - static InformationManager* get() { - return informationManager.get(); + static InformationManager *get() { + return &informationManager; } - InformationManager(); - virtual ~InformationManager(); - void updateDaemonList(Net::Connection *con); bool isUpdating() const { |