Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

duplicate.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_DUPLICATE_HH
00020 # define QOLYESTER_DAEMON_SET_DUPLICATE_HH 1
00021 
00022 # include <sys/types.h>
00023 # include <set>
00024 # include "utl/timeval.hh"
00025 # include "sch/scheduler.hh"
00026 # include "utl/set.hh"
00027 # include "cst/constants.hh"
00028 # include "net/ipaddress.hh"
00029 
00030 namespace olsr {
00031 
00032   namespace sch {
00033 
00034     class StatePrinter;
00035 
00036   }
00037 
00038   namespace set {
00039 
00040     class DuplicateEntry {
00041       typedef DuplicateEntry            This;
00042       typedef std::set<address_t>       ifaces_t;
00043 
00044       DuplicateEntry();
00045     public:
00046       DuplicateEntry(const address_t& a, u_int16_t s,
00047                      const address_t& i, bool r);
00048 
00049       virtual ~DuplicateEntry() {}
00050 
00051       bool              is_valid() const { return !time_.is_past(); }
00052       const timeval_t&  time() const { return time_; }
00053       void              set_time(const timeval_t& t =
00054                                  timeval_t::in(cst::dup_hold_time)) {
00055         time_ = t;
00056       }
00057 
00058       bool retransmitted() const { return retransmitted_; }
00059       void set_retransmitted() { retransmitted_ = true; }
00060 
00061       ifaces_t&         ifaces() { return ifaces_; }
00062       const ifaces_t&   ifaces() const { return ifaces_; }
00063 
00064       bool in_ifaces(const address_t& a) const;
00065       void add_iface(const address_t& a);
00066       bool operator<(const This& rhs) const;
00067 
00068       static This       make_key(const address_t& a, u_int16_t s);
00069     private:
00070       const address_t   addr_;
00071       const u_int16_t   seqnum_;
00072       bool              retransmitted_;
00073       ifaces_t          ifaces_;
00074       timeval_t         time_;
00075 
00076       static This       dummy_for_find_;
00077 
00078       friend class sch::StatePrinter;
00079     };
00080 
00081     class DuplicateSet {
00082       typedef DuplicateSet                                      This;
00083       typedef sch::Updatable<DuplicateEntry>                    elem_t;
00084       typedef std::set<elem_t>                                  dset_t;
00085       typedef sch::upd::SetEraser<This, dset_t::iterator>       eraser_t;
00086       typedef sch::UpdateEvent<eraser_t>                        updater_t;
00087 
00088       typedef utl::Subset<dset_t,
00089                           utl::NoAction<This, dset_t::iterator>,
00090                           utl::DefaultPredicate<This, dset_t::iterator>,
00091                           This>                                 val_dset_t;
00092     public:
00093       typedef val_dset_t                dupset_t;
00094 
00095       dupset_t& dupset() { return dupset_; }
00096 
00097       DuplicateSet();
00098 
00099       void              insert(const DuplicateEntry& x);
00100       void              erase(const dset_t::iterator& pos);
00101     private:
00102       dset_t    dset_;
00103       dupset_t  dupset_;
00104 
00105       friend class sch::StatePrinter;
00106     };
00107 
00108   } // namespace set
00109 
00110   typedef set::DuplicateSet     dupset_t;
00111   extern dupset_t               dup_set;
00112 
00113 } // namespace olsr
00114 
00115 # ifndef QOLYESTER_DONTINCLUDE_HXX
00116 #  include "duplicate.hxx"
00117 # endif
00118 
00119 #endif // ! QOLYESTER_DAEMON_SET_DUPLICATE_HH

Generated on Thu Jul 28 21:21:46 2005 for Qolyester daemon by  doxygen 1.4.1