summaryrefslogtreecommitdiffstats
path: root/src/mad.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
commit7234fe326d16d6bf9f4374a09ddc6ef790e6723f (patch)
tree437d4c40eeb1e9b34b369e4b82064a1572c7dac9 /src/mad.cpp
parentbf561f8226e97f4ace4f04bddf198175e91ee7f0 (diff)
downloadmad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.tar
mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.zip
Globale Variablen durch Application-Klasse ersetzt
Diffstat (limited to 'src/mad.cpp')
-rw-r--r--src/mad.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/mad.cpp b/src/mad.cpp
index b1dbb8f..e0266f8 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -17,15 +17,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Core/ThreadManager.h"
#include "Core/ConfigManager.h"
#include "Core/LogManager.h"
+
#include "Common/ModuleManager.h"
#include "Common/RequestManager.h"
#include "Common/ClientConnection.h"
#include "Common/Requests/IdentifyRequest.h"
#include "Common/RequestHandlers/FSInfoRequestHandler.h"
#include "Common/RequestHandlers/StatusRequestHandler.h"
+
+#include "Daemon/Application.h"
#include "Daemon/Backends/NetworkLogger.h"
#include "Daemon/RequestHandlers/CommandRequestHandler.h"
@@ -35,19 +37,19 @@ using namespace Mad;
int main() {
- Core::ThreadManager::get()->init();
+ Daemon::Application application;
- Common::ModuleManager::get()->loadModule("FileLogger");
- Common::ModuleManager::get()->loadModule("SystemBackendPosix");
- Common::ModuleManager::get()->loadModule("SystemBackendProc");
+ application.getModuleManager()->loadModule("FileLogger");
+ application.getModuleManager()->loadModule("SystemBackendPosix");
+ application.getModuleManager()->loadModule("SystemBackendProc");
- Core::ConfigManager::get()->finish();
+ application.getConfigManager()->finish();
- Common::RequestManager::get()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>("Command");
- Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>("FSInfo");
- Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>("GetStatus");
+ application.getRequestManager()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>("Command");
+ application.getRequestManager()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>("FSInfo");
+ application.getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>("GetStatus");
- Common::ClientConnection *connection = new Common::ClientConnection;
+ Common::ClientConnection *connection = new Common::ClientConnection(&application);
try {
connection->connect(boost::asio::ip::tcp::endpoint(
@@ -55,40 +57,33 @@ int main() {
connection->waitWhileConnecting();
- Common::RequestManager::get()->registerConnection(connection);
+ application.getRequestManager()->registerConnection(connection);
- boost::shared_ptr<Core::Logger> networkLogger(new Daemon::Backends::NetworkLogger(connection));
- Core::LogManager::get()->registerLogger(networkLogger);
+ boost::shared_ptr<Core::Logger> networkLogger(new Daemon::Backends::NetworkLogger(&application, connection));
+ application.getLogManager()->registerLogger(networkLogger);
-
- //char hostname[256];
- //gethostname(hostname, sizeof(hostname));
- //Common::RequestManager::get()->sendRequest<Daemon::Requests::IdentifyRequest>(connection, sigc::ptr_fun(requestFinished), hostname);
- //Common::RequestManager::get()->sendRequest1<Common::Requests::IdentifyRequest>(connection, "test")->wait();
{
- boost::shared_ptr<Common::Requests::IdentifyRequest> request(new Common::Requests::IdentifyRequest("test"));
- Common::RequestManager::get()->sendRequest(connection, request);
+ boost::shared_ptr<Common::Requests::IdentifyRequest> request(new Common::Requests::IdentifyRequest(&application, "test"));
+ application.getRequestManager()->sendRequest(connection, request);
request->wait();
}
- Core::Logger::log("Identified.");
+ application.log("Identified.");
connection->waitWhileConnected();
- Core::LogManager::get()->unregisterLogger(networkLogger);
+ application.getLogManager()->unregisterLogger(networkLogger);
- Common::RequestManager::get()->unregisterConnection(connection);
+ application.getRequestManager()->unregisterConnection(connection);
}
catch(Core::Exception &e) {
- Core::Logger::logf(Core::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
+ application.logf(Core::LoggerBase::CRITICAL, "Connection error: %s", e.strerror().c_str());
}
delete connection;
- Common::RequestManager::get()->unregisterPacketType("Command");
- Common::RequestManager::get()->unregisterPacketType("FSInfo");
- Common::RequestManager::get()->unregisterPacketType("GetStatus");
-
- Core::Initializable::deinit();
+ application.getRequestManager()->unregisterPacketType("Command");
+ application.getRequestManager()->unregisterPacketType("FSInfo");
+ application.getRequestManager()->unregisterPacketType("GetStatus");
return 0;
}