Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 29c369053a983cc5d8c880dc6e0a2237 > files > 548

libdtn-devel-2.6.0-2mdv2009.1.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: Repository.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<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>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>Repository.h</h1><a href="Repository_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_REPOSITORY_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_REPOSITORY_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="prophet_2Bundle_8h.html">Bundle.h</a>"</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="prophet_2BundleList_8h.html">BundleList.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="QueuePolicy_8h.html">QueuePolicy.h</a>"</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#if defined(__GNUC__)</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor"># define PRINTFLIKE(fmt, arg) __attribute__((format (printf, fmt, arg)))</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00027"></a><a class="code" href="Repository_8h.html#f2200d91c2af569b1e7c99405045640e">00027</a> <span class="preprocessor"></span><span class="preprocessor"># define PRINTFLIKE(a, b)</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="keyword">namespace </span>prophet
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 
<a name="l00043"></a><a class="code" href="classprophet_1_1Repository.html">00043</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1Repository.html" title="Implements a modified heap-based priority_queue with bounds enforcement.">Repository</a>
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045 <span class="keyword">public</span>:
<a name="l00046"></a><a class="code" href="classprophet_1_1Repository.html#0194fa44c6eb1de11a06840a8909bc56">00046</a>     <span class="keyword">typedef</span> BundleList::iterator <a class="code" href="classprophet_1_1Repository.html#0194fa44c6eb1de11a06840a8909bc56">iterator</a>;
<a name="l00047"></a><a class="code" href="classprophet_1_1Repository.html#979d0a33179bc3894e60816e71591ef9">00047</a>     <span class="keyword">typedef</span> BundleList::const_iterator <a class="code" href="classprophet_1_1Repository.html#979d0a33179bc3894e60816e71591ef9">const_iterator</a>;
<a name="l00048"></a>00048 
<a name="l00053"></a><a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html">00053</a>     <span class="keyword">class </span><a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html" title="Reduced interface into BundleCore to provide logging, drop_bundle signal, and answer...">BundleCoreRep</a>
<a name="l00054"></a>00054     {
<a name="l00055"></a>00055     <span class="keyword">public</span>:
<a name="l00056"></a><a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#f46814473cbf10a7ade24c0fae9fd8ee">00056</a>         <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#f46814473cbf10a7ade24c0fae9fd8ee">~BundleCoreRep</a>() {}
<a name="l00057"></a>00057         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#8eb05a2110ab587c83cf7f5b4934c78c">print_log</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">int</span> level,
<a name="l00058"></a>00058                                <span class="keyword">const</span> <span class="keywordtype">char</span>* fmt, ...)
<a name="l00059"></a>00059             <a class="code" href="BundleCore_8h.html#f2200d91c2af569b1e7c99405045640e">PRINTFLIKE</a>(4,5) = 0;
<a name="l00060"></a>00060         virtual <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#ac1de960ebf0b2391782ebc52934e3b3">drop_bundle</a>(const <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&amp;#39;s Bundle representation...">Bundle</a>* bundle) = 0;
<a name="l00061"></a>00061         virtual u_int64_t <a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#e8c1402cd4f60af4d617ab6b74534c29">max_bundle_quota</a>() const = 0;
<a name="l00062"></a>00062     };
<a name="l00063"></a>00063 
<a name="l00073"></a>00073     <a class="code" href="classprophet_1_1Repository.html" title="Implements a modified heap-based priority_queue with bounds enforcement.">Repository</a>(<a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html" title="Reduced interface into BundleCore to provide logging, drop_bundle signal, and answer...">BundleCoreRep</a>* core, <a class="code" href="classprophet_1_1QueueComp.html" title="Bundle queuing policy requires a sort order, which is provided by QueueComp and its...">QueueComp</a>* qc = NULL,
<a name="l00074"></a>00074                const <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&amp;#39;s Bundle facade objects.">BundleList</a>* list = NULL);
<a name="l00075"></a>00075 
<a name="l00079"></a>00079     ~<a class="code" href="classprophet_1_1Repository.html" title="Implements a modified heap-based priority_queue with bounds enforcement.">Repository</a>();
<a name="l00080"></a>00080 
<a name="l00087"></a>00087     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1Repository.html#1cafd561e6fe753ab2c47e9ac0147610" title="Add bundle to Repository, incrementing current utilization by Bundle&amp;#39;s storage...">add</a>(const <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&amp;#39;s Bundle representation...">Bundle</a>* bundle);
<a name="l00088"></a>00088 
<a name="l00095"></a>00095     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#85630acc1cb2251b14f9e315545ce672" title="Remove arbitrary Bundle from Repository, and decrement current utilization accordingly...">del</a>(const <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&amp;#39;s Bundle representation...">Bundle</a>* bundle);
<a name="l00096"></a>00096 
<a name="l00102"></a>00102     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#cc753727bc152f8e95a6871b93c6195b" title="Change policy of Repository by replacing comparator; post condition is that eviction...">set_comparator</a>(<a class="code" href="classprophet_1_1QueueComp.html" title="Bundle queuing policy requires a sort order, which is provided by QueueComp and its...">QueueComp</a>* qc);
<a name="l00103"></a>00103 
<a name="l00107"></a><a class="code" href="classprophet_1_1Repository.html#e81e044d161c5c3fc6a3026b47b546fc">00107</a>     const <a class="code" href="classprophet_1_1QueueComp.html" title="Bundle queuing policy requires a sort order, which is provided by QueueComp and its...">QueueComp</a>* <a class="code" href="classprophet_1_1Repository.html#e81e044d161c5c3fc6a3026b47b546fc" title="Accessor to current comparator.">get_comparator</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#cb20665e4d1142b8238574e870459080" title="queue policy Bundle comparator">comp_</a>; }
<a name="l00108"></a>00108 
<a name="l00112"></a>00112     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#43a57af8101bc6ae87cd903a6a56d5f8" title="Callback to instruct Repository to query BundleCore on new max.">handle_change_max</a>();
<a name="l00113"></a>00113 
<a name="l00118"></a>00118     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#cd87c47df716511152d5c9da8c820de9" title="Callback for external notice to recalculate eviction order for list, due to changed...">change_priority</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);
<a name="l00119"></a>00119 
<a name="l00124"></a><a class="code" href="classprophet_1_1Repository.html#2bc7391d0e5755776242f21f1069f962">00124</a>     <span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&amp;#39;s Bundle facade objects.">BundleList</a>&amp; <a class="code" href="classprophet_1_1Repository.html#2bc7391d0e5755776242f21f1069f962" title="Fetch const reference to internal list of Bundles (there is no guarantee of meaningful...">get_bundles</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#30b8149dab50ab002643ce0a4ea8e0f7" title="array-based eviction-ordered heap of Bundles">list_</a>; }
<a name="l00125"></a>00125 
<a name="l00129"></a><a class="code" href="classprophet_1_1Repository.html#c1554cd2ad11330f6fe1635971244497">00129</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1Repository.html#c1554cd2ad11330f6fe1635971244497" title="Return boolean indicating whether Repository has any bundles.">empty</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#30b8149dab50ab002643ce0a4ea8e0f7" title="array-based eviction-ordered heap of Bundles">list_</a>.empty(); }
<a name="l00130"></a>00130 
<a name="l00134"></a><a class="code" href="classprophet_1_1Repository.html#36f17a28a30034539c725e545bcbbae1">00134</a>     <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1Repository.html#36f17a28a30034539c725e545bcbbae1" title="Return number of Bundles in Repository.">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#30b8149dab50ab002643ce0a4ea8e0f7" title="array-based eviction-ordered heap of Bundles">list_</a>.size(); }
<a name="l00135"></a>00135 
<a name="l00139"></a><a class="code" href="classprophet_1_1Repository.html#6f4bb95fb969edaf6eb1fcbdc8b36964">00139</a>     u_int <a class="code" href="classprophet_1_1Repository.html#6f4bb95fb969edaf6eb1fcbdc8b36964" title="Return the current upper limit imposed by Repository.">get_max</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#40ace45bc3475f088b007a693fbe346e" title="facade interface into Bundle host">core_</a>-&gt;<a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html#e8c1402cd4f60af4d617ab6b74534c29">max_bundle_quota</a>(); }
<a name="l00140"></a>00140 
<a name="l00144"></a><a class="code" href="classprophet_1_1Repository.html#d67a88c4f2acca62cc8907c61ea9116d">00144</a>     u_int <a class="code" href="classprophet_1_1Repository.html#d67a88c4f2acca62cc8907c61ea9116d" title="Return current storage consumed by Bundles in Repository.">get_current</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1Repository.html#e39fe77b424c3bf6e2c9a12aec55dc7d" title="current utilization">current_</a>; }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 <span class="keyword">protected</span>:
<a name="l00150"></a>00150     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#7369ce2c18b82ea116377d4edb838509" title="Evict the next candidate Bundle according to policy order.">evict</a>();
<a name="l00151"></a>00151 
<a name="l00153"></a>00153     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#a3ee3d3ac064fccb45e547c5c68cef67" title="Heap operations.">make_heap</a>(<span class="keywordtype">size_t</span> first, <span class="keywordtype">size_t</span> last);
<a name="l00154"></a>00154     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#05490d99aca837b83e8e951cf302e9b8" title="Heap operations.">push_heap</a>(<span class="keywordtype">size_t</span> first, <span class="keywordtype">size_t</span> hole, <span class="keywordtype">size_t</span> top, <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);
<a name="l00155"></a>00155     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#3080a9f8198447ef342f7050f7222406" title="Heap operations.">pop_heap</a>(<span class="keywordtype">size_t</span> first, <span class="keywordtype">size_t</span> last, <span class="keywordtype">size_t</span> result, <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);
<a name="l00156"></a>00156     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#9867f5529bdd391f9cf89df552912cde" title="Heap operations.">adjust_heap</a>(<span class="keywordtype">size_t</span> first, <span class="keywordtype">size_t</span> hole, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</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);
<a name="l00157"></a>00157     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1Repository.html#d7ed7acb85267844994fb86365c1051e" title="Heap operations.">remove_and_reheap</a>(<span class="keywordtype">size_t</span> hole);
<a name="l00159"></a>00159 
<a name="l00163"></a>00163     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1Repository.html#fb61e882fbfc1d8aa83f65d6ba55ca0e" title="Utility function for find.">find</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, <a class="code" href="classprophet_1_1Repository.html#0194fa44c6eb1de11a06840a8909bc56">iterator</a>&amp; i);
<a name="l00164"></a>00164 
<a name="l00165"></a><a class="code" href="classprophet_1_1Repository.html#40ace45bc3475f088b007a693fbe346e">00165</a>     <a class="code" href="classprophet_1_1Repository_1_1BundleCoreRep.html" title="Reduced interface into BundleCore to provide logging, drop_bundle signal, and answer...">BundleCoreRep</a>* <a class="code" href="classprophet_1_1Repository.html#40ace45bc3475f088b007a693fbe346e" title="facade interface into Bundle host">core_</a>; 
<a name="l00166"></a><a class="code" href="classprophet_1_1Repository.html#cb20665e4d1142b8238574e870459080">00166</a>     <a class="code" href="classprophet_1_1QueueComp.html" title="Bundle queuing policy requires a sort order, which is provided by QueueComp and its...">QueueComp</a>* <a class="code" href="classprophet_1_1Repository.html#cb20665e4d1142b8238574e870459080" title="queue policy Bundle comparator">comp_</a>; 
<a name="l00167"></a><a class="code" href="classprophet_1_1Repository.html#30b8149dab50ab002643ce0a4ea8e0f7">00167</a>     <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&amp;#39;s Bundle facade objects.">BundleList</a> <a class="code" href="classprophet_1_1Repository.html#30b8149dab50ab002643ce0a4ea8e0f7" title="array-based eviction-ordered heap of Bundles">list_</a>; 
<a name="l00168"></a><a class="code" href="classprophet_1_1Repository.html#e39fe77b424c3bf6e2c9a12aec55dc7d">00168</a>     u_int <a class="code" href="classprophet_1_1Repository.html#e39fe77b424c3bf6e2c9a12aec55dc7d" title="current utilization">current_</a>;   
<a name="l00169"></a>00169 }; <span class="comment">// class Repository</span>
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 }; <span class="comment">// namespace prophet</span>
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="preprocessor">#endif // _PROPHET_REPOSITORY_H_</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:57 2009 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.8 </small></address>
</body>
</html>