2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief Events public header */
28 #include <boost/date_time/posix_time/posix_time_types.hpp>
31 //#include "Events.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
37 // Implementation: The concrete EventDescriptor implementation will need to set things up so
38 // some callback (within the EventDescriptor implementation) will be called when the event
39 // happens. This setup happens in 'v_enable()'. This internal handler sets up an EventType
40 // instance if needed and calls 'callback()'.
42 // 'callback()' will access the EventBinding wrapper to find the user-callback to signal. It
43 // will do any needed internal processing, call that user callback and clean up afterwards.
45 /** \brief Generic event interface baseclass
47 The EventDescriptor baseclass provides an interface to manipulate events in a generic
48 way. This allows to register events or to temporarily disable event processing.
53 virtual ~EventDescriptor();
55 bool enabled(); ///< Check, whether the event is currently enabled
56 void enabled(bool v); ///< Enable or disable the event
62 virtual void v_enable() = 0; ///< Called to enable the event delivery
63 virtual void v_disable() = 0; ///< Called to disable the event delivery
65 virtual bool v_isRegistered() = 0;
67 void notifyThrottle();
68 void notifyUnthrottle();
72 friend class ForwardingRoute;
75 template <class EventType, class Self>
76 class EventImplementationHelper
79 typedef typename detail::EventArgType<EventType>::type EventArg;
81 void callback(EventArg event, boost::posix_time::ptime time);
82 void callback(EventArg event);
85 detail::EventBinding<EventType> & binding();
89 class EventImplementationHelper<void,Self>
92 void callback(boost::posix_time::ptime time);
96 detail::EventBinding<void> & binding();
99 template <class EventType>
100 class EventImplementation
101 : public EventDescriptor,
102 public EventImplementationHelper< EventType, EventImplementation<EventType> >
105 typedef EventType Event;
106 typedef typename detail::EventArgType<EventType>::type EventArg;
109 EventImplementation();
112 virtual bool v_isRegistered();
113 void setBinding(detail::EventBinding<Event> & binding);
115 detail::EventBinding<Event> * binding_;
117 friend class EventManager;
118 friend class EventImplementationHelper< EventType, EventImplementation<EventType> >;
123 ///////////////////////////////hh.e////////////////////////////////////////
124 #include "Events.cci"
125 //#include "Events.ct"
126 #include "Events.cti"
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // comment-column: 40