From 7234fe326d16d6bf9f4374a09ddc6ef790e6723f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 18 Jun 2009 22:03:02 +0200 Subject: Globale Variablen durch Application-Klasse ersetzt --- src/Core/Signals/GenericSignal.h | 2 ++ src/Core/Signals/Signal0.h | 5 ++++- src/Core/Signals/Signal1.h | 5 ++++- src/Core/Signals/Signal2.h | 5 ++++- src/Core/Signals/SignalBase.h | 11 ++++++++++- 5 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/Core/Signals') diff --git a/src/Core/Signals/GenericSignal.h b/src/Core/Signals/GenericSignal.h index 641f575..af5bae9 100644 --- a/src/Core/Signals/GenericSignal.h +++ b/src/Core/Signals/GenericSignal.h @@ -37,6 +37,8 @@ class GenericSignal : protected SignalBase { protected: std::map handlers; + GenericSignal(Application *application) : SignalBase(application) {} + public: Connection connect(const slot_type &slot) { boost::lock_guard lock(mutex); diff --git a/src/Core/Signals/Signal0.h b/src/Core/Signals/Signal0.h index ccfb548..c01a82a 100644 --- a/src/Core/Signals/Signal0.h +++ b/src/Core/Signals/Signal0.h @@ -21,6 +21,7 @@ #define MAD_CORE_SIGNALS_SIGNAL0_H_ #include "GenericSignal.h" +#include "../Application.h" #include "../ThreadManager.h" #include @@ -31,11 +32,13 @@ namespace Signals { class Signal0 : public GenericSignal > { public: + Signal0(Application *application) : GenericSignal >(application) {} + void emit() { boost::lock_guard lock(mutex); for(std::map::iterator handler = handlers.begin(); handler != handlers.end(); ++handler) - ThreadManager::get()->pushWork(handler->second); + getApplication()->getThreadManager()->pushWork(handler->second); } }; diff --git a/src/Core/Signals/Signal1.h b/src/Core/Signals/Signal1.h index e4a946c..0a03c39 100644 --- a/src/Core/Signals/Signal1.h +++ b/src/Core/Signals/Signal1.h @@ -21,6 +21,7 @@ #define MAD_CORE_SIGNALS_SIGNAL1_H_ #include "GenericSignal.h" +#include "../Application.h" #include "../ThreadManager.h" #include @@ -32,11 +33,13 @@ namespace Signals { template class Signal1 : public GenericSignal > { public: + Signal1(Application *application) : GenericSignal >(application) {} + void emit(T1 arg1) { boost::lock_guard lock(this->mutex); for(typename std::map >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) - ThreadManager::get()->pushWork(boost::bind(handler->second, arg1)); + this->getApplication()->getThreadManager()->pushWork(boost::bind(handler->second, arg1)); } }; diff --git a/src/Core/Signals/Signal2.h b/src/Core/Signals/Signal2.h index 41045d7..0966258 100644 --- a/src/Core/Signals/Signal2.h +++ b/src/Core/Signals/Signal2.h @@ -21,6 +21,7 @@ #define MAD_CORE_SIGNALS_SIGNAL2_H_ #include "GenericSignal.h" +#include "../Application.h" #include "../ThreadManager.h" #include @@ -32,11 +33,13 @@ namespace Signals { template class Signal2 : public GenericSignal > { public: + Signal2(Application *application) : GenericSignal >(application) {} + void emit(T1 arg1, T2 arg2) { boost::lock_guard lock(this->mutex); for(typename std::map >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler) - ThreadManager::get()->pushWork(boost::bind(handler->second, arg1, arg2)); + this->getApplication()->getThreadManager()->pushWork(boost::bind(handler->second, arg1, arg2)); } }; diff --git a/src/Core/Signals/SignalBase.h b/src/Core/Signals/SignalBase.h index 1a5d5a3..8ec8483 100644 --- a/src/Core/Signals/SignalBase.h +++ b/src/Core/Signals/SignalBase.h @@ -27,12 +27,17 @@ namespace Mad { namespace Core { + +class Application; + namespace Signals { class SignalBase : private boost::noncopyable { private: friend class Connection; + Application *application; + unsigned long connectionId; protected: @@ -42,8 +47,12 @@ class SignalBase : private boost::noncopyable { return Connection(this, connectionId++); } - SignalBase() : connectionId(0) {} + SignalBase(Application *application0) : application(application0), connectionId(0) {} virtual ~SignalBase() {} + + Application* getApplication() { + return application; + } }; } -- cgit v1.2.3