ed35f1f32a7c150bc2873c3012333e8fe4864a20
[senf.git] / PPI / Events.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
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.
10 //
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.
15 //
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.
20
21 /** \file
22     \brief Events public header */
23
24 #ifndef HH_Events_
25 #define HH_Events_ 1
26
27 // Custom includes
28
29 //#include "Events.mpp"
30 ///////////////////////////////hh.p////////////////////////////////////////
31
32 namespace senf {
33 namespace ppi {
34
35     /** \brief Generic event interface baseclass
36
37         The EventDescriptor baseclass provides an interface to manipulate events in a generic
38         way. This allows to register events or to temporarily disable event processing.
39      */ 
40     class EventDescriptor
41     {
42     public:
43         bool enabled(); ///< Check, whether the event is currently enabled
44         void enabled(bool); ///< Enable or disable the event
45
46     protected:
47         typedef unspecified CallbackType; ///< Fixed type of the (internal) event handler.
48
49         void register(CallbackType handler); ///< Register the event
50         void unregister(); ///< Unregister the event
51
52     private:
53         virtual void v_register(CallbackType handler) = 0; ///< Called to register the event
54         virtual void v_unregister() = 0; ///< Called to unregister the event
55         virtual void v_enable() = 0;    ///< Called to enable the event delivery
56         virtual void v_disable() = 0;   ///< Called to disable the event delivery
57         virtual void v_process() = 0;   ///< Called whenever the event is signaled
58                                         /**< This virtual method is called \e after every call to
59                                              the event handler to provide a hook for further
60                                              processing (example: calculate the next time, an
61                                              interval timer expires) */
62
63         bool enabled_;
64     };
65
66 }}
67
68 ///////////////////////////////hh.e////////////////////////////////////////
69 //#include "Events.cci"
70 //#include "Events.ct"
71 //#include "Events.cti"
72 #endif
73
74 \f
75 // Local Variables:
76 // mode: c++
77 // fill-column: 100
78 // c-file-style: "senf"
79 // indent-tabs-mode: nil
80 // ispell-local-dictionary: "american"
81 // compile-command: "scons -u test"
82 // End: