<!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: BundleTLVEntryList.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 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>BundleTLVEntryList.h</h1><a href="BundleTLVEntryList_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_BUNDLE_ENTRY_LIST_H_</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_BUNDLE_ENTRY_LIST_H_</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <map></span> <a name="l00021"></a>00021 <span class="preprocessor">#include <string></span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="PointerList_8h.html">PointerList.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="BundleTLVEntry_8h.html">BundleTLVEntry.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="prophet_2Dictionary_8h.html">Dictionary.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="Table_8h.html">Table.h</a>"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">namespace </span>prophet <a name="l00029"></a>00029 { <a name="l00030"></a>00030 <a name="l00035"></a>00035 <span class="keyword">template</span> <<span class="keyword">class</span> BundleEntryType> <a name="l00036"></a><a class="code" href="classprophet_1_1BundleEntryList.html">00036</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a> <a name="l00037"></a>00037 { <a name="l00038"></a>00038 <span class="keyword">public</span>: <a name="l00039"></a><a class="code" href="classprophet_1_1BundleEntryList.html#4df36d34f79736342bc4b21ad2e578d3">00039</a> <span class="keyword">typedef</span> <a class="code" href="classprophet_1_1PointerList.html">PointerList<BundleEntryType></a> <a class="code" href="classprophet_1_1PointerList.html">List</a>; <a name="l00040"></a>00040 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList<BundleEntryType>::iterator</a> <a name="l00041"></a><a class="code" href="classprophet_1_1BundleEntryList.html#304bdd8fa33e472ad896a77ea558fab4">00041</a> <a class="code" href="classprophet_1_1BundleEntryList.html#304bdd8fa33e472ad896a77ea558fab4">iterator</a>; <a name="l00042"></a>00042 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList<BundleEntryType>::const_iterator</a> <a name="l00043"></a><a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">00043</a> <a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a>; <a name="l00044"></a>00044 <a name="l00048"></a><a class="code" href="classprophet_1_1BundleEntryList.html#f69fd46aacfd4216148f1577662ebf48">00048</a> <a class="code" href="classprophet_1_1BundleEntryList.html#f69fd46aacfd4216148f1577662ebf48" title="Default constructor.">BundleEntryList</a>(<a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321" title="A BundleTLVEntry can represent either an OFFER or a RESPONSE, depending on what is...">BundleTLVEntry::bundle_entry_t</a> <a class="code" href="classprophet_1_1BundleEntryList.html#caf703e147911a7b98754bd961bbeeb4" title="Return type of entries hosted by this list.">type</a> = <a name="l00049"></a>00049 <a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d3215a1a084212865f78c542f8c458201a19" title="no valid type has been specified">BundleTLVEntry::UNDEFINED</a>) <a name="l00050"></a>00050 : <a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>(<a class="code" href="classprophet_1_1BundleEntryList.html#caf703e147911a7b98754bd961bbeeb4" title="Return type of entries hosted by this list.">type</a>) {} <a name="l00051"></a>00051 <a name="l00055"></a><a class="code" href="classprophet_1_1BundleEntryList.html#48dddd7f4601d3bae18b0e9a5e9f5a88">00055</a> <a class="code" href="classprophet_1_1BundleEntryList.html#f69fd46aacfd4216148f1577662ebf48" title="Default constructor.">BundleEntryList</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a>& list) <a name="l00056"></a>00056 : <a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>(list.<a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>), <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>(list.<a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>) {} <a name="l00057"></a>00057 <a name="l00061"></a><a class="code" href="classprophet_1_1BundleEntryList.html#4d9897c8b1113219f1bff025fd22bf15">00061</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1BundleEntryList.html#4d9897c8b1113219f1bff025fd22bf15" title="Destructor.">~BundleEntryList</a>() { <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.<a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>(); } <a name="l00062"></a>00062 <a name="l00066"></a><a class="code" href="classprophet_1_1BundleEntryList.html#7f9d7c0e391d203027f2ce3ba3eca232">00066</a> <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1BundleEntryList.html#7f9d7c0e391d203027f2ce3ba3eca232" title="Return number of Bundle offers in list.">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.size(); } <a name="l00067"></a>00067 <a name="l00071"></a><a class="code" href="classprophet_1_1BundleEntryList.html#2ac8813783a19d6a1ec23915ce958032">00071</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleEntryList.html#2ac8813783a19d6a1ec23915ce958032" title="Return whether list is empty.">empty</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.empty(); } <a name="l00072"></a>00072 <a name="l00076"></a><a class="code" href="classprophet_1_1BundleEntryList.html#94e566413b26c807c6ab214a244a1732">00076</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleEntryList.html#94e566413b26c807c6ab214a244a1732" title="Remove all entries from internal list.">clear</a>() { <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.<a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>(); } <a name="l00077"></a>00077 <a name="l00081"></a><a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0">00081</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0" title="Add a Bundle entry to this list; return whether successful.">add_entry</a>(<span class="keyword">const</span> BundleEntryType* entry) <a name="l00082"></a>00082 { <a name="l00083"></a>00083 <span class="comment">// weed out the oddball</span> <a name="l00084"></a>00084 <span class="keywordflow">if</span> (entry == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="comment">// pass on the parameters to the "other" add_entry</span> <a name="l00087"></a>00087 <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0" title="Add a Bundle entry to this list; return whether successful.">add_entry</a>(entry->type(), entry->creation_ts(), <a name="l00088"></a>00088 entry->seqno(), entry->sid(), <a name="l00089"></a>00089 entry->custody(), entry->accept(), <a name="l00090"></a>00090 entry->ack()); <a name="l00091"></a>00091 } <a name="l00092"></a>00092 <a name="l00097"></a><a class="code" href="classprophet_1_1BundleEntryList.html#6dd785f0f4fec3ef7eab8277794fb566">00097</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleEntryList.html#6dd785f0f4fec3ef7eab8277794fb566" title="Remove entry from Bundle offer list; returns true if found (and removed) else false...">remove_entry</a>(u_int32_t cts, u_int32_t seq, u_int16_t sid) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 <span class="comment">// walk the list in search of these unique identifiers</span> <a name="l00100"></a>00100 <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#304bdd8fa33e472ad896a77ea558fab4">iterator</a> i = <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.begin(); i != <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.end(); i++) <a name="l00101"></a>00101 { <a name="l00102"></a>00102 <span class="keywordflow">if</span> ((*i)->creation_ts() == cts && <a name="l00103"></a>00103 (*i)->seqno() == seq && <a name="l00104"></a>00104 (*i)->sid() == sid) <a name="l00105"></a>00105 { <a name="l00106"></a>00106 <span class="comment">// erase if found</span> <a name="l00107"></a>00107 <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.<a class="code" href="classprophet_1_1PointerList.html#6153b191deba1b5eef87771ceef60ea7" title="Deletes member pointed to by iterator, then removes pointer.">erase</a>(i); <a name="l00108"></a>00108 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <span class="comment">// not found</span> <a name="l00112"></a>00112 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <a name="l00118"></a><a class="code" href="classprophet_1_1BundleEntryList.html#ae61a57a613d4b909bc973fe2bb58fed">00118</a> <span class="keyword">const</span> BundleEntryType* <a class="code" href="classprophet_1_1BundleEntryList.html#ae61a57a613d4b909bc973fe2bb58fed" title="Return pointer to entry if found, else return NULL.">find</a>(u_int32_t cts, <a name="l00119"></a>00119 u_int32_t seq, <a name="l00120"></a>00120 u_int16_t sid)<span class="keyword"> const</span> <a name="l00121"></a>00121 <span class="keyword"> </span>{ <a name="l00122"></a>00122 BundleEntryType* bo = NULL; <a name="l00123"></a>00123 <span class="keywordflow">for</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a> i = <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.begin(); i != <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.end(); i++) <a name="l00124"></a>00124 { <a name="l00125"></a>00125 <span class="keywordflow">if</span> ((*i)->creation_ts() == cts && <a name="l00126"></a>00126 (*i)->seqno() == seq && <a name="l00127"></a>00127 (*i)->sid() == sid) <a name="l00128"></a>00128 { <a name="l00129"></a>00129 bo = *i; <a name="l00130"></a>00130 <span class="keywordflow">break</span>; <a name="l00131"></a>00131 } <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <span class="keywordflow">return</span> bo; <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00139"></a><a class="code" href="classprophet_1_1BundleEntryList.html#caf703e147911a7b98754bd961bbeeb4">00139</a> <a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321" title="A BundleTLVEntry can represent either an OFFER or a RESPONSE, depending on what is...">BundleTLVEntry::bundle_entry_t</a> <a class="code" href="classprophet_1_1BundleEntryList.html#caf703e147911a7b98754bd961bbeeb4" title="Return type of entries hosted by this list.">type</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>; } <a name="l00140"></a>00140 <a name="l00142"></a><a class="code" href="classprophet_1_1BundleEntryList.html#475b43261ea35c8ff5ef1c9104b3fe78">00142</a> <a class="code" href="classprophet_1_1BundleEntryList.html#304bdd8fa33e472ad896a77ea558fab4">iterator</a> <a class="code" href="classprophet_1_1BundleEntryList.html#475b43261ea35c8ff5ef1c9104b3fe78" title="These iterators are not thread safe.">begin</a>() { <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.begin(); } <a name="l00143"></a><a class="code" href="classprophet_1_1BundleEntryList.html#bc89e63957c0c2242d9d7b1396f273f0">00143</a> <a class="code" href="classprophet_1_1BundleEntryList.html#304bdd8fa33e472ad896a77ea558fab4">iterator</a> <a class="code" href="classprophet_1_1BundleEntryList.html#bc89e63957c0c2242d9d7b1396f273f0" title="These iterators are not thread safe.">end</a>() { <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.end(); } <a name="l00144"></a><a class="code" href="classprophet_1_1BundleEntryList.html#856f9d7337e159eb6d67b5d156109464">00144</a> <a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a> <a class="code" href="classprophet_1_1BundleEntryList.html#856f9d7337e159eb6d67b5d156109464" title="These iterators are not thread safe.">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a>) <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.begin(); } <a name="l00145"></a><a class="code" href="classprophet_1_1BundleEntryList.html#ce957ced169dfd4a49517e9be694c5c1">00145</a> <a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a> <a class="code" href="classprophet_1_1BundleEntryList.html#ce957ced169dfd4a49517e9be694c5c1" title="These iterators are not thread safe.">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#3332c2306c20626dd5e0b9767ac2c378">const_iterator</a>) <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.end(); } <a name="l00147"></a>00147 <a name="l00151"></a><a class="code" href="classprophet_1_1BundleEntryList.html#5f6c8c6669805dd71c8d278f63a1edad">00151</a> <span class="keyword">const</span> BundleEntryType* <a class="code" href="classprophet_1_1BundleEntryList.html#5f6c8c6669805dd71c8d278f63a1edad" title="Convenience method to access first entry in list, or NULL if empty.">front</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.front(); } <a name="l00152"></a>00152 <a name="l00156"></a><a class="code" href="classprophet_1_1BundleEntryList.html#497318442d53555b008bfa1beb23ba52">00156</a> <span class="keyword">const</span> BundleEntryType* <a class="code" href="classprophet_1_1BundleEntryList.html#497318442d53555b008bfa1beb23ba52" title="Convenience method to access last entry in list, or NULL if empty.">back</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.back(); } <a name="l00157"></a>00157 <a name="l00161"></a><a class="code" href="classprophet_1_1BundleEntryList.html#881e48ea062bab1b88fd041f8f773f4a">00161</a> <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1BundleEntryList.html#881e48ea062bab1b88fd041f8f773f4a" title="Estimate serialized buffer length.">guess_size</a>(<span class="keywordtype">size_t</span> BOEsz)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> BOEsz * <a class="code" href="classprophet_1_1BundleEntryList.html#7f9d7c0e391d203027f2ce3ba3eca232" title="Return number of Bundle offers in list.">size</a>(); } <a name="l00162"></a>00162 <a name="l00166"></a><a class="code" href="classprophet_1_1BundleEntryList.html#0e19f5237ddc2bf6c5b9704c5b852fbe">00166</a> <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a>& <a class="code" href="classprophet_1_1BundleEntryList.html#0e19f5237ddc2bf6c5b9704c5b852fbe" title="Assignment operator.">operator= </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a>& list) <a name="l00167"></a>00167 { <a name="l00168"></a>00168 <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a> = list.<a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>; <a name="l00169"></a>00169 <a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a> = list.<a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>; <a name="l00170"></a>00170 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00171"></a>00171 } <a name="l00172"></a>00172 <a name="l00173"></a>00173 <span class="keyword">protected</span>: <a name="l00178"></a><a class="code" href="classprophet_1_1BundleEntryList.html#dc0f65d4702895e389f5665c67335c0d">00178</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0" title="Add a Bundle entry to this list; return whether successful.">add_entry</a>(<a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321" title="A BundleTLVEntry can represent either an OFFER or a RESPONSE, depending on what is...">BundleTLVEntry::bundle_entry_t</a> <a class="code" href="classprophet_1_1BundleEntryList.html#caf703e147911a7b98754bd961bbeeb4" title="Return type of entries hosted by this list.">type</a>, <a name="l00179"></a>00179 u_int32_t cts, u_int32_t seq, u_int16_t sid, <a name="l00180"></a>00180 <span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>=<span class="keyword">false</span>, <a name="l00181"></a>00181 <span class="keywordtype">bool</span> accept=<span class="keyword">false</span>, <a name="l00182"></a>00182 <span class="keywordtype">bool</span> ack=<span class="keyword">false</span>) <a name="l00183"></a>00183 { <a name="l00184"></a>00184 <span class="comment">// there can only be one type in this list, and UNDEFINED</span> <a name="l00185"></a>00185 <span class="comment">// isn't one of them</span> <a name="l00186"></a>00186 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a> == <a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d3215a1a084212865f78c542f8c458201a19" title="no valid type has been specified">BundleTLVEntry::UNDEFINED</a>) <a name="l00187"></a>00187 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00188"></a>00188 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a> != type) <a name="l00189"></a>00189 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00190"></a>00190 <a name="l00191"></a>00191 <span class="comment">// attempt to create new entry</span> <a name="l00192"></a>00192 <a class="code" href="classprophet_1_1BundleTLVEntry.html" title="BundleTLVEntry is the in-memory representation of an element listed within the Bundle...">BundleTLVEntry</a>* b = <a name="l00193"></a>00193 <a class="code" href="classprophet_1_1BundleTLVEntry.html#089ac2402ce89d32e972398bf200d0e8" title="Factory method for convenience.">BundleTLVEntry::create_entry</a>(cts,seq,sid,<a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>,accept,ack); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="comment">// fail out on error</span> <a name="l00196"></a>00196 <span class="keywordflow">if</span> (b == NULL) <a name="l00197"></a>00197 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00198"></a>00198 <span class="keywordflow">else</span> <a name="l00199"></a>00199 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a> != b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#2d97556fa7fb52f5a8b041b463f59e72" title="Accessors.">type</a>()) <a name="l00200"></a>00200 { <a name="l00201"></a>00201 <span class="keyword">delete</span> b; <a name="l00202"></a>00202 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00203"></a>00203 } <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="comment">// push back upon success</span> <a name="l00206"></a>00206 <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleEntryList.html#11268583624d0c667de934f8354ba5a1" title="Add entry to back of list.">push_back</a>(dynamic_cast<BundleEntryType*>(b)); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <a name="l00212"></a>00212 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleEntryList.html#11268583624d0c667de934f8354ba5a1" title="Add entry to back of list.">push_back</a>(BundleEntryType* bo) = 0; <a name="l00213"></a>00213 <a name="l00214"></a><a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5">00214</a> <a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321" title="A BundleTLVEntry can represent either an OFFER or a RESPONSE, depending on what is...">BundleTLVEntry::bundle_entry_t</a> <a class="code" href="classprophet_1_1BundleEntryList.html#a9354b1a5556112fbcd44456d49a94b5" title="type of Bundle entry in list">type_</a>; <a name="l00215"></a><a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">00215</a> <a class="code" href="classprophet_1_1PointerList.html">List</a> <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>; <a name="l00216"></a>00216 }; <span class="comment">// class BundleEntryList</span> <a name="l00217"></a>00217 <a name="l00222"></a><a class="code" href="classprophet_1_1BundleOfferList.html">00222</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1BundleOfferList.html" title="In-memory representation of list of bundle offer entries from a Bundle TLV sent by...">BundleOfferList</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a><BundleOfferEntry> <a name="l00223"></a>00223 { <a name="l00224"></a>00224 <span class="keyword">public</span>: <a name="l00228"></a><a class="code" href="classprophet_1_1BundleOfferList.html#7478abeb0a361c5a30976c56ec946e47">00228</a> <a class="code" href="classprophet_1_1BundleOfferList.html#7478abeb0a361c5a30976c56ec946e47" title="Constructor.">BundleOfferList</a>() <a name="l00229"></a>00229 : <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a><<a class="code" href="classprophet_1_1BundleOfferEntry.html" title="BundleOfferEntry represents one Bundle, a single entry in a Bundle TLV sent by a...">BundleOfferEntry</a>>(<a class="code" href="classprophet_1_1BundleTLVEntry.html" title="BundleTLVEntry is the in-memory representation of an element listed within the Bundle...">BundleTLVEntry</a>::OFFER) {} <a name="l00230"></a>00230 <a name="l00234"></a><a class="code" href="classprophet_1_1BundleOfferList.html#43f1917156449828b3bbee3c0c8e1e6a">00234</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1BundleOfferList.html#43f1917156449828b3bbee3c0c8e1e6a" title="Destructor.">~BundleOfferList</a>() {} <a name="l00235"></a>00235 <a name="l00240"></a><a class="code" href="classprophet_1_1BundleOfferList.html#fd09313f46f237e0246706360b4c7a3d">00240</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleOfferList.html#fd09313f46f237e0246706360b4c7a3d" title="Convenience method to add Bundle to the list; return whether successful.">add_offer</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, u_int16_t sid) <a name="l00241"></a>00241 { <a name="l00242"></a>00242 <span class="comment">// weed out the oddball</span> <a name="l00243"></a>00243 <span class="keywordflow">if</span> (b == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1BundleOfferList.html#fd09313f46f237e0246706360b4c7a3d" title="Convenience method to add Bundle to the list; return whether successful.">add_offer</a>(b-><a class="code" href="classprophet_1_1Bundle.html#df5ff9aa8aba7ddd7a741d6143fe3d88" title="Accessors.">creation_ts</a>(), <a name="l00246"></a>00246 b-><a class="code" href="classprophet_1_1Bundle.html#8f4fad2c83696237207ba7a19acb9ca4" title="Accessors.">sequence_num</a>(), <a name="l00247"></a>00247 sid, <a name="l00248"></a>00248 b-><a class="code" href="classprophet_1_1Bundle.html#2ee26721e39ead0250eab37c58e14aa8" title="Accessors.">custody_requested</a>(), <a name="l00249"></a>00249 <span class="keyword">false</span>); <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <a name="l00255"></a><a class="code" href="classprophet_1_1BundleOfferList.html#616241f01219ab6f48a79786f1aa8448">00255</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleOfferList.html#fd09313f46f237e0246706360b4c7a3d" title="Convenience method to add Bundle to the list; return whether successful.">add_offer</a>(u_int32_t cts, <a name="l00256"></a>00256 u_int32_t seq, <a name="l00257"></a>00257 u_int16_t sid, <a name="l00258"></a>00258 <span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>, <a name="l00259"></a>00259 <span class="keywordtype">bool</span> ack) <a name="l00260"></a>00260 { <a name="l00261"></a>00261 <span class="keywordflow">return</span> <a name="l00262"></a>00262 <a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0" title="Add a Bundle entry to this list; return whether successful.">add_entry</a>(<a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321fa6f7dc01f904230e508005e6f942085" title="Bundle OFFER.">BundleTLVEntry::OFFER</a>,cts,seq,sid,custody,<span class="keyword">false</span>,ack); <a name="l00263"></a>00263 } <a name="l00264"></a>00264 <span class="keyword">protected</span>: <a name="l00265"></a><a class="code" href="classprophet_1_1BundleOfferList.html#f5d8d432ae93da1eceed6bc167bce2b2">00265</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleOfferList.html#f5d8d432ae93da1eceed6bc167bce2b2" title="Add entry to back of list.">push_back</a>(<a class="code" href="classprophet_1_1BundleOfferEntry.html" title="BundleOfferEntry represents one Bundle, a single entry in a Bundle TLV sent by a...">BundleOfferEntry</a>* b) <a name="l00266"></a>00266 { <a name="l00267"></a>00267 <span class="keywordflow">if</span> (b == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00268"></a>00268 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#ae61a57a613d4b909bc973fe2bb58fed" title="Return pointer to entry if found, else return NULL.">find</a>(b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#1cf4b89ca8699e54a91e04dd4fc7c86e" title="Accessors.">creation_ts</a>(),b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#f53626463b117791141a4c6e1367eecc" title="Accessors.">seqno</a>(),b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#c470331376431b7ac04bc76578011298" title="Accessors.">sid</a>()) == NULL) <a name="l00269"></a>00269 { <a name="l00270"></a>00270 <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.push_back(b); <a name="l00271"></a>00271 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00274"></a>00274 } <a name="l00275"></a>00275 }; <span class="comment">// class BundleOfferList </span> <a name="l00276"></a>00276 <a name="l00281"></a><a class="code" href="classprophet_1_1BundleResponseList.html">00281</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1BundleResponseList.html" title="In-memory representation of list of bundle response entries from a Bundle TLV sent...">BundleResponseList</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a><BundleResponseEntry> <a name="l00282"></a>00282 { <a name="l00283"></a>00283 <span class="keyword">public</span>: <a name="l00287"></a><a class="code" href="classprophet_1_1BundleResponseList.html#045763840469f09d3d8550b1feda4978">00287</a> <a class="code" href="classprophet_1_1BundleResponseList.html#045763840469f09d3d8550b1feda4978" title="Constructor.">BundleResponseList</a>() <a name="l00288"></a>00288 : <a class="code" href="classprophet_1_1BundleEntryList.html" title="BundleEntryList is the in-memory representation of the Bundle offer that is exchanged...">BundleEntryList</a><<a class="code" href="classprophet_1_1BundleResponseEntry.html" title="BundleResponseEntry represents one Bundle, a single entry in a Bundle TLV sent by...">BundleResponseEntry</a>>(<a class="code" href="classprophet_1_1BundleTLVEntry.html" title="BundleTLVEntry is the in-memory representation of an element listed within the Bundle...">BundleTLVEntry</a>::RESPONSE) {} <a name="l00289"></a>00289 <a name="l00293"></a><a class="code" href="classprophet_1_1BundleResponseList.html#955e25bef4c1344eeba8dc8f4a9f93f9">00293</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1BundleResponseList.html#955e25bef4c1344eeba8dc8f4a9f93f9" title="Destructor.">~BundleResponseList</a>() {} <a name="l00294"></a>00294 <a name="l00298"></a><a class="code" href="classprophet_1_1BundleResponseList.html#bfb26b75e5a8c01aca8f4a20f9ccd390">00298</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleResponseList.html#bfb26b75e5a8c01aca8f4a20f9ccd390" title="Convenience wrapper around base class&#39;s add_entry.">add_response</a>(u_int32_t cts, <a name="l00299"></a>00299 u_int32_t seq, <a name="l00300"></a>00300 u_int16_t sid, <a name="l00301"></a>00301 <span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#160881851a33309c0106503ac4d14d96">custody</a>, <a name="l00302"></a>00302 <span class="keywordtype">bool</span> accept = <span class="keyword">true</span>) <a name="l00303"></a>00303 { <a name="l00304"></a>00304 <span class="keywordflow">return</span> <a name="l00305"></a>00305 <a class="code" href="classprophet_1_1BundleEntryList.html#7f1cca0e35a3f8be9495f7e7988cd2b0" title="Add a Bundle entry to this list; return whether successful.">add_entry</a>(<a class="code" href="classprophet_1_1BundleTLVEntry.html#ba508cc555c3c88394dc4659c7e0d321e191d0ebeaab2e6ea1e63a773b404c23" title="Bundle RESPONSE.">BundleTLVEntry::RESPONSE</a>,cts,seq,sid,custody,accept,<span class="keyword">false</span>); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <span class="keyword">protected</span>: <a name="l00308"></a><a class="code" href="classprophet_1_1BundleResponseList.html#151fe4180ed5b0fd8b5dfa7d5e811b34">00308</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleResponseList.html#151fe4180ed5b0fd8b5dfa7d5e811b34" title="Add entry to back of list.">push_back</a>(<a class="code" href="classprophet_1_1BundleResponseEntry.html" title="BundleResponseEntry represents one Bundle, a single entry in a Bundle TLV sent by...">BundleResponseEntry</a>* b) <a name="l00309"></a>00309 { <a name="l00310"></a>00310 <span class="keywordflow">if</span> (b == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00311"></a>00311 <span class="keywordflow">if</span> (<a class="code" href="classprophet_1_1BundleEntryList.html#ae61a57a613d4b909bc973fe2bb58fed" title="Return pointer to entry if found, else return NULL.">find</a>(b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#1cf4b89ca8699e54a91e04dd4fc7c86e" title="Accessors.">creation_ts</a>(),b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#f53626463b117791141a4c6e1367eecc" title="Accessors.">seqno</a>(),b-><a class="code" href="classprophet_1_1BundleTLVEntry.html#c470331376431b7ac04bc76578011298" title="Accessors.">sid</a>()) == NULL) <a name="l00312"></a>00312 { <a name="l00313"></a>00313 <a class="code" href="classprophet_1_1BundleEntryList.html#f347ea8cf9daf6fb009813dd4c60a78e">list_</a>.push_back(b); <a name="l00314"></a>00314 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00317"></a>00317 } <a name="l00318"></a>00318 }; <span class="comment">// class BundleResponseList </span> <a name="l00319"></a>00319 <a name="l00320"></a>00320 }; <span class="comment">// namespace prophet</span> <a name="l00321"></a>00321 <a name="l00322"></a>00322 <span class="preprocessor">#endif // _PROPHET_BUNDLE_ENTRY_LIST_H_</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:53 2009 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.8 </small></address> </body> </html>