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_TOPOLOGY_HH 00020 # define QOLYESTER_DAEMON_SET_TOPOLOGY_HH 1 00021 00022 # include <sys/types.h> 00023 00024 # include "net/ipaddress.hh" 00025 # include "sch/scheduler.hh" 00026 # include "utl/seqnum.hh" 00027 # include "utl/set.hh" 00028 # include "utl/timeval.hh" 00029 00030 namespace olsr { 00031 00032 namespace sch { 00033 00034 class StatePrinter; 00035 00036 } 00037 00038 namespace set { 00039 00040 class TopologyEntry { 00041 typedef TopologyEntry This; 00042 inline TopologyEntry(); 00043 public: 00044 inline TopologyEntry(const address_t& d, const address_t& l, 00045 u_int16_t sn, const timeval_t& v); 00046 00047 virtual ~TopologyEntry() {} 00048 00049 const address_t& dest_addr() const { return daddr_; } 00050 const address_t& last_addr() const { return laddr_; } 00051 utl::Seqnum<u_int16_t> seqnum() const { return seqnum_; } 00052 const timeval_t& time() const { return time_; } 00053 00054 inline bool is_valid() const; 00055 inline void set_time(const timeval_t& t); 00056 inline bool operator<(const This& rhs) const; 00057 00058 static inline const This& make_key(const address_t& l); 00059 private: 00060 const address_t daddr_; 00061 const address_t laddr_; 00062 utl::Seqnum<u_int16_t> seqnum_; 00063 timeval_t time_; 00064 00065 static This dummy_for_find_; 00066 00067 friend class sch::StatePrinter; 00068 }; 00069 00070 class TopologySet { 00071 typedef TopologySet This; 00072 typedef sch::Updatable<TopologyEntry> elem_t; 00073 typedef std::multiset<elem_t> tset_t; 00074 typedef sch::upd::SetEraser<This, tset_t::iterator> eraser_t; 00075 typedef sch::UpdateEvent<eraser_t> updater_t; 00076 00077 typedef utl::Subset<utl::MultiAdapt<tset_t>, 00078 utl::NoAction<This, tset_t::iterator>, 00079 utl::DefaultPredicate<This, tset_t::iterator>, 00080 This> val_tset_t; 00081 public: 00082 typedef val_tset_t toposet_t; 00083 00084 toposet_t& toposet() { return toposet_; } 00085 00086 inline TopologySet(); 00087 00088 inline void insert(const TopologyEntry& x); 00089 inline void erase(const tset_t::iterator& pos); 00090 private: 00091 tset_t tset_; 00092 toposet_t toposet_; 00093 00094 friend class sch::StatePrinter; 00095 }; 00096 00097 } // namespace set 00098 00099 typedef set::TopologySet toposet_t; 00100 00101 } // namespace olsr 00102 00103 # include "topology.hxx" 00104 00105 #endif // ! QOLYESTER_DAEMON_SET_TOPOLOGY_HH