summaryrefslogtreecommitdiffstats
path: root/src/Core
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-10-27 22:41:06 +0100
committerMatthias Schiffer <matthias@gamezock.de>2008-10-27 22:41:06 +0100
commit2b83ae7c71dc706fb4fd7b4efc4a8ffee8dfe522 (patch)
tree4f63c64041fd93255105493fd444a65ad0761b9b /src/Core
parentb58831e5eec4d0595099b8e9c2979b157fe37041 (diff)
downloadmad-2b83ae7c71dc706fb4fd7b4efc4a8ffee8dfe522.tar
mad-2b83ae7c71dc706fb4fd7b4efc4a8ffee8dfe522.zip
Neues Initialisierung-Framework hinzugef?gt
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/ConnectionManager.cpp9
-rw-r--r--src/Core/ConnectionManager.h21
-rw-r--r--src/Core/RequestHandlers/LogRequestHandler.cpp4
3 files changed, 17 insertions, 17 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index ff44da3..3d69165 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -42,7 +42,7 @@
namespace Mad {
namespace Core {
-std::auto_ptr<ConnectionManager> ConnectionManager::connectionManager;
+ConnectionManager ConnectionManager::connectionManager;
void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) {
@@ -129,8 +129,9 @@ void ConnectionManager::configFinished() {
}
}
-ConnectionManager::ConnectionManager() {
- Common::RequestManager::init(true);
+void ConnectionManager::doInit() {
+ Common::RequestManager::getRequestManager()->setCore(true);
+ Common::RequestManager::getRequestManager()->init();
Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>(Net::Packet::FS_INFO);
Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS);
@@ -146,7 +147,7 @@ ConnectionManager::ConnectionManager() {
Net::Connection::init();
}
-ConnectionManager::~ConnectionManager() {
+void ConnectionManager::doDeinit() {
for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con)
delete *con;
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index 29ed280..e9565f9 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -23,13 +23,15 @@
#include <list>
#include <vector>
#include <map>
-#include <memory>
#include <Common/Configurable.h>
#include <Common/Exception.h>
#include <Common/HostInfo.h>
+#include <Common/Initializable.h>
#include <Common/RequestManager.h>
+#include <Net/IPAddress.h>
+
namespace Mad {
namespace Net {
@@ -41,9 +43,9 @@ class Packet;
namespace Core {
-class ConnectionManager : private Common::Configurable {
+class ConnectionManager : public Common::Initializable, public Common::Configurable {
private:
- static std::auto_ptr<ConnectionManager> connectionManager;
+ static ConnectionManager connectionManager;
std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
@@ -60,27 +62,24 @@ class ConnectionManager : private Common::Configurable {
ConnectionManager(const ConnectionManager &o);
ConnectionManager& operator=(const ConnectionManager &o);
- ConnectionManager();
+ 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:
static ConnectionManager* getConnectionManager() {
- return connectionManager.get();
+ return &connectionManager;
}
- static void init() {
- connectionManager = std::auto_ptr<ConnectionManager>(new ConnectionManager());
- }
-
- ~ConnectionManager();
-
void run();
Net::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&);
diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp
index 6bda627..c2b2fde 100644
--- a/src/Core/RequestHandlers/LogRequestHandler.cpp
+++ b/src/Core/RequestHandlers/LogRequestHandler.cpp
@@ -19,7 +19,7 @@
#include "LogRequestHandler.h"
#include <Common/Logger.h>
-#include <Common/RemoteLogger.h>
+#include <Common/LogManager.h>
#include "../ConnectionManager.h"
#include <Net/Connection.h>
#include <Net/Packets/ErrorPacket.h>
@@ -43,7 +43,7 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Pac
Net::Packets::LogPacket logPacket(packet);
try {
- Common::RemoteLogger::log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(),
+ Common::LogManager::getLogManager()->log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(),
ConnectionManager::getConnectionManager()->getDaemonName(connection));
}
catch(Common::Exception &e) {