4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief SignalDispatcher public header */
26 #ifndef HH_SignalDispatcher_
27 #define HH_SignalDispatcher_ 1
31 #include <boost/function.hpp>
32 #include "FIFORunner.hh"
33 #include "../boost/intrusive/iset_hook.hpp"
35 //#include "SignalEvent.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
46 typedef boost::intrusive::iset_base_hook<SignalSetTag> SignalSetBase;
47 struct SignalSetCompare;
48 struct FindNumericSignal;
49 struct SignalDispatcher;
52 /** \brief UNIX signal event
54 The SignalEvent class registers a callback for UNIX signals. The callback will be called \e
55 synchronously (not from within the UNIX signal handler) by the scheduler.
57 The SignalEvent class is an implementation of the RAII idiom: The event will be
58 automatically unregistered in the SignalEvent destructor. The SignalEvent instance should be
59 created within the same scope or on a scope below where the callback is defined (e.g. if the
60 callback is a member function it should be defined as a class member).
63 : public detail::FIFORunner::TaskInfo,
64 public detail::SignalSetBase
67 ///////////////////////////////////////////////////////////////////////////
70 typedef boost::function<void (siginfo_t const &)> Callback;
73 ///////////////////////////////////////////////////////////////////////////
74 ///\name Structors and default members
77 SignalEvent(int signal, Callback const & cb, bool initiallyEnabled=true);
78 ///< Register a signal event
79 /**< Registers \a cb as callback for the UNIX signal \a
80 signal. If \a initiallyEnabled is set \c false, the
81 callback will not be enabled automatically. Use
83 \param[in] signal UNIX signal to register callback for
84 \param[in] cb Callback to call
85 \param[in] initiallyEnabled if set \c false, do not
86 enable callback automatically. */
90 ///////////////////////////////////////////////////////////////////////////
92 void disable(); ///< Enable signal event registration
93 void enable(); ///< Disable the signal event registration
95 void action(Callback const & cb); ///< Change signal event callback
99 virtual char const * v_type() const;
100 virtual std::string v_info() const;
106 friend class detail::SignalSetCompare;
107 friend class detail::FindNumericSignal;
108 friend class detail::SignalDispatcher;
114 ///////////////////////////////hh.e////////////////////////////////////////
115 #include "SignalEvent.cci"
116 //#include "SignalEvent.ct"
117 //#include "SignalEvent.cti"
124 // comment-column: 40
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"