summaryrefslogtreecommitdiffstats
path: root/src/Client
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client')
-rw-r--r--src/Client/InformationManager.cpp12
-rw-r--r--src/Client/InformationManager.h17
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 {