X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FEvents.hh;h=cb21dd7c9a4c2d0884b13293c50f661ceee48afd;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=154beba620804f0c13530aefa642ef4a660da07b;hpb=145f6a7d0f3a6aaa77b3625351c952d24cb0b8a1;p=senf.git diff --git a/PPI/Events.hh b/PPI/Events.hh index 154beba..cb21dd7 100644 --- a/PPI/Events.hh +++ b/PPI/Events.hh @@ -25,6 +25,8 @@ #define HH_Events_ 1 // Custom includes +#include +#include "predecl.hh" //#include "Events.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -32,6 +34,14 @@ namespace senf { namespace ppi { + // Implementation: The concrete EventDescriptor implementation will need to set things up so + // some callback (within the EventDescriptor implementation) will be called when the event + // happens. This setup happens in 'v_enable()'. This internal handler sets up an EventType + // instance if needed and calls 'callback()'. + // + // 'callback()' will access the EventBinding wrapper to find the user-callback to signal. It + // will do any needed internal processing, call that user callback and clean up afterwards. + /** \brief Generic event interface baseclass The EventDescriptor baseclass provides an interface to manipulate events in a generic @@ -40,35 +50,52 @@ namespace ppi { class EventDescriptor { public: + virtual ~EventDescriptor(); + bool enabled(); ///< Check, whether the event is currently enabled - void enabled(bool); ///< Enable or disable the event + void enabled(bool v); ///< Enable or disable the event protected: - typedef unspecified CallbackType; ///< Fixed type of the (internal) event handler. - - void register(CallbackType handler); ///< Register the event - void unregister(); ///< Unregister the event + EventDescriptor(); private: - virtual void v_register(CallbackType handler) = 0; ///< Called to register the event - virtual void v_unregister() = 0; ///< Called to unregister the event virtual void v_enable() = 0; ///< Called to enable the event delivery virtual void v_disable() = 0; ///< Called to disable the event delivery - virtual void v_process() = 0; ///< Called whenever the event is signaled - /**< This virtual method is called \e after every call to - the event handler to provide a hook for further - processing (example: calculate the next time, an - interval timer expires) */ + + virtual bool v_isRegistered() = 0; bool enabled_; }; + template + class EventImplementation + : public EventDescriptor + { + public: + typedef EventType Event; + typedef typename detail::EventArgType::type EventArg; + + protected: + EventImplementation(); + + void callback(EventArg event, boost::posix_time::ptime time); + void callback(EventArg event); + + private: + virtual bool v_isRegistered(); + void setBinding(detail::EventBinding & binding); + + detail::EventBinding * binding_; + + friend class EventManager; + }; + }} ///////////////////////////////hh.e//////////////////////////////////////// -//#include "Events.cci" +#include "Events.cci" //#include "Events.ct" -//#include "Events.cti" +#include "Events.cti" #endif