events.hh

Go to the documentation of this file.
00001 // Copyright (C) 2003, 2004, 2005 Laboratoire de Recherche en Informatique
00002 
00003 // This file is part of Qolyester.
00004 
00005 // Qolyester is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 // Qolyester is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00019 #include "net/interface.hh"
00020 #include "msg/hna.hh"
00021 #include "msg/mid.hh"
00022 
00023 #ifndef QOLYESTER_DAEMON_SCH_EVENTS_HH
00024 # define QOLYESTER_DAEMON_SCH_EVENTS_HH 1
00025 
00026 # include <queue>
00027 # include "msg/hello.hh"
00028 # include "msg/tc.hh"
00029 # include "pkt/packet.hh"
00030 # include "sch/scheduler.hh"
00031 
00032 namespace olsr {
00033 
00034   namespace sch {
00035 
00036     namespace internal {
00037 
00038       template <class M>
00039       struct sender_traits {};
00040 
00041 # define SENDER_TRAITS(Msg, Id) \
00042       template <> struct sender_traits<msg::Msg ## Message> { \
00043         static const timeval_t& interval; \
00044         static const timeval_t  in_jitter; \
00045         static const timeval_t& maxjitter; \
00046         static const std::string name; \
00047       }
00048 
00049       SENDER_TRAITS(HELLO, hello);
00050       SENDER_TRAITS(TC, tc);
00051       SENDER_TRAITS(MID, mid);
00052       SENDER_TRAITS(HNA, hna);
00053 
00054 # undef SENDER_TRAITS
00055 
00056     } // namespace internal
00057 
00058     template <class M>
00059     class MessageSender : public JitteredEvent {
00060       typedef MessageSender<M>  This;
00061       typedef JitteredEvent     Super;
00062     public:
00063       inline MessageSender();
00064       virtual inline void       handle();
00065     };
00066 
00067     template <>
00068     class MessageSender<msg::TCMessage> : public JitteredEvent {
00069       typedef MessageSender<msg::TCMessage>     This;
00070       typedef JitteredEvent                     Super;
00071     public:
00072       inline MessageSender();
00073       virtual inline void       handle();
00074     };
00075 
00076     class MessageForwarder : public TimedEvent {
00077       typedef MessageForwarder  This;
00078       typedef TimedEvent        Super;
00079       inline MessageForwarder(const This&);
00080     public:
00081       inline MessageForwarder(const timeval_t& n,
00082                               const msg::UnknownMessage& m);
00083       inline ~MessageForwarder();
00084       virtual inline void       handle();
00085     private:
00086       msg::UnknownMessage*      message_;
00087     };
00088 
00089     class StatePrinter : public PeriodicEvent {
00090       typedef StatePrinter      This;
00091       typedef PeriodicEvent     Super;
00092     public:
00093       inline StatePrinter();
00094       virtual inline void       handle();
00095     };
00096 
00097     class PacketSender : public IOEvent {
00098       typedef PacketSender              This;
00099       typedef IOEvent                   Super;
00100       typedef std::queue<pkt::Packet>   pqueue_t;
00101     public:
00102       inline PacketSender(iface_t* i, const pkt::Packet& p);
00103       virtual inline void       handle();
00104       inline void               push_packet(const pkt::Packet& p);
00105     private:
00106       iface_t*          iface_;
00107       pqueue_t          packets_;
00108     };
00109 
00110     class PacketReceiver : public IOEvent {
00111       typedef PacketReceiver    This;
00112       typedef IOEvent           Super;
00113     public:
00114       inline PacketReceiver(iface_t* i);
00115       virtual inline void       handle();
00116     private:
00117       iface_t*  iface_;
00118     };
00119 
00120     class QolyesterLoopHandler : public LoopHandler {
00121       typedef QolyesterLoopHandler      This;
00122       typedef LoopHandler               Super;
00123     public:
00124       virtual inline bool       operator()() const;
00125     private:
00126     };
00127 
00128     inline void remove_routes();
00129 
00130   } // namespace sch
00131 
00132 } // namespace olsr
00133 
00134 # include "events.hxx"
00135 
00136 #endif // !QOLYESTER_DAEMON_SCH_EVENTS_HH

Generated on Mon Sep 10 17:02:11 2007 for Qolyester daemon by  doxygen 1.5.1