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

topology.hxx

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_TOPOLOGY_HXX
00020 # define QOLYESTER_DAEMON_SET_TOPOLOGY_HXX 1
00021 
00022 # include "gra/graph.hh"
00023 # include "set/neighbors.hh"
00024 
00025 # include "topology.hh"
00026 
00027 namespace olsr {
00028 
00029   extern sched_t        scheduler;
00030   extern pathnet_t      path_net;
00031   extern cproxy_t       cproxy;
00032 
00033   namespace set {
00034 
00035     TopologyEntry::TopologyEntry() :
00036       daddr_(),
00037       laddr_(),
00038       seqnum_(0),
00039       time_(0, 0)
00040     {}
00041   
00042     TopologyEntry::TopologyEntry(const address_t& d, const address_t& l,
00043                                  u_int16_t sn, const timeval_t& v) :
00044       daddr_(d),
00045       laddr_(l),
00046       seqnum_(sn),
00047       time_(timeval_t::in(v))
00048     {}
00049 
00050     bool
00051     TopologyEntry::is_valid() const { return !time_.is_past(); }
00052 
00053     void
00054     TopologyEntry::set_time(const timeval_t& t) { time_ = t; }
00055 
00056     bool
00057     TopologyEntry::operator<(const This& rhs) const {
00058       return laddr_ < rhs.laddr_;
00059     }
00060 
00061     const TopologyEntry&
00062     TopologyEntry::make_key(const address_t& l) {
00063       const_cast<address_t&>(dummy_for_find_.laddr_) = l;
00064       return dummy_for_find_;
00065     }
00066 
00067     TopologySet::TopologySet()
00068       : tset_(),
00069         toposet_(*this, tset_)
00070     {}
00071 
00072     void
00073     TopologySet::insert(const TopologyEntry& x) {
00074       tset_t::iterator  pos = tset_.insert(x);
00075 
00076       sch::TimedEvent*  e = new updater_t(x.time(), eraser_t(*this, pos));
00077       const_cast<elem_t&>(*pos).set_updater(e);
00078       scheduler.insert(e);
00079 
00080       path_net.insert_node(gra::AdjNode(x.last_addr()));
00081       path_net.insert_node(gra::AdjNode(x.dest_addr()));
00082       path_net.insert_arc(gra::AdjInfo(x.last_addr(), x.dest_addr(), topo));
00083       routes_recomp.set_mark();
00084     }
00085 
00086     void
00087     TopologySet::erase(const tset_t::iterator& pos) {
00088       path_net.remove_arc(gra::AdjInfo::make_key(pos->last_addr(),
00089                                                  pos->dest_addr(),
00090                                                  topo));
00091       if (cproxy.sym_neighborset().find(Neighbor::make_key(pos->last_addr())) ==
00092           cproxy.sym_neighborset().end())
00093         path_net.remove_node_if_alone(gra::AdjNode::make_key(pos->last_addr()));
00094       if (cproxy.sym_neighborset().find(Neighbor::make_key(pos->dest_addr())) ==
00095           cproxy.sym_neighborset().end())
00096         path_net.remove_node_if_alone(gra::AdjNode::make_key(pos->dest_addr()));
00097 //       del_set.erase(pos->del_pos());
00098 
00099       sch::TimedEvent*  e = pos->updater();
00100       tset_.erase(pos);
00101       scheduler.destroy(e);
00102       routes_recomp.set_mark();
00103     }
00104 
00105   } // namespace set
00106 
00107 } // namespace olsr
00108 
00109 #endif // ! QOLYESTER_DAEMON_SET_TOPOLOGY_HXX

Generated on Thu Dec 8 01:24:38 2005 for Qolyester daemon by  doxygen 1.4.3-20050530