Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > d9faa203c2b0b6fbb179d93daaea81b7 > files > 708

libdtn-devel-2.6.0-1mdv2009.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: Table.cc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<h1>Table.cc</h1><a href="Table_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2007 Baylor University</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="prophet_2Dictionary_8h.html">Dictionary.h</a>"</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="Table_8h.html">Table.h</a>"</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keyword">namespace </span>prophet
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022 
<a name="l00023"></a><a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">00023</a> <span class="preprocessor">#define MIN_LENGTH (strlen("dtn://"))</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a><a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">00025</a> <span class="preprocessor">#define LOG_LT_MIN_LENGTH core_-&gt;print_log(name_.c_str(),BundleCore::LOG_ERR, \</span>
<a name="l00026"></a>00026 <span class="preprocessor">            "destination id is shorter than required minimum @ %s:%d", \</span>
<a name="l00027"></a>00027 <span class="preprocessor">            __FILE__, __LINE__)</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a><a class="code" href="classprophet_1_1Table.html#ce73a48d847fc6b7ad291ec82bd6c80b">00029</a> <a class="code" href="classprophet_1_1Table.html#ce73a48d847fc6b7ad291ec82bd6c80b" title="Default constructor.">Table::Table</a>(<a class="code" href="classprophet_1_1BundleCore.html" title="Prophet facade&amp;#39;s abstract interface into DTN host&amp;#39;s bundle core.">BundleCore</a>* core,
<a name="l00030"></a>00030              <span class="keyword">const</span> std::string&amp; name,
<a name="l00031"></a>00031              <span class="keywordtype">bool</span> persistent)
<a name="l00032"></a>00032     : core_(core), persistent_(persistent), name_(name), max_route_(0)
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="classprophet_1_1Table.html#39a5d9198b9829f45d2aaf128b93ebd4">00036</a> Table::Table(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>&amp; t)
<a name="l00037"></a>00037     : core_(t.core_), persistent_(t.persistent_),
<a name="l00038"></a>00038       name_(t.name_), max_route_(0)
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin();
<a name="l00041"></a>00041     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1Table.html#a2f4bc33f615e318215dc60b48447a5d">const_iterator</a> c = t.<a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin();
<a name="l00042"></a>00042             c != t.<a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end();
<a name="l00043"></a>00043             c++)
<a name="l00044"></a>00044     {
<a name="l00045"></a>00045         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a> *n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(*(c-&gt;second));
<a name="l00046"></a>00046         i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.insert(i,rib_table::value_type(c-&gt;first,n));
<a name="l00047"></a>00047         <span class="comment">// keep track of min-heap for quota-enforcement</span>
<a name="l00048"></a>00048         <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00049"></a>00049     }
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="classprophet_1_1Table.html#d530eae364964bb99f44582d5dc2e06f">00052</a> <a class="code" href="classprophet_1_1Table.html#d530eae364964bb99f44582d5dc2e06f" title="Destructor.">Table::~Table</a>()
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054     <a class="code" href="classprophet_1_1Table.html#5acac2d4bc869643d71266c2ba388015" title="Clean up memory pointed to by each Node*.">free</a>();
<a name="l00055"></a>00055     <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.clear();
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a><a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911">00058</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">Table::heap_add</a>(<a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n) {
<a name="l00059"></a>00059     <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#c80802c5b5edf1998b023b6323ae8b3d" title="Add data to heap, return index of insertion point.">add</a>(n);
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="keywordtype">void</span>
<a name="l00063"></a><a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d">00063</a> <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">Table::heap_del</a>(<a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n) {
<a name="l00064"></a>00064     <span class="comment">// first make sure we're picking off the right victim</span>
<a name="l00065"></a>00065     <span class="keywordtype">size_t</span> pos = n-&gt;<a class="code" href="classprophet_1_1Node.html#e53ea58de68128e0b384f24d19265525" title="heap index used by Table">heap_pos_</a>;
<a name="l00066"></a>00066     <span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>*  old_n;
<a name="l00067"></a>00067     <span class="keywordflow">if</span> (pos &lt; <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#24f75e9aa275c8a12feea2c630603bd6" title="Return number of elements in underlying sequence.">size</a>())
<a name="l00068"></a>00068     {
<a name="l00069"></a>00069         old_n = <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#29f17eeee1c6569552023e544073031c" title="Constant reference to underlying sequence.">sequence</a>()[pos];
<a name="l00070"></a>00070         <span class="keywordflow">if</span> (old_n-&gt;<a class="code" href="classprophet_1_1Node.html#37978147b84bbb9bd2cb9b0135620fd9" title="string representation of route to node">dest_id_</a> == n-&gt;<a class="code" href="classprophet_1_1Node.html#37978147b84bbb9bd2cb9b0135620fd9" title="string representation of route to node">dest_id_</a>)
<a name="l00071"></a>00071             <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#20d319981c5585b49f388b5a9d6afadb" title="Remove element from heap by position, re-heap remaining elements.">remove</a>(pos);
<a name="l00072"></a>00072     }
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>*
<a name="l00076"></a><a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef">00076</a> <a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">Table::find</a>(<span class="keyword">const</span> std::string&amp; dest_id)<span class="keyword"> const</span>
<a name="l00077"></a>00077 <span class="keyword"></span>{
<a name="l00078"></a>00078     <span class="keywordflow">if</span> (dest_id.length() &gt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00079"></a>00079     {
<a name="l00080"></a>00080         <a class="code" href="classprophet_1_1Table.html#a2f4bc33f615e318215dc60b48447a5d">const_iterator</a> it = (<a class="code" href="classprophet_1_1Table.html#a2f4bc33f615e318215dc60b48447a5d">const_iterator</a>) <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.find(dest_id);
<a name="l00081"></a>00081         <span class="keywordflow">if</span> (it != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end())
<a name="l00082"></a>00082             <span class="keywordflow">return</span> (*it).second;
<a name="l00083"></a>00083     }
<a name="l00084"></a>00084     <span class="keywordflow">else</span>
<a name="l00085"></a>00085         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00086"></a>00086     <span class="keywordflow">return</span> NULL;
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="keywordtype">double</span>
<a name="l00090"></a><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe">00090</a> <a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">Table::p_value</a>(<span class="keyword">const</span> std::string&amp; dest_id)<span class="keyword"> const</span>
<a name="l00091"></a>00091 <span class="keyword"></span>{
<a name="l00092"></a>00092     <span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = <a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(dest_id);
<a name="l00093"></a>00093     <span class="keywordflow">if</span> (n == NULL)
<a name="l00094"></a>00094         <span class="keywordflow">return</span> 0.0;
<a name="l00095"></a>00095 
<a name="l00096"></a>00096     <span class="keywordflow">return</span> n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>();
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 <span class="keywordtype">double</span>
<a name="l00100"></a><a class="code" href="classprophet_1_1Table.html#4be56a2157f7d7e8ba44548dde2c6a8f">00100</a> <a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">Table::p_value</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&amp;#39;s Bundle representation...">Bundle</a>* b)<span class="keyword"> const</span>
<a name="l00101"></a>00101 <span class="keyword"></span>{
<a name="l00102"></a>00102     std::string dest = b-&gt;<a class="code" href="classprophet_1_1Bundle.html#81f0a95589809a157829bacb4d3c5989" title="Accessors.">destination_id</a>();
<a name="l00103"></a>00103     std::string route = <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#5ee789c3c5a49bbcb0624658e7f524c6" title="Given a Bundle&amp;#39;s destination, return the route.">get_route</a>(dest);
<a name="l00104"></a>00104     <span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = <a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(route);
<a name="l00105"></a>00105     <span class="keywordflow">if</span> (n == NULL)
<a name="l00106"></a>00106         <span class="keywordflow">return</span> 0.0;
<a name="l00107"></a>00107 
<a name="l00108"></a>00108     <span class="keywordflow">return</span> n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>();
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 <span class="keywordtype">void</span>
<a name="l00112"></a><a class="code" href="classprophet_1_1Table.html#8dbc9e921c25d19231b5efe7772cd048">00112</a> <a class="code" href="classprophet_1_1Table.html#8dbc9e921c25d19231b5efe7772cd048" title="Table takes ownership of memory pointed to by Node*, updating its member list (replacing...">Table::update</a>(<a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n)
<a name="l00113"></a>00113 {
<a name="l00114"></a>00114     <span class="keywordflow">if</span> (n == NULL ||
<a name="l00115"></a>00115         strlen(n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>()) &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00116"></a>00116     {
<a name="l00117"></a>00117         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00118"></a>00118         <span class="keywordflow">return</span>;
<a name="l00119"></a>00119     }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121     <span class="comment">// initialize an iterator to point to the insertion</span>
<a name="l00122"></a>00122     <span class="comment">// point for this dest_id</span>
<a name="l00123"></a>00123     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i;
<a name="l00124"></a>00124 
<a name="l00125"></a>00125     <span class="keywordtype">double</span> p_old = 0.0;
<a name="l00126"></a>00126     <span class="comment">// if this dest_id is already known, perform some</span>
<a name="l00127"></a>00127     <span class="comment">// memory management while updating the existing node</span>
<a name="l00128"></a>00128     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(),&amp;i))
<a name="l00129"></a>00129     {
<a name="l00130"></a>00130         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* old = i-&gt;second;
<a name="l00131"></a>00131         p_old = i-&gt;second-&gt;p_value();
<a name="l00132"></a>00132         i-&gt;second = n;
<a name="l00133"></a>00133         <span class="keywordflow">if</span> (n != old) 
<a name="l00134"></a>00134         {
<a name="l00135"></a>00135             <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(old);
<a name="l00136"></a>00136             <span class="keyword">delete</span> old;
<a name="l00137"></a>00137         }
<a name="l00138"></a>00138         <span class="keywordflow">else</span>
<a name="l00139"></a>00139             <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00140"></a>00140     }
<a name="l00141"></a>00141     <span class="comment">// else this is a new dest_id, insert right here</span>
<a name="l00142"></a>00142     <span class="keywordflow">else</span>
<a name="l00143"></a>00143         <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.insert(i,rib_table::value_type(n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(),n));
<a name="l00144"></a>00144 
<a name="l00145"></a>00145     <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00146"></a>00146     <a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca" title="Enforce upper bound by eliminating minimum routes.">enforce_quota</a>();
<a name="l00147"></a>00147 
<a name="l00148"></a>00148     <span class="comment">// log the results</span>
<a name="l00149"></a>00149     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00150"></a>00150             <span class="stringliteral">"updating route %s (%.2f -&gt; %.2f) direct\n"</span>,
<a name="l00151"></a>00151             n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(), p_old, n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>());
<a name="l00152"></a>00152 
<a name="l00153"></a>00153     <span class="comment">// utilize persistent storage as appropriate</span>
<a name="l00154"></a>00154     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&amp;#39;s info.">update_node</a>(n);
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156 
<a name="l00157"></a>00157 <span class="keywordtype">void</span>
<a name="l00158"></a><a class="code" href="classprophet_1_1Table.html#61c5ad124e1840280fd0655356fcb30f">00158</a> <a class="code" href="classprophet_1_1Table.html#61c5ad124e1840280fd0655356fcb30f" title="Convenience function for updating directly-encountered route in table.">Table::update_route</a>(<span class="keyword">const</span> std::string&amp; dest_id,
<a name="l00159"></a>00159                     <span class="keywordtype">bool</span> relay, <span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>, <span class="keywordtype">bool</span> internet)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161     <span class="keywordflow">if</span> (dest_id.length() &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00162"></a>00162     {
<a name="l00163"></a>00163         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00164"></a>00164         <span class="keywordflow">return</span>;
<a name="l00165"></a>00165     }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167     <span class="keywordtype">double</span> p_old = 0.0;
<a name="l00168"></a>00168 
<a name="l00169"></a>00169     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i;
<a name="l00170"></a>00170     <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = NULL;
<a name="l00171"></a>00171     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(dest_id,&amp;i)) 
<a name="l00172"></a>00172     {
<a name="l00173"></a>00173         n = i-&gt;second;
<a name="l00174"></a>00174         p_old = n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>();
<a name="l00175"></a>00175         n-&gt;<a class="code" href="classprophet_1_1Node.html#9365eb7dd51b5d164e40beec48922e22" title="Apply the direct contact algorithm, p.">update_pvalue</a>();
<a name="l00176"></a>00176         n-&gt;<a class="code" href="classprophet_1_1Node.html#3000d74e49497db616a5273a1a9c8b05" title="}">set_relay</a>(relay);
<a name="l00177"></a>00177         n-&gt;<a class="code" href="classprophet_1_1Node.html#8fe7de524be35146a9453473138b9c0f" title="}">set_custody</a>(custody);
<a name="l00178"></a>00178         n-&gt;<a class="code" href="classprophet_1_1Node.html#aded851dec9a724734930e46589113a2" title="}">set_internet_gw</a>(internet);
<a name="l00179"></a>00179         <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00180"></a>00180     }
<a name="l00181"></a>00181     <span class="keywordflow">else</span>
<a name="l00182"></a>00182     {
<a name="l00183"></a>00183         n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(dest_id,relay,custody,internet);
<a name="l00184"></a>00184         n-&gt;<a class="code" href="classprophet_1_1Node.html#9365eb7dd51b5d164e40beec48922e22" title="Apply the direct contact algorithm, p.">update_pvalue</a>();
<a name="l00185"></a>00185         <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.insert(i,rib_table::value_type(dest_id,n));
<a name="l00186"></a>00186     }
<a name="l00187"></a>00187     <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00188"></a>00188     <a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca" title="Enforce upper bound by eliminating minimum routes.">enforce_quota</a>();
<a name="l00189"></a>00189 
<a name="l00190"></a>00190     <span class="comment">// log the results</span>
<a name="l00191"></a>00191     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00192"></a>00192             <span class="stringliteral">"updating route %s (%.2f -&gt; %.2f) direct\n"</span>,
<a name="l00193"></a>00193             n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(), p_old, n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>());
<a name="l00194"></a>00194 
<a name="l00195"></a>00195     <span class="comment">// utilize persistent storage as appropriate</span>
<a name="l00196"></a>00196     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&amp;#39;s info.">update_node</a>(n);
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 <span class="keywordtype">void</span>
<a name="l00200"></a><a class="code" href="classprophet_1_1Table.html#20cab4c11590a5904a541e59b03fc337">00200</a> <a class="code" href="classprophet_1_1Table.html#20cab4c11590a5904a541e59b03fc337" title="Convenience function for updating transitively-discovered route in table.">Table::update_transitive</a>(<span class="keyword">const</span> std::string&amp; dest_id,
<a name="l00201"></a>00201                          <span class="keyword">const</span> std::string&amp; peer_id, <span class="keywordtype">double</span> peer_pvalue,
<a name="l00202"></a>00202                          <span class="keywordtype">bool</span> relay, <span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>, <span class="keywordtype">bool</span> internet)
<a name="l00203"></a>00203 {
<a name="l00204"></a>00204     <span class="keywordflow">if</span> (dest_id.length() &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a> ||
<a name="l00205"></a>00205             peer_id.length() &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00206"></a>00206     {
<a name="l00207"></a>00207         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00208"></a>00208         <span class="keywordflow">return</span>;
<a name="l00209"></a>00209     }
<a name="l00210"></a>00210 
<a name="l00211"></a>00211     <span class="keywordtype">double</span> ab = <a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(peer_id);
<a name="l00212"></a>00212     <span class="keywordtype">double</span> p_old = 0.0;
<a name="l00213"></a>00213     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i;
<a name="l00214"></a>00214     <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = NULL;
<a name="l00215"></a>00215     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(dest_id,&amp;i)) 
<a name="l00216"></a>00216     {
<a name="l00217"></a>00217         n = i-&gt;second;
<a name="l00218"></a>00218         p_old = n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>();
<a name="l00219"></a>00219         n-&gt;<a class="code" href="classprophet_1_1Node.html#8c01707e283dc0c3b69bd4f6786a4cb6" title="Apply transitive algorithm, where ab is p_value from local to peer, bc is p_value...">update_transitive</a>(ab,peer_pvalue);
<a name="l00220"></a>00220         n-&gt;<a class="code" href="classprophet_1_1Node.html#3000d74e49497db616a5273a1a9c8b05" title="}">set_relay</a>(relay);
<a name="l00221"></a>00221         n-&gt;<a class="code" href="classprophet_1_1Node.html#8fe7de524be35146a9453473138b9c0f" title="}">set_custody</a>(custody);
<a name="l00222"></a>00222         n-&gt;<a class="code" href="classprophet_1_1Node.html#aded851dec9a724734930e46589113a2" title="}">set_internet_gw</a>(internet);
<a name="l00223"></a>00223         <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00224"></a>00224     }
<a name="l00225"></a>00225     <span class="keywordflow">else</span>
<a name="l00226"></a>00226     {
<a name="l00227"></a>00227         n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(dest_id,relay,custody,internet);
<a name="l00228"></a>00228         n-&gt;<a class="code" href="classprophet_1_1Node.html#8c01707e283dc0c3b69bd4f6786a4cb6" title="Apply transitive algorithm, where ab is p_value from local to peer, bc is p_value...">update_transitive</a>(ab,peer_pvalue);
<a name="l00229"></a>00229         <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.insert(i,rib_table::value_type(dest_id,n));
<a name="l00230"></a>00230     }
<a name="l00231"></a>00231     <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00232"></a>00232     <a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca" title="Enforce upper bound by eliminating minimum routes.">enforce_quota</a>();
<a name="l00233"></a>00233 
<a name="l00234"></a>00234     <span class="comment">// log the results</span>
<a name="l00235"></a>00235     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00236"></a>00236             <span class="stringliteral">"updating route %s (%.2f -&gt; %.2f) transitive\n"</span>,
<a name="l00237"></a>00237             n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(), p_old, n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>());
<a name="l00238"></a>00238 
<a name="l00239"></a>00239     <span class="comment">// utilize persistent storage as appropriate</span>
<a name="l00240"></a>00240     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&amp;#39;s info.">update_node</a>(n);
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 
<a name="l00243"></a>00243 <span class="keywordtype">void</span>
<a name="l00244"></a><a class="code" href="classprophet_1_1Table.html#430acd99e90a37ff64415038921ca436">00244</a> <a class="code" href="classprophet_1_1Table.html#20cab4c11590a5904a541e59b03fc337" title="Convenience function for updating transitively-discovered route in table.">Table::update_transitive</a>(<span class="keyword">const</span> std::string&amp; peer_id,
<a name="l00245"></a>00245                          <span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">RIBNodeList</a>&amp; rib,
<a name="l00246"></a>00246                          <span class="keyword">const</span> <a class="code" href="classprophet_1_1Dictionary.html" title="Utility class to facilitate converting to and from routing string (endpoint ID) and...">Dictionary</a>&amp;  ribd)
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248     <span class="keywordflow">if</span> (peer_id.length() &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00249"></a>00249     {
<a name="l00250"></a>00250         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00251"></a>00251         <span class="keywordflow">return</span>;
<a name="l00252"></a>00252     }
<a name="l00253"></a>00253 
<a name="l00254"></a>00254     <span class="keywordtype">double</span> ab = <a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(peer_id);
<a name="l00255"></a>00255     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">RIBNodeList::const_iterator</a> i = rib.begin(); i != rib.end(); i++)
<a name="l00256"></a>00256     {
<a name="l00257"></a>00257         <span class="keywordtype">double</span> p_old = 0.0;
<a name="l00258"></a>00258 
<a name="l00259"></a>00259         <span class="keywordflow">if</span> ((*i)-&gt;sid_ == <a class="code" href="classprophet_1_1Dictionary.html#bb335d818c777bf393a25cbbd0661679" title="Reserve 0xffff for in-band error signal.">Dictionary::INVALID_SID</a>)
<a name="l00260"></a>00260             <span class="keywordflow">continue</span>; <span class="comment">// perhaps logging would be appropriate ?</span>
<a name="l00261"></a>00261 
<a name="l00262"></a>00262         std::string eid = ribd.<a class="code" href="classprophet_1_1Dictionary.html#b1cfc06ddc3d8128bbd7d6948a349ae9" title="If dest_id is valid, returns sid; else returns INVALID_SID.">find</a>((*i)-&gt;sid_);
<a name="l00263"></a>00263 
<a name="l00264"></a>00264         <span class="keywordflow">if</span> (eid == <span class="stringliteral">""</span>)
<a name="l00265"></a>00265             <span class="keywordflow">continue</span>; <span class="comment">// perhaps logging would be appropriate ?</span>
<a name="l00266"></a>00266 
<a name="l00267"></a>00267         <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> t;
<a name="l00268"></a>00268         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = NULL;
<a name="l00269"></a>00269         <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(eid,&amp;t)) 
<a name="l00270"></a>00270         {
<a name="l00271"></a>00271             n = t-&gt;second;
<a name="l00272"></a>00272             p_old = n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>();
<a name="l00273"></a>00273             n-&gt;<a class="code" href="classprophet_1_1Node.html#8c01707e283dc0c3b69bd4f6786a4cb6" title="Apply transitive algorithm, where ab is p_value from local to peer, bc is p_value...">update_transitive</a>(ab,(*i)-&gt;p_value());
<a name="l00274"></a>00274             n-&gt;<a class="code" href="classprophet_1_1Node.html#3000d74e49497db616a5273a1a9c8b05" title="}">set_relay</a>((*i)-&gt;relay());
<a name="l00275"></a>00275             n-&gt;<a class="code" href="classprophet_1_1Node.html#8fe7de524be35146a9453473138b9c0f" title="}">set_custody</a>((*i)-&gt;custody());
<a name="l00276"></a>00276             n-&gt;<a class="code" href="classprophet_1_1Node.html#aded851dec9a724734930e46589113a2" title="}">set_internet_gw</a>((*i)-&gt;internet_gw());
<a name="l00277"></a>00277             <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00278"></a>00278         }
<a name="l00279"></a>00279         <span class="keywordflow">else</span>
<a name="l00280"></a>00280         {
<a name="l00281"></a>00281             n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(eid,
<a name="l00282"></a>00282                          (*i)-&gt;relay(),
<a name="l00283"></a>00283                          (*i)-&gt;custody(),
<a name="l00284"></a>00284                          (*i)-&gt;internet_gw());
<a name="l00285"></a>00285             n-&gt;<a class="code" href="classprophet_1_1Node.html#8c01707e283dc0c3b69bd4f6786a4cb6" title="Apply transitive algorithm, where ab is p_value from local to peer, bc is p_value...">update_transitive</a>(ab,(*i)-&gt;p_value());
<a name="l00286"></a>00286             <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.insert(t,rib_table::value_type(eid,n));
<a name="l00287"></a>00287         }
<a name="l00288"></a>00288         <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00289"></a>00289         <a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca" title="Enforce upper bound by eliminating minimum routes.">enforce_quota</a>();
<a name="l00290"></a>00290 
<a name="l00291"></a>00291         <span class="comment">// log the results</span>
<a name="l00292"></a>00292         <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00293"></a>00293                 <span class="stringliteral">"updating route %s (%.2f -&gt; %.2f) transitive\n"</span>,
<a name="l00294"></a>00294                 eid.c_str(), p_old, n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>());
<a name="l00295"></a>00295 
<a name="l00296"></a>00296         <span class="comment">// utilize persistent storage as appropriate</span>
<a name="l00297"></a>00297         <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&amp;#39;s info.">update_node</a>(n);
<a name="l00298"></a>00298     }
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 <span class="keywordtype">size_t</span>
<a name="l00302"></a><a class="code" href="classprophet_1_1Table.html#97dbc037ee1b0e167d97b995cf8b7659">00302</a> <a class="code" href="classprophet_1_1Table.html#97dbc037ee1b0e167d97b995cf8b7659" title="Create duplicate list of Nodes, return number of elements.">Table::clone</a>(<a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">NodeList</a>&amp; list)<span class="keyword"> const</span>
<a name="l00303"></a>00303 <span class="keyword"></span>{
<a name="l00304"></a>00304     <span class="comment">// make sure nothing else is cluttering the incoming list </span>
<a name="l00305"></a>00305     list.<a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>();
<a name="l00306"></a>00306 
<a name="l00307"></a>00307     <span class="keywordtype">size_t</span> num = 0;
<a name="l00308"></a>00308     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1Table.html#a2f4bc33f615e318215dc60b48447a5d">const_iterator</a> i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin(); i != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end(); i++)
<a name="l00309"></a>00309     {
<a name="l00310"></a>00310         <span class="comment">// NodeList assumes ownership of each Node, so allocate</span>
<a name="l00311"></a>00311         <span class="comment">// a new copy</span>
<a name="l00312"></a>00312         list.push_back(<span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(*((*i).second)));
<a name="l00313"></a>00313         <span class="comment">// increment the reported total</span>
<a name="l00314"></a>00314         num++;
<a name="l00315"></a>00315     }
<a name="l00316"></a>00316     <span class="keywordflow">return</span> num;
<a name="l00317"></a>00317 }
<a name="l00318"></a>00318 
<a name="l00319"></a>00319 <span class="keywordtype">size_t</span>
<a name="l00320"></a><a class="code" href="classprophet_1_1Table.html#4bde73fe9f4a477a42619e805e9a4508">00320</a> <a class="code" href="classprophet_1_1Table.html#4bde73fe9f4a477a42619e805e9a4508" title="The predictability of Nodes should diminish with time; to allow for maintenance of...">Table::truncate</a>(<span class="keywordtype">double</span> epsilon) 
<a name="l00321"></a>00321 {
<a name="l00322"></a>00322     <span class="keywordtype">size_t</span> num = 0;
<a name="l00323"></a>00323 
<a name="l00324"></a>00324     <span class="comment">// weed out the oddball case first</span>
<a name="l00325"></a>00325     <span class="keywordflow">if</span> (epsilon &gt;= 1.0)
<a name="l00326"></a>00326     {
<a name="l00327"></a>00327 
<a name="l00328"></a>00328         <span class="comment">// all nodes are goners, so skip the iteration below</span>
<a name="l00329"></a>00329         num = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.size();
<a name="l00330"></a>00330         <a class="code" href="classprophet_1_1Table.html#5acac2d4bc869643d71266c2ba388015" title="Clean up memory pointed to by each Node*.">free</a>();
<a name="l00331"></a>00331         <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.clear();
<a name="l00332"></a>00332 
<a name="l00333"></a>00333         <span class="comment">// most efficient way to clear heap is from the back</span>
<a name="l00334"></a>00334         <span class="keywordtype">size_t</span> pos = <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#24f75e9aa275c8a12feea2c630603bd6" title="Return number of elements in underlying sequence.">size</a>();
<a name="l00335"></a>00335         <span class="keywordflow">while</span> (pos-- &gt; 0)
<a name="l00336"></a>00336             <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#20d319981c5585b49f388b5a9d6afadb" title="Remove element from heap by position, re-heap remaining elements.">remove</a>(pos);
<a name="l00337"></a>00337 
<a name="l00338"></a>00338         <span class="keywordflow">return</span> num;
<a name="l00339"></a>00339     }
<a name="l00340"></a>00340 
<a name="l00341"></a>00341     <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n;
<a name="l00342"></a>00342     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i;
<a name="l00343"></a>00343     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#f9153c0d26efbd93362cc4a572437ee7" title="Return true if underlying sequence is empty.">empty</a>()) {
<a name="l00344"></a>00344         <span class="keywordflow">for</span> (i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin(); i != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end(); i++) {
<a name="l00345"></a>00345             n = (*i).second;
<a name="l00346"></a>00346             <span class="keywordflow">if</span> (n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>() &lt; epsilon) {
<a name="l00347"></a>00347                 <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> j = i++;
<a name="l00348"></a>00348                 <span class="comment">// remove this element and clean up its memory</span>
<a name="l00349"></a>00349                 <span class="keyword">remove</span>(&amp;j);
<a name="l00350"></a>00350                 <span class="comment">// count this removal towards the reported total</span>
<a name="l00351"></a>00351                 num++;
<a name="l00352"></a>00352             } <span class="keywordflow">else</span>
<a name="l00353"></a>00353                 i++;
<a name="l00354"></a>00354         }
<a name="l00355"></a>00355     } <span class="keywordflow">else</span> {
<a name="l00356"></a>00356         n = <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#ed8c35bf71920dcca199adc8f869a8eb" title="Return read-only reference to top of heap.">top</a>();
<a name="l00357"></a>00357         <span class="keywordflow">while</span> (n-&gt;<a class="code" href="classprophet_1_1Node.html#97b1dbf4d60d48b5ffc8d7022a3708b7" title="Accessors.">p_value</a>() &lt; epsilon)
<a name="l00358"></a>00358         {
<a name="l00359"></a>00359             <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(),&amp;i))
<a name="l00360"></a>00360             {
<a name="l00361"></a>00361                 <span class="comment">// remove this element and clean up its memory</span>
<a name="l00362"></a>00362                 <span class="keyword">remove</span>(&amp;i);
<a name="l00363"></a>00363                 <span class="comment">// remove() will pop() from heap, now advance to next lowest</span>
<a name="l00364"></a>00364                 n = <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#ed8c35bf71920dcca199adc8f869a8eb" title="Return read-only reference to top of heap.">top</a>();
<a name="l00365"></a>00365                 <span class="comment">// count this removal in the reported total</span>
<a name="l00366"></a>00366                 num++;
<a name="l00367"></a>00367             }
<a name="l00368"></a>00368             <span class="keywordflow">else</span>
<a name="l00369"></a>00369                 <span class="keywordflow">break</span>;
<a name="l00370"></a>00370         }
<a name="l00371"></a>00371     }
<a name="l00372"></a>00372 
<a name="l00373"></a>00373     <span class="comment">// log the results</span>
<a name="l00374"></a>00374     <span class="keywordflow">if</span> (num &gt; 0)
<a name="l00375"></a>00375     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00376"></a>00376             <span class="stringliteral">"removed %zu routes with p_value &lt; (epsilon %.4f)\n"</span>,
<a name="l00377"></a>00377             num, epsilon);
<a name="l00378"></a>00378 
<a name="l00379"></a>00379     <span class="keywordflow">return</span> num;
<a name="l00380"></a>00380 }
<a name="l00381"></a>00381 
<a name="l00382"></a>00382 <span class="keywordtype">void</span>
<a name="l00383"></a><a class="code" href="classprophet_1_1Table.html#d771f3abdf649a941a4c8fbfbe7a0f42">00383</a> <a class="code" href="classprophet_1_1Table.html#d771f3abdf649a941a4c8fbfbe7a0f42" title="Update Table from peer&amp;#39;s RIB.">Table::assign</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">RIBNodeList</a>&amp; list,
<a name="l00384"></a>00384               <span class="keyword">const</span> <a class="code" href="classprophet_1_1Dictionary.html" title="Utility class to facilitate converting to and from routing string (endpoint ID) and...">Dictionary</a>&amp; ribd)
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">RIBNodeList::const_iterator</a> i = list.begin(); i != list.end(); i++)
<a name="l00387"></a>00387     {
<a name="l00388"></a>00388         std::string eid = ribd.<a class="code" href="classprophet_1_1Dictionary.html#b1cfc06ddc3d8128bbd7d6948a349ae9" title="If dest_id is valid, returns sid; else returns INVALID_SID.">find</a>((*i)-&gt;sid_);
<a name="l00389"></a>00389         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(*(*i));
<a name="l00390"></a>00390         n-&gt;<a class="code" href="classprophet_1_1Node.html#89f3c19b326af535d569e2f2659b599c" title="}">set_dest_id</a>(eid);
<a name="l00391"></a>00391         <a class="code" href="classprophet_1_1Table.html#8dbc9e921c25d19231b5efe7772cd048" title="Table takes ownership of memory pointed to by Node*, updating its member list (replacing...">update</a>(n);
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393 
<a name="l00394"></a>00394     <span class="comment">// log if anything happens</span>
<a name="l00395"></a>00395     <span class="keywordflow">if</span> (list.size() &gt; 0)
<a name="l00396"></a>00396     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00397"></a>00397             <span class="stringliteral">"assigned %zu routes from RIB\n"</span>,
<a name="l00398"></a>00398             list.size());
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400 
<a name="l00401"></a><a class="code" href="classprophet_1_1Table.html#aaf205b6912e863602760cda23cc733e">00401</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Table.html#d771f3abdf649a941a4c8fbfbe7a0f42" title="Update Table from peer&amp;#39;s RIB.">Table::assign</a>(<span class="keyword">const</span> std::list&lt;const Node*&gt;&amp; list, 
<a name="l00402"></a>00402                    <span class="keyword">const</span> <a class="code" href="structprophet_1_1NodeParams.html" title="Tunable parameter struct for setting global default values for Prophet node algorithms...">NodeParams</a>* params)
<a name="l00403"></a>00403 {
<a name="l00404"></a>00404     <span class="comment">// turn off permanent storage updates, since this is coming from storage</span>
<a name="l00405"></a>00405     <span class="keywordtype">bool</span> old = <a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>;
<a name="l00406"></a>00406     <a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a> = <span class="keyword">false</span>;
<a name="l00407"></a>00407     <span class="keywordflow">for</span> (std::list&lt;const Node*&gt;::const_iterator i = list.begin();
<a name="l00408"></a>00408             i != list.end(); i++)
<a name="l00409"></a>00409     {
<a name="l00410"></a>00410         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = <span class="keyword">new</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>(*(*i));
<a name="l00411"></a>00411         n-&gt;<a class="code" href="classprophet_1_1Node.html#81474d8376b1a420f9876cf15af603e6" title="}">set_params</a>(params);
<a name="l00412"></a>00412         <a class="code" href="classprophet_1_1Table.html#8dbc9e921c25d19231b5efe7772cd048" title="Table takes ownership of memory pointed to by Node*, updating its member list (replacing...">update</a>(n);
<a name="l00413"></a>00413     }
<a name="l00414"></a>00414     <a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a> = old;
<a name="l00415"></a>00415 
<a name="l00416"></a>00416     <span class="comment">// log if anything happens</span>
<a name="l00417"></a>00417     <span class="keywordflow">if</span> (list.size() &gt; 0)
<a name="l00418"></a>00418     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00419"></a>00419             <span class="stringliteral">"assigned %zu routes from permanent storage\n"</span>,
<a name="l00420"></a>00420             list.size());
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422 
<a name="l00423"></a>00423 <span class="keywordtype">size_t</span>
<a name="l00424"></a><a class="code" href="classprophet_1_1Table.html#0fb8c279c02261f9b600777b6cadd591">00424</a> <a class="code" href="classprophet_1_1Table.html#0fb8c279c02261f9b600777b6cadd591" title="For maintenance routines, visit each Node in table and invoke its aging algorithm;...">Table::age_nodes</a>()
<a name="l00425"></a>00425 {
<a name="l00426"></a>00426     <span class="keywordtype">size_t</span> num = 0;
<a name="l00427"></a>00427     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin(); i != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end(); i++)
<a name="l00428"></a>00428     {
<a name="l00429"></a>00429         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a> *n = (*i).second;
<a name="l00430"></a>00430         n-&gt;<a class="code" href="classprophet_1_1Node.html#71b04fb6a94d2ad69945624e80185684" title="Routes must decrease predictability with the passing of time, p.">update_age</a>();
<a name="l00431"></a>00431         <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00432"></a>00432         <a class="code" href="classprophet_1_1Table.html#202673f8ec231f35b1e750b8b6430911" title="Add route to heap.">heap_add</a>(n);
<a name="l00433"></a>00433         num++;
<a name="l00434"></a>00434 
<a name="l00435"></a>00435         <span class="comment">// utilize persistent storage as appropriate</span>
<a name="l00436"></a>00436         <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&amp;#39;s info.">update_node</a>(n);
<a name="l00437"></a>00437     }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439     <span class="comment">// log if anything happens</span>
<a name="l00440"></a>00440     <span class="keywordflow">if</span> (num &gt; 0)
<a name="l00441"></a>00441     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00442"></a>00442             <span class="stringliteral">"applied age algorithm to %zu nodes\n"</span>, num);
<a name="l00443"></a>00443 
<a name="l00444"></a>00444     <span class="keywordflow">return</span> num;
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 <span class="keywordtype">void</span>
<a name="l00448"></a><a class="code" href="classprophet_1_1Table.html#0a9f5c816b36df486f60541bdfbd9157">00448</a> <a class="code" href="classprophet_1_1Table.html#0a9f5c816b36df486f60541bdfbd9157" title="Clean up memory and remove pointer from internal map for this element.">Table::remove</a>(<a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a>* i)
<a name="l00449"></a>00449 {
<a name="l00450"></a>00450     <span class="comment">// update persistent storage as appropriate</span>
<a name="l00451"></a>00451     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#f8213d41f401d35a14ee320cb92bb6ec" title="whether to utilize BundleCore&amp;#39;s persistent storage interface for Nodes">persistent_</a>) <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#e799b610b984ebd900dcf1c0bb9e9afc" title="Remove this Node from persistent storage.">delete_node</a>((*i)-&gt;second);
<a name="l00452"></a>00452 
<a name="l00453"></a>00453     <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = (**i).second;
<a name="l00454"></a>00454     <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.erase(*i);
<a name="l00455"></a>00455     <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00456"></a>00456     <span class="keyword">delete</span> n;
<a name="l00457"></a>00457 }
<a name="l00458"></a>00458 
<a name="l00459"></a>00459 <span class="keywordtype">void</span>
<a name="l00460"></a><a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca">00460</a> <a class="code" href="classprophet_1_1Table.html#a634007d67cd85b12f62166ca4db3cca" title="Enforce upper bound by eliminating minimum routes.">Table::enforce_quota</a>()
<a name="l00461"></a>00461 {
<a name="l00462"></a>00462     <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#66e1a17c87be6dcdb044879b61ce29c5" title="upper limit to number of routes to retain">max_route_</a> == 0)
<a name="l00463"></a>00463         <span class="comment">// quota disabled</span>
<a name="l00464"></a>00464         <span class="keywordflow">return</span>;
<a name="l00465"></a>00465 
<a name="l00466"></a>00466     <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i;
<a name="l00467"></a>00467     <a class="code" href="classprophet_1_1Table.html#3617981b587cbbd0e3e64afea1e997e0" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<a class="code" href="classprophet_1_1Table.html#39803a4bfdceda69b153a60415b7a8de" title="object name">name_</a>.c_str(),<a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">BundleCore::LOG_INFO</a>,
<a name="l00468"></a>00468             <span class="stringliteral">"enforce_quota table_size=[%zu] max_route=[%u]"</span>,
<a name="l00469"></a>00469             <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.size(), <a class="code" href="classprophet_1_1Table.html#66e1a17c87be6dcdb044879b61ce29c5" title="upper limit to number of routes to retain">max_route_</a>);
<a name="l00470"></a>00470     <span class="keywordflow">while</span>(<a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.size() &gt; <a class="code" href="classprophet_1_1Table.html#66e1a17c87be6dcdb044879b61ce29c5" title="upper limit to number of routes to retain">max_route_</a>)
<a name="l00471"></a>00471     {
<a name="l00472"></a>00472         <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#f9153c0d26efbd93362cc4a572437ee7" title="Return true if underlying sequence is empty.">empty</a>())
<a name="l00473"></a>00473             <span class="keywordflow">break</span>;
<a name="l00474"></a>00474 
<a name="l00475"></a>00475         <span class="comment">// select the minimum known route and evict</span>
<a name="l00476"></a>00476         <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* n = <a class="code" href="classprophet_1_1Table.html#a448d426b276031ddf7cb07c6f4188ce" title="Min-heap for quota-enforcement eviction ordering.">heap_</a>.<a class="code" href="classprophet_1_1Heap.html#ed8c35bf71920dcca199adc8f869a8eb" title="Return read-only reference to top of heap.">top</a>();
<a name="l00477"></a>00477         <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">find</a>(n-&gt;<a class="code" href="classprophet_1_1Node.html#4c423ba83a417f43615a087bf52127e9" title="Accessors.">dest_id</a>(),&amp;i))
<a name="l00478"></a>00478             <span class="keyword">remove</span>(&amp;i);
<a name="l00479"></a>00479         <span class="keywordflow">else</span>
<a name="l00480"></a>00480             <span class="comment">// shouldn't be reached ... ?</span>
<a name="l00481"></a>00481             <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>(n);
<a name="l00482"></a>00482     }
<a name="l00483"></a>00483 }
<a name="l00484"></a>00484 
<a name="l00485"></a>00485 <span class="keywordtype">void</span>
<a name="l00486"></a><a class="code" href="classprophet_1_1Table.html#5acac2d4bc869643d71266c2ba388015">00486</a> <a class="code" href="classprophet_1_1Table.html#5acac2d4bc869643d71266c2ba388015" title="Clean up memory pointed to by each Node*.">Table::free</a>()
<a name="l00487"></a>00487 {
<a name="l00488"></a>00488     <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a> i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.begin(); i != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end(); i++)
<a name="l00489"></a>00489     {
<a name="l00490"></a>00490         <a class="code" href="classprophet_1_1Table.html#e4eedc231c636737a7d1289df4863d6d" title="Remove node from heap.">heap_del</a>((*i).second);
<a name="l00491"></a>00491         <span class="keyword">delete</span> ((*i).second);
<a name="l00492"></a>00492     }
<a name="l00493"></a>00493 }
<a name="l00494"></a>00494 
<a name="l00495"></a>00495 <span class="keywordtype">bool</span>
<a name="l00496"></a><a class="code" href="classprophet_1_1Table.html#c91b4b50f968d566193032f745d8f278">00496</a> <a class="code" href="classprophet_1_1Table.html#b3c3698e75794320979428537a37cdef" title="Find and return route for given destination ID; else return NULL.">Table::find</a>(<span class="keyword">const</span> std::string&amp; dest_id, <a class="code" href="classprophet_1_1Table.html#6702f69454bf0cbaa3cfa9007214a43d">iterator</a>* i)
<a name="l00497"></a>00497 {
<a name="l00498"></a>00498     <span class="keywordflow">if</span> (dest_id.length() &lt; <a class="code" href="Table_8cc.html#36aadcc60cb05b42dcda5459cd0c8acc">MIN_LENGTH</a>)
<a name="l00499"></a>00499     {
<a name="l00500"></a>00500         <a class="code" href="Table_8cc.html#681fc17ca4af049309d6364b670b4ff8">LOG_LT_MIN_LENGTH</a>;
<a name="l00501"></a>00501         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00502"></a>00502     }
<a name="l00503"></a>00503     <span class="keywordflow">if</span> (i == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00504"></a>00504 
<a name="l00505"></a>00505     *i = <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.lower_bound(dest_id);
<a name="l00506"></a>00506     <span class="keywordflow">return</span> (*i != <a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.end() &amp;&amp; !(<a class="code" href="classprophet_1_1Table.html#a48e56087c6a1c4f78b17450a39526bf" title="Mapped collection of &amp;lt;dest_id,Node*&amp;gt; pairs.">table_</a>.key_comp()(dest_id,(*i)-&gt;first)));
<a name="l00507"></a>00507 }
<a name="l00508"></a>00508 
<a name="l00509"></a>00509 }; <span class="comment">// namespace prophet</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:47 2008 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>