EventBinding.hh
Go to the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_PPI_detail_EventBinding_
00027 #define HH_SENF_PPI_detail_EventBinding_ 1
00028
00029
00030 #include <senf/Scheduler/ClockService.hh>
00031 #include <senf/PPI/predecl.hh>
00032 #include "Callback.hh"
00033
00034
00035
00036
00037 namespace senf {
00038 namespace ppi {
00039 namespace detail {
00040
00042 class EventBindingBase
00043 {
00044 public:
00045 ~EventBindingBase();
00046
00047 EventManager & manager() const;
00048 module::Module & module() const;
00049
00050 protected:
00051 EventBindingBase(EventManager & manager, module::Module & module,
00052 EventDescriptor & descriptor);
00053
00054 void eventTime(ClockService::clock_type time);
00055
00056 private:
00057 EventManager * manager_;
00058 module::Module * module_;
00059 EventDescriptor * descriptor_;
00060
00061 friend class senf::ppi::EventManager;
00062 friend class senf::ppi::EventDescriptor;
00063 };
00064
00067 template <class EventType, class Self>
00068 class EventBindingHelper
00069 {
00070 public:
00071 typedef typename detail::EventArgType<EventType>::type EventArg;
00072
00073 void callback(EventArg event, ClockService::clock_type time);
00074 void callback(EventArg event);
00075
00076 private:
00077 Self & self();
00078 };
00079
00080 #ifndef DOXYGEN
00081
00082 template <class Self>
00083 class EventBindingHelper<void,Self>
00084 {
00085 public:
00086 void callback(ClockService::clock_type time);
00087 void callback();
00088
00089 private:
00090 Self & self();
00091 };
00092
00093 #endif
00094
00096 template <class EventType>
00097 class EventBinding
00098 : public EventBindingBase,
00099 public EventBindingHelper<EventType, EventBinding<EventType> >
00100 {
00101 public:
00102 typedef EventType Event;
00103 typedef typename detail::EventArgType<Event>::type EventArg;
00104 typedef typename detail::Callback<EventArg>::type Callback;
00105
00106 EventBinding(EventManager & manager, module::Module & module, Callback callback,
00107 EventDescriptor & descriptor);
00108
00109 private:
00110 Callback callback_;
00111
00112 friend class EventBindingHelper<EventType, EventBinding<EventType> >;
00113 };
00114
00115 }}}
00116
00117
00118 #include "EventBinding.cci"
00119
00120 #include "EventBinding.cti"
00121 #endif
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132