<!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: FwdStrategy.h 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 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>FwdStrategy.h</h1><a href="FwdStrategy_8h.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">#ifndef _PROPHET_FWD_STRATEGY_H_</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_FWD_STRATEGY_H_</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <algorithm></span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="prophet_2Bundle_8h.html">Bundle.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="Table_8h.html">Table.h</a>"</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="keyword">namespace </span>prophet <a name="l00025"></a>00025 { <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="comment">// forward declaration</span> <a name="l00028"></a>00028 <span class="keyword">class </span>FwdStrategyComp; <a name="l00029"></a>00029 <a name="l00030"></a><a class="code" href="structprophet_1_1FwdStrategy.html">00030</a> <span class="keyword">struct </span><a class="code" href="structprophet_1_1FwdStrategy.html">FwdStrategy</a> <a name="l00031"></a>00031 { <a name="l00036"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9">00036</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a name="l00037"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b5606df1e789e95473436978bdec3d6a">00037</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b5606df1e789e95473436978bdec3d6a">INVALID_FS</a> = 0, <a name="l00038"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9d50665e088294ee93bfdab2b1887c683">00038</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9d50665e088294ee93bfdab2b1887c683">GRTR</a>, <a name="l00039"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff93556b70a32a018adc3efee4111f10580">00039</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff93556b70a32a018adc3efee4111f10580">GTMX</a>, <a name="l00040"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff92dc38cf4c7a05c138524ad3ed80a5699">00040</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff92dc38cf4c7a05c138524ad3ed80a5699">GRTR_PLUS</a>, <a name="l00041"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff982360112f9e1c1b7137f30156eb45520">00041</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff982360112f9e1c1b7137f30156eb45520">GTMX_PLUS</a>, <a name="l00042"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b9c1ff494a55bdfb4d57eb8a43666466">00042</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b9c1ff494a55bdfb4d57eb8a43666466">GRTR_SORT</a>, <a name="l00043"></a><a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9ecc35b1ddfc1e3bd218f938a99327472">00043</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9ecc35b1ddfc1e3bd218f938a99327472">GRTR_MAX</a> <a name="l00044"></a>00044 } <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">fwd_strategy_t</a>; <a name="l00045"></a>00045 <a name="l00049"></a>00049 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a name="l00050"></a><a class="code" href="structprophet_1_1FwdStrategy.html#7f4f68ad00baaae6231d6b4162e92c1e">00050</a> <a class="code" href="structprophet_1_1FwdStrategy.html#7f4f68ad00baaae6231d6b4162e92c1e" title="Utility function to convert type code to const char*.">fs_to_str</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">fwd_strategy_t</a> fs) <a name="l00051"></a>00051 { <a name="l00052"></a>00052 <span class="keywordflow">switch</span>(fs) { <a name="l00053"></a>00053 <span class="preprocessor">#define CASE(_f_s) case _f_s: return # _f_s</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9d50665e088294ee93bfdab2b1887c683">GRTR</a>); <a name="l00055"></a>00055 <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff93556b70a32a018adc3efee4111f10580">GTMX</a>); <a name="l00056"></a>00056 <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff92dc38cf4c7a05c138524ad3ed80a5699">GRTR_PLUS</a>); <a name="l00057"></a>00057 <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff982360112f9e1c1b7137f30156eb45520">GTMX_PLUS</a>); <a name="l00058"></a>00058 <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b9c1ff494a55bdfb4d57eb8a43666466">GRTR_SORT</a>); <a name="l00059"></a>00059 <a class="code" href="dtn__ipc_8c.html#6d24efd83036c2dde8d9100adb9abffd">CASE</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9ecc35b1ddfc1e3bd218f938a99327472">GRTR_MAX</a>); <a name="l00060"></a>00060 <span class="preprocessor">#undef CASE</span> <a name="l00061"></a>00061 <span class="preprocessor"></span> <span class="keywordflow">default</span>: <span class="keywordflow">return</span> <span class="stringliteral">"Unknown forwarding strategy"</span>; <a name="l00062"></a>00062 } <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00069"></a>00069 <span class="keyword">inline</span> <span class="keyword">static</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>* <a class="code" href="structprophet_1_1FwdStrategy.html#923e75aec806ac8dfdb97904e222ae7a" title="Factory method to create instance of appropriate type of comparator.">strategy</a>( <a name="l00070"></a>00070 <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> fs, <a name="l00071"></a>00071 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* local_nodes = NULL, <a name="l00072"></a>00072 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* remote_nodes = NULL); <a name="l00073"></a>00073 <a name="l00074"></a>00074 }; <span class="comment">// struct FwdStrategy</span> <a name="l00075"></a>00075 <a name="l00082"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html">00082</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a> : <a name="l00083"></a>00083 <span class="keyword">public</span> std::binary_function<const Bundle*,const Bundle*,bool> <a name="l00084"></a>00084 { <a name="l00085"></a>00085 <span class="keyword">public</span>: <a name="l00089"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#63716594db5c14d1896c3ed196484e63">00089</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html#63716594db5c14d1896c3ed196484e63" title="Destructor.">~FwdStrategyComp</a>() {} <a name="l00090"></a>00090 <a name="l00094"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#977aa52b23eb49fe72e892f12102348d">00094</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html#977aa52b23eb49fe72e892f12102348d" title="Comparator function for FIFO ordering in a heap.">operator() </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* a, <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b)<span class="keyword"> const</span> <a name="l00095"></a>00095 <span class="keyword"> </span>{ <a name="l00096"></a>00096 <span class="keywordflow">return</span> *b < *a; <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <a name="l00100"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#1399415e6d001e011ab55694545890a0">00100</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> <a class="code" href="classprophet_1_1FwdStrategyComp.html#1399415e6d001e011ab55694545890a0" title="Accessors.">fwd_strategy</a>()<span class="keyword"> const</span> <a name="l00101"></a>00101 <span class="keyword"> </span>{ <a name="l00102"></a>00102 <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html#5c02f5cfb5d6285f478a3656fee5c7d4" title="which strategy is in use">strategy_</a>; <a name="l00103"></a>00103 } <a name="l00104"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#ae12f4e773a6f3e5019aab1cd2b828e3">00104</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classprophet_1_1FwdStrategyComp.html#ae12f4e773a6f3e5019aab1cd2b828e3" title="Accessors.">fwd_strategy_str</a>()<span class="keyword"> const</span> <a name="l00105"></a>00105 <span class="keyword"> </span>{ <a name="l00106"></a>00106 <span class="keywordflow">return</span> <a class="code" href="structprophet_1_1FwdStrategy.html#7f4f68ad00baaae6231d6b4162e92c1e" title="Utility function to convert type code to const char*.">FwdStrategy::fs_to_str</a>(<a class="code" href="classprophet_1_1FwdStrategyComp.html#5c02f5cfb5d6285f478a3656fee5c7d4" title="which strategy is in use">strategy_</a>); <a name="l00107"></a>00107 } <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="keyword">protected</span>: <a name="l00111"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#d399dade364b5046211f77a07e53d5fb">00111</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structprophet_1_1FwdStrategy.html">FwdStrategy</a>; <a name="l00112"></a>00112 <a name="l00116"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#6e2eac2d76fb45c9b9ff259e130b0b87">00116</a> <a class="code" href="classprophet_1_1FwdStrategyComp.html#6e2eac2d76fb45c9b9ff259e130b0b87" title="Constructor is protected to force use of factory method.">FwdStrategyComp</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> fs = <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b5606df1e789e95473436978bdec3d6a">FwdStrategy::INVALID_FS</a>) <a name="l00117"></a>00117 : <a class="code" href="classprophet_1_1FwdStrategyComp.html#5c02f5cfb5d6285f478a3656fee5c7d4" title="which strategy is in use">strategy_</a>(fs) {} <a name="l00118"></a>00118 <a name="l00119"></a><a class="code" href="classprophet_1_1FwdStrategyComp.html#5c02f5cfb5d6285f478a3656fee5c7d4">00119</a> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> <a class="code" href="classprophet_1_1FwdStrategyComp.html#5c02f5cfb5d6285f478a3656fee5c7d4" title="which strategy is in use">strategy_</a>; <a name="l00120"></a>00120 }; <span class="comment">// class FwdStrategyComp</span> <a name="l00121"></a>00121 <a name="l00129"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html">00129</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html" title="Comparator for sorting Bundles according to GRTRSort, Section 3.6, Prophet March...">FwdStrategyCompGRTRSORT</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a> <a name="l00130"></a>00130 { <a name="l00131"></a>00131 <span class="keyword">public</span>: <a name="l00135"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#2aa6a4c91c7622b505963293578a65ea">00135</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#2aa6a4c91c7622b505963293578a65ea" title="Destructor.">~FwdStrategyCompGRTRSORT</a>() {} <a name="l00136"></a>00136 <a name="l00137"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#75ff32e30a6a2a02c72de5c9bf8ca0dd">00137</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#75ff32e30a6a2a02c72de5c9bf8ca0dd" title="Comparator function for FIFO ordering in a heap.">operator() </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* a, <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b)<span class="keyword"> const</span> <a name="l00138"></a>00138 <span class="keyword"> </span>{ <a name="l00139"></a>00139 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a> == NULL || <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a> == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00140"></a>00140 <span class="keywordtype">double</span> pa = <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(a) - <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(a); <a name="l00141"></a>00141 <span class="keywordtype">double</span> pb = <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(b) - <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(b); <a name="l00142"></a>00142 <span class="keywordflow">return</span> pa < pb; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 <a name="l00146"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#9ba184b765ac731b437c9298e7dd8969">00146</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#9ba184b765ac731b437c9298e7dd8969" title="Accessors.">local_nodes</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a>; } <a name="l00147"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#3aefc3ca7c4fe94a0a9f26c2b2be6197">00147</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#3aefc3ca7c4fe94a0a9f26c2b2be6197" title="Accessors.">remote_nodes</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a>; } <a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="keyword">protected</span>: <a name="l00151"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#d399dade364b5046211f77a07e53d5fb">00151</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structprophet_1_1FwdStrategy.html">FwdStrategy</a>; <a name="l00152"></a>00152 <a name="l00156"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#ffe6dfae553ad6dba623d723ae3aecb4">00156</a> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#ffe6dfae553ad6dba623d723ae3aecb4" title="Constructor is protected to restrict access to factory method.">FwdStrategyCompGRTRSORT</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> fs, <a name="l00157"></a>00157 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* local, <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* remote) <a name="l00158"></a>00158 : <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>(fs), <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a>(local), <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a>(remote) {} <a name="l00159"></a>00159 <a name="l00160"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9">00160</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#dd692d527d0c6da86ba489f2327e86d9" title="list of routes as known by local node">local_</a>; <a name="l00161"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03">00161</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html#4638941329f8756fd69feb9565475c03" title="list of routes known by peer node">remote_</a>; <a name="l00162"></a>00162 <a name="l00163"></a>00163 }; <span class="comment">// class FwdStrategyCompGRTRSORT</span> <a name="l00164"></a>00164 <a name="l00165"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html">00165</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html">FwdStrategyCompGRTRMAX</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a> <a name="l00166"></a>00166 { <a name="l00167"></a>00167 <span class="keyword">public</span>: <a name="l00171"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#a6a47ccbc84a7dcc5df19822951a90c0">00171</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#a6a47ccbc84a7dcc5df19822951a90c0" title="Destructor.">~FwdStrategyCompGRTRMAX</a>() {} <a name="l00172"></a>00172 <a name="l00173"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#026a2b75669272b830146fa33a967324">00173</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#026a2b75669272b830146fa33a967324" title="Comparator function for FIFO ordering in a heap.">operator() </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* a, <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b)<span class="keyword"> const</span> <a name="l00174"></a>00174 <span class="keyword"> </span>{ <a name="l00175"></a>00175 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a> == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00176"></a>00176 <span class="keywordflow">return</span> (<a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(a) < <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a>-><a class="code" href="classprophet_1_1Table.html#0660932fcdaa4a5ebc21d6f7e54c7ebe" title="Convenience function for looking up predictability of a given route.">p_value</a>(b)); <a name="l00177"></a>00177 } <a name="l00178"></a>00178 <a name="l00180"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#4b8fee0471bc7d9e4f2050bcf8f261a8">00180</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#4b8fee0471bc7d9e4f2050bcf8f261a8" title="Accessors.">remote_nodes</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a>; } <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="keyword">protected</span>: <a name="l00184"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#d399dade364b5046211f77a07e53d5fb">00184</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structprophet_1_1FwdStrategy.html">FwdStrategy</a>; <a name="l00185"></a>00185 <a name="l00189"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#18e095f939279584d88391ae41c0feb2">00189</a> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#18e095f939279584d88391ae41c0feb2" title="Constructor is protected to restrict access to factory method.">FwdStrategyCompGRTRMAX</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> fs,<span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* remote) <a name="l00190"></a>00190 : <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>(fs), <a name="l00191"></a>00191 <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a>(remote) {} <a name="l00192"></a>00192 <a name="l00193"></a><a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31">00193</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html#408b329bb836e863552fb537e3e37c31" title="list of routes known by peer node">remote_</a>; <a name="l00194"></a>00194 }; <span class="comment">// class FwdStrategyCompGRTRMAX</span> <a name="l00195"></a>00195 <a name="l00204"></a><a class="code" href="structprophet_1_1BundleOfferComp.html">00204</a> <span class="keyword">struct </span><a class="code" href="structprophet_1_1BundleOfferComp.html" title="Due to extensive use of copy constructors in the STL, any inheritance hierarchy of...">BundleOfferComp</a> : <a name="l00205"></a>00205 <span class="keyword">public</span> std::binary_function<const Bundle*,const Bundle*,bool> <a name="l00206"></a>00206 { <a name="l00207"></a><a class="code" href="structprophet_1_1BundleOfferComp.html#9d81cc04b89f1fa3c38bdfe1e81c631e">00207</a> <a class="code" href="structprophet_1_1BundleOfferComp.html#9d81cc04b89f1fa3c38bdfe1e81c631e">BundleOfferComp</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>* comp) <a name="l00208"></a>00208 : <a class="code" href="structprophet_1_1BundleOfferComp.html#b411951d835148266915dc661a5b1ce5" title="pointer to actual comparator instance">comp_</a>(comp) {} <a name="l00209"></a>00209 <a name="l00210"></a><a class="code" href="structprophet_1_1BundleOfferComp.html#cb4a7cbc7049266ce0edef2b270fda1a">00210</a> <span class="keywordtype">bool</span> <a class="code" href="structprophet_1_1BundleOfferComp.html#cb4a7cbc7049266ce0edef2b270fda1a">operator() </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* a, <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b)<span class="keyword"> const</span> <a name="l00211"></a>00211 <span class="keyword"> </span>{ <a name="l00212"></a>00212 <span class="keywordflow">return</span> <a class="code" href="structprophet_1_1BundleOfferComp.html#b411951d835148266915dc661a5b1ce5" title="pointer to actual comparator instance">comp_</a>->operator()(a,b); <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00215"></a><a class="code" href="structprophet_1_1BundleOfferComp.html#b411951d835148266915dc661a5b1ce5">00215</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>* <a class="code" href="structprophet_1_1BundleOfferComp.html#b411951d835148266915dc661a5b1ce5" title="pointer to actual comparator instance">comp_</a>; <a name="l00216"></a>00216 }; <a name="l00217"></a>00217 <a name="l00218"></a>00218 <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>* <a name="l00219"></a><a class="code" href="structprophet_1_1FwdStrategy.html#923e75aec806ac8dfdb97904e222ae7a">00219</a> <a class="code" href="structprophet_1_1FwdStrategy.html#923e75aec806ac8dfdb97904e222ae7a" title="Factory method to create instance of appropriate type of comparator.">FwdStrategy::strategy</a>(<a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9" title="Forwarding strategies p.">FwdStrategy::fwd_strategy_t</a> fs, <a name="l00220"></a>00220 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* local, <a name="l00221"></a>00221 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Table.html" title="Container for Prophet nodes (routes and predictability values).">Table</a>* remote) <a name="l00222"></a>00222 { <a name="l00223"></a>00223 <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>* f = NULL; <a name="l00224"></a>00224 <span class="keywordflow">switch</span> (fs) <a name="l00225"></a>00225 { <a name="l00226"></a>00226 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9d50665e088294ee93bfdab2b1887c683">FwdStrategy::GRTR</a>: <a name="l00227"></a>00227 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff93556b70a32a018adc3efee4111f10580">FwdStrategy::GTMX</a>: <a name="l00228"></a>00228 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff92dc38cf4c7a05c138524ad3ed80a5699">FwdStrategy::GRTR_PLUS</a>: <a name="l00229"></a>00229 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff982360112f9e1c1b7137f30156eb45520">FwdStrategy::GTMX_PLUS</a>: <a name="l00230"></a>00230 <span class="comment">// effectively uses BundleLess (FIFO) ordering</span> <a name="l00231"></a>00231 f = <span class="keyword">new</span> <a class="code" href="classprophet_1_1FwdStrategyComp.html" title="Prophet forwarding strategy is laid out in Prophet I-D March 2006 Section 3.6, and...">FwdStrategyComp</a>(fs); <a name="l00232"></a>00232 <span class="keywordflow">break</span>; <a name="l00233"></a>00233 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b9c1ff494a55bdfb4d57eb8a43666466">FwdStrategy::GRTR_SORT</a>: <a name="l00234"></a>00234 { <a name="l00235"></a>00235 <span class="keywordflow">if</span> (local == NULL || remote == NULL) <span class="keywordflow">return</span> NULL; <a name="l00236"></a>00236 f = <span class="keyword">new</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRSORT.html" title="Comparator for sorting Bundles according to GRTRSort, Section 3.6, Prophet March...">FwdStrategyCompGRTRSORT</a>(fs,local,remote); <a name="l00237"></a>00237 <span class="keywordflow">break</span>; <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9ecc35b1ddfc1e3bd218f938a99327472">FwdStrategy::GRTR_MAX</a>: <a name="l00240"></a>00240 { <a name="l00241"></a>00241 <span class="keywordflow">if</span> (remote == NULL) <span class="keywordflow">return</span> NULL; <a name="l00242"></a>00242 f = <span class="keyword">new</span> <a class="code" href="classprophet_1_1FwdStrategyCompGRTRMAX.html">FwdStrategyCompGRTRMAX</a>(fs,remote); <a name="l00243"></a>00243 <span class="keywordflow">break</span>; <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <span class="keywordflow">case</span> <a class="code" href="structprophet_1_1FwdStrategy.html#50567dba6d835926a1532568f6a46ff9b5606df1e789e95473436978bdec3d6a">FwdStrategy::INVALID_FS</a>: <a name="l00246"></a>00246 <span class="keywordflow">default</span>: <a name="l00247"></a>00247 <span class="keywordflow">break</span>; <a name="l00248"></a>00248 } <a name="l00249"></a>00249 <span class="keywordflow">return</span> f; <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <a name="l00252"></a>00252 }; <span class="comment">// namespace prophet</span> <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="preprocessor">#endif // _PROPHET_FWD_STRATEGY_H_</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:45 2008 for DTN Reference Implementation by <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>