F:/Dev-Cpp/Projects/Events System 1.0 Revision/Signals.hpp

Go to the documentation of this file.
00001 #ifndef _Signals
00002 #define _Signals
00003 
00004 #include <map>
00005 #include <string>
00006 #include <queue>
00007 
00008 #include <loki/Singleton.h>
00009 #include "BaseSignal.hpp"
00010 #include "Element.hpp"
00011 #include <windows.h>
00012 #include "Invoker.hpp"
00013 
00014 namespace EventsSystem
00015 {
00016         namespace Signals
00017         {
00018                 class SignalsQueueImpl
00019                 {
00020                 private:
00021                         SignalsQueueImpl() {}
00022                         SignalsQueueImpl(SignalsQueueImpl &) {}
00023                 
00024                         void operator =(SignalsQueueImpl &) {}
00025                         
00026                         std::queue<Interfaces::BaseSignal *> qSingalsQueue;
00027                 public:
00028                         std::map<std::string, Interfaces::BaseSignal *> SignalsList;
00029                 
00030                         inline void raiseSignal(std::string sSignal) { qSingalsQueue.push(SignalsList[sSignal]); }
00031                 
00032                         friend class Loki::CreateUsingNew<SignalsQueueImpl>;
00033                         friend DWORD WINAPI EventsLoop(LPVOID lpParam);
00034                 };
00035                 
00036                 typedef Loki::SingletonHolder<EventsSystem::Signals::SignalsQueueImpl, Loki::CreateUsingNew, Loki::PhoenixSingleton, Loki::ObjectLevelLockable> SignalsQueue;
00037                 
00038                 DWORD WINAPI EventsLoop(LPVOID lpParam)
00039                 {
00040                         EventsSystem::Interfaces::BaseSignal *bsSignal = SignalsQueue::Instance().qSingalsQueue.front();
00041                         
00042                         while ( bsSignal->getSignalType() != "QuitLoop" )
00043                         {
00044                                 if ( bsSignal->getSignalType() != "Wait" )
00045                                 {
00046                                         EventsSystem::Invoker::Instance().getRootElement(*bsSignal).runComponent();
00047                                         SignalsQueue::Instance().qSingalsQueue.pop();
00048                                 }
00049                                 
00050                                 if ( SignalsQueue::Instance().qSingalsQueue.empty() )
00051                                         SignalsQueue::Instance().qSingalsQueue.push(SignalsQueue::Instance().SignalsList["Wait"]);
00052                                         
00053                                 bsSignal = SignalsQueue::Instance().qSingalsQueue.front();
00054                 }
00055         }
00056 }
00057 
00058 #endif

Generated on Thu Apr 13 12:15:07 2006 for Events System by  doxygen 1.4.6-NO