00001 /* 00002 * EventSwitch.h 00003 * 00004 * Created on: 05.03.2009 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef EVENTSWITCH_H_ 00009 #define EVENTSWITCH_H_ 00010 00011 #include "data/Exceptions.h" 00012 #include "core/Event.h" 00013 #include "core/EventReceiver.h" 00014 #include "utils/Service.h" 00015 #include "utils/Mutex.h" 00016 #include "utils/MutexLock.h" 00017 00018 #include <map> 00019 #include <list> 00020 #include <queue> 00021 00022 using namespace std; 00023 using namespace dtn::exceptions; 00024 00025 namespace dtn 00026 { 00027 namespace exceptions 00028 { 00029 class EventException : public Exception 00030 { 00031 00032 }; 00033 00034 class NoSuchEventException : public EventException 00035 { 00036 00037 }; 00038 } 00039 00040 namespace core 00041 { 00042 class EventSwitch //: public dtn::utils::Service 00043 { 00044 private: 00045 EventSwitch(); 00046 ~EventSwitch(); 00047 static EventSwitch& getInstance(); 00048 00049 map<string,list<EventReceiver*> > m_list; 00050 queue<Event*> m_queue; 00051 dtn::utils::Mutex m_queuelock; 00052 00053 void direct(const Event *evt); 00054 // void push(Event *evt); 00055 // void private_flush(); 00056 00057 protected: 00058 void terminate(); 00059 void tick(); 00060 00061 public: 00062 static void registerEventReceiver(string eventName, EventReceiver *receiver); 00063 static void unregisterEventReceiver(string eventName, EventReceiver *receiver); 00064 static void raiseEvent(Event *evt); 00065 // static void flush(); 00066 // static void shutdown(); 00067 }; 00068 } 00069 } 00070 00071 #endif /* EVENTSWITCH_H_ */
1.5.6