00001 #ifndef _UNEVT_RegistryDispatcherGlue_H_ // -*-c++-*-
00002
00003 #ifdef __GNUG__
00004 # pragma interface
00005 #endif
00006
00007
00008
00009
00010
00011 #define _UNEVT_RegistryDispatcherGlue_H_
00012
00013 #include <UniEvent/Event.h>
00014 #include <UniEvent/EventPtr.h>
00015 #include <UniEvent/EventPtrT.h>
00016
00017 namespace strmod {
00018 namespace unievent {
00019
00020 class Dispaatcher;
00021 class UnixEventRegistry;
00022
00023 class RegistryDispatcherGlue
00024 {
00025 public:
00026 RegistryDispatcherGlue(Dispatcher *disp, UnixEventRegistry *ureg);
00027 virtual ~RegistryDispatcherGlue();
00028
00029 void doBusyAction();
00030 void doQEmptyAction();
00031
00032 Dispatcher *dispatcher() const { return disp_; }
00033 void dispatcher(Dispatcher *disp);
00034 UnixEventRegistry *eventRegistry() const { return ureg_; }
00035 void eventRegistry(UnixEventRegistry *ureg) { ureg_ = ureg; }
00036
00037 private:
00038 class EmptyEvent : public Event
00039 {
00040 public:
00041 EmptyEvent(RegistryDispatcherGlue *parent) : parent_(parent) { }
00042 virtual ~EmptyEvent() { }
00043
00044 inline virtual void triggerEvent(Dispatcher *dispatcher = 0)
00045 {
00046 if (parent_)
00047 {
00048 parent_->doQEmptyAction();
00049 }
00050 }
00051
00052 void parentGone() { parent_ = 0; }
00053
00054 private:
00055 RegistryDispatcherGlue *parent_;
00056 };
00057 class BusyEvent : public Event
00058 {
00059 public:
00060 BusyEvent(RegistryDispatcherGlue *parent) : parent_(parent) { }
00061 virtual ~BusyEvent() { }
00062
00063 inline virtual void triggerEvent(Dispatcher *dispatcher = 0)
00064 {
00065 if (parent_)
00066 {
00067 parent_->doBusyAction();
00068 }
00069 }
00070
00071 void parentGone() { parent_ = 0; }
00072
00073 private:
00074 RegistryDispatcherGlue *parent_;
00075 };
00076 Dispatcher *disp_;
00077 UnixEventRegistry *ureg_;
00078 EventPtrT<EmptyEvent> emptyev_;
00079 EventPtrT<BusyEvent> busyev_;
00080 };
00081
00082 }
00083 }
00084
00085 #endif