Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

SignalEvent.hh

Go to the documentation of this file.
00001 // $Id: SignalEvent.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Scheduler_SignalEvent_
00027 #define HH_SENF_Scheduler_SignalEvent_ 1
00028 
00029 // Custom includes
00030 #include <signal.h>
00031 #include <boost/function.hpp>
00032 #include "FIFORunner.hh"
00033 #include <senf/boost_intrusive/iset_hook.hpp>
00034 
00035 //#include "SignalEvent.mpp"
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 
00038 namespace senf {
00039 
00040     class Scheduler;
00041 
00042 namespace scheduler {
00043 
00044     namespace detail {
00045         struct SignalSetTag;
00046         typedef boost::intrusive::iset_base_hook<SignalSetTag> SignalSetBase;
00047         struct SignalSetCompare;
00048         struct FindNumericSignal;
00049         struct SignalDispatcher;
00050     }
00051 
00062     class SignalEvent
00063         : public detail::FIFORunner::TaskInfo,
00064           public detail::SignalSetBase
00065     {
00066     public:
00067         //-////////////////////////////////////////////////////////////////////////
00068         // Types
00069 
00070         typedef boost::function<void (siginfo_t const &)> Callback;
00072 
00073         //-////////////////////////////////////////////////////////////////////////
00075         //\{
00076 
00077         SignalEvent(int signal, Callback const & cb, bool initiallyEnabled=true);
00079 
00087         ~SignalEvent();
00088 
00089         //\}
00090         //-////////////////////////////////////////////////////////////////////////
00091 
00092         void disable();                 
00093         void enable();                  
00094 
00095         void action(Callback const & cb); 
00096 
00097     private:
00098         virtual void v_run();
00099         virtual char const * v_type() const;
00100         virtual std::string v_info() const;
00101 
00102         int signal_;
00103         Callback cb_;
00104         siginfo_t siginfo_;
00105 
00106         friend class detail::SignalSetCompare;
00107         friend class detail::FindNumericSignal;
00108         friend class detail::SignalDispatcher;
00109     };
00110 
00111 
00112 }}
00113 
00114 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00115 #include "SignalEvent.cci"
00116 //#include "SignalEvent.ct"
00117 //#include "SignalEvent.cti"
00118 #endif
00119 
00120 
00121 // Local Variables:
00122 // mode: c++
00123 // fill-column: 100
00124 // comment-column: 40
00125 // c-file-style: "senf"
00126 // indent-tabs-mode: nil
00127 // ispell-local-dictionary: "american"
00128 // compile-command: "scons -u test"
00129 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research