00001 #ifndef _UNEVT_SimpleDispatcher_H_ // -*-c++-*-
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __GNUG__
00022 # pragma interface
00023 #endif
00024
00025
00026
00027
00028
00029 #include <UniEvent/Dispatcher.h>
00030
00031 #define _UNEVT_SimpleDispatcher_H_
00032
00033 namespace strmod {
00034 namespace unievent {
00035
00036 class Event;
00037
00038
00039
00040
00041
00042 class SimpleDispatcher : public Dispatcher
00043 {
00044 public:
00045 static const UNEVT_ClassIdent identifier;
00046
00047
00048 SimpleDispatcher();
00049
00050 virtual ~SimpleDispatcher();
00051
00052 inline virtual int AreYouA(const lcore::ClassIdent &cid) const;
00053
00054 virtual void addEvent(const EventPtr &ev);
00055
00056 virtual void dispatchEvents(unsigned int numevents,
00057 Dispatcher *enclosing = 0);
00058 virtual void dispatchUntilEmpty(Dispatcher *enclosing = 0);
00059 inline virtual void stopDispatching();
00060 virtual void interrupt();
00061
00062 virtual bool isQueueEmpty() const;
00063
00064 virtual void addBusyPollEvent(const EventPtr &ev);
00065 virtual bool onQueueEmpty(const EventPtr &ev);
00066 virtual bool onInterrupt(const EventPtr &ev);
00067
00068 protected:
00069 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; }
00070
00071 private:
00072 class Imp;
00073 Imp &imp_;
00074 bool stop_flag_;
00075
00076 inline void i_DispatchEvent(Imp &imp, Dispatcher *enclosing);
00077 unsigned int i_dispatchNEvents(unsigned int n, bool checkbusypoll,
00078 Dispatcher *enclosing);
00079 inline unsigned int checkEmptyBusy(Imp &imp, bool &checkbusy);
00080 void dispatchNEvents(unsigned int n, Dispatcher *enclosing);
00081
00082
00083 SimpleDispatcher(const SimpleDispatcher &b);
00084 const SimpleDispatcher &operator =(const SimpleDispatcher &b);
00085 };
00086
00087
00088
00089 inline int SimpleDispatcher::AreYouA(const lcore::ClassIdent &cid) const
00090 {
00091 return((identifier == cid) || Dispatcher::AreYouA(cid));
00092 }
00093
00094 void SimpleDispatcher::stopDispatching()
00095 {
00096 stop_flag_ = true;
00097 }
00098
00099 };
00100 };
00101
00102 #endif