hna.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 #ifndef QOLYESTER_DAEMON_SET_HNA_HH
00020 # define QOLYESTER_DAEMON_SET_HNA_HH 1
00021 
00022 # include <set>
00023 # include "sch/scheduler.hh"
00024 # include "utl/timeval.hh"
00025 # include "utl/set.hh"
00026 # include "net/ipaddress.hh"
00027 
00028 namespace olsr {
00029 
00030   namespace sch {
00031 
00032     class StatePrinter;
00033 
00034   }
00035 
00036   namespace set {
00037 
00038     class HNAEntry {
00039       typedef HNAEntry  This;
00040 
00041       inline HNAEntry();
00042     public:
00043       inline HNAEntry(const address_t& gaddr,
00044                       const address_t& naddr,
00045                       unsigned prefix,
00046                       const timeval_t& v);
00047 
00048       virtual ~HNAEntry() {}
00049 
00050       const address_t&  gw_addr()       const { return g_addr_; }
00051       const address_t&  net_addr()      const { return n_addr_; }
00052       unsigned          prefix()        const { return prefix_; }
00053       inline bool       is_valid()      const;
00054       inline void       set_time(const timeval_t& t);
00055       const timeval_t&  time() const { return time_; }
00056 
00057       inline bool       operator<(const This& rhs) const;
00058       static inline This        make_key(const address_t& gaddr,
00059                                          const address_t& naddr,
00060                                          unsigned prefix);
00061     private:
00062       const address_t   g_addr_;
00063       const address_t   n_addr_;
00064       const unsigned    prefix_;
00065       timeval_t time_;
00066 
00067       static This       dummy_for_find_;
00068 
00069       friend class sch::StatePrinter;
00070     };
00071 
00072     class HNASet {
00073       typedef HNASet                                            This;
00074       typedef sch::Updatable<HNAEntry>                          elem_t;
00075       typedef std::set<elem_t>                                  hset_t;
00076       typedef sch::upd::SetEraser<This, hset_t::iterator>       eraser_t;
00077       typedef sch::UpdateEvent<eraser_t>                        updater_t;
00078 
00079       typedef utl::Subset<hset_t,
00080                           utl::NoAction<This, hset_t::iterator>,
00081                           utl::DefaultPredicate<This, hset_t::iterator>,
00082                           This> val_hset_t;
00083     public:
00084       typedef val_hset_t        hnaset_t;
00085 
00086       hnaset_t& hnaset() { return hnaset_; }
00087 
00088       inline HNASet();
00089 
00090       inline void       insert(const HNAEntry& x);
00091       inline void       erase(const hset_t::iterator& pos);
00092     private:
00093       hset_t    hset_;
00094       hnaset_t  hnaset_;
00095 
00096       friend class sch::StatePrinter;
00097     };
00098 
00099   } // namespace set
00100 
00101   typedef set::HNASet   hnaset_t;
00102 
00103 } // namespace olsr
00104 
00105 # include "hna.hxx"
00106 
00107 #endif // ! QOLYESTER_DAEMON_SET_HNA_HH

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