Sophie

Sophie

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: BundlePayload.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&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<h1>BundlePayload.h</h1><a href="BundlePayload_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 2004-2006 Intel Corporation</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 _BUNDLE_PAYLOAD_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _BUNDLE_PAYLOAD_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;oasys/serialize/Serialize.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;oasys/debug/DebugUtils.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;oasys/io/FileIOClient.h&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="keyword">namespace </span>dtn {
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">class </span>BundleStore;
<a name="l00028"></a>00028 
<a name="l00040"></a><a class="code" href="classdtn_1_1BundlePayload.html">00040</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1BundlePayload.html" title="The representation of a bundle payload.">BundlePayload</a> : <span class="keyword">public</span> oasys::SerializableObject, <span class="keyword">public</span> oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a> {
<a name="l00041"></a>00041 <span class="keyword">public</span>:
<a name="l00042"></a>00042     <a class="code" href="classdtn_1_1BundlePayload.html#76c9d29f0afcb48ae95c36f3923649b9">BundlePayload</a>(oasys::SpinLock* lock);
<a name="l00043"></a>00043     <span class="keyword">virtual</span> <a class="code" href="classdtn_1_1BundlePayload.html#9c6fd650a92362b38f591ac58fc4eaef">~BundlePayload</a>();
<a name="l00044"></a>00044     
<a name="l00048"></a><a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352">00048</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {
<a name="l00049"></a><a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35251755f9b50eab4ee0e32bf01f38d7309">00049</a>         <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35251755f9b50eab4ee0e32bf01f38d7309">MEMORY</a> = 1,     
<a name="l00050"></a><a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e">00050</a>         <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e" title="in memory only (TempBundle)">DISK</a>   = 2,     
<a name="l00051"></a><a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352136a5a00db709c66557035a52134298f">00051</a>         <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352136a5a00db709c66557035a52134298f" title="on disk">NODATA</a> = 3,     
<a name="l00052"></a>00052     } <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352" title="Options for payload location state.">location_t</a>;
<a name="l00053"></a>00053     
<a name="l00057"></a>00057     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#ad63b74a23afeffb000d2e9d59d88f19" title="Actual payload initialization function.">init</a>(<span class="keywordtype">int</span> bundleid, <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352" title="Options for payload location state.">location_t</a> <a class="code" href="classdtn_1_1BundlePayload.html#d6d6293001575473f0a1a3df3d83ed85" title="The payload location.">location</a> = <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e" title="in memory only (TempBundle)">DISK</a>);
<a name="l00058"></a>00058   
<a name="l00062"></a>00062     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#e701d992e994d03b174e500976e60c0c" title="Initialization when re-reading the database.">init_from_store</a>(<span class="keywordtype">int</span> bundleid);
<a name="l00063"></a>00063   
<a name="l00067"></a>00067     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#af1ede6096a6d625fb83c001a9d490d6" title="Set the payload length in preparation for filling in with data.">set_length</a>(<span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00068"></a>00068 
<a name="l00072"></a>00072     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#571daa527ed47d397080c96603d72b5c" title="Truncate the payload.">truncate</a>(<span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00073"></a>00073     
<a name="l00077"></a><a class="code" href="classdtn_1_1BundlePayload.html#56b3851ad789c4dbf019a32d557b7453">00077</a>     <span class="keywordtype">size_t</span> <a class="code" href="classdtn_1_1BundlePayload.html#56b3851ad789c4dbf019a32d557b7453" title="The payload length.">length</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundlePayload.html#63caf4563b2b99f622ad74d927a2c284" title="the payload length">length_</a>; }
<a name="l00078"></a>00078 
<a name="l00082"></a><a class="code" href="classdtn_1_1BundlePayload.html#d6d6293001575473f0a1a3df3d83ed85">00082</a>     <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352" title="Options for payload location state.">location_t</a> <a class="code" href="classdtn_1_1BundlePayload.html#d6d6293001575473f0a1a3df3d83ed85" title="The payload location.">location</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4" title="location of the data">location_</a>; }
<a name="l00083"></a>00083     
<a name="l00087"></a>00087     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#8abce553a70ab4bff48443d3faf49b2e" title="Set the payload data and length.">set_data</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00088"></a>00088 
<a name="l00092"></a>00092     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#8abce553a70ab4bff48443d3faf49b2e" title="Set the payload data and length.">set_data</a>(<span class="keyword">const</span> std::string&amp; data);
<a name="l00093"></a>00093 
<a name="l00098"></a>00098     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#00a87d4367a9494a4b1e44bcf72284b6" title="Append a chunk of payload data, extending the length to accomodate the new data.">append_data</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00099"></a>00099 
<a name="l00104"></a>00104     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#7f5185039b03f0c875a12136b6b24862" title="Write a chunk of payload data at the specified offset.">write_data</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> offset, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00105"></a>00105 
<a name="l00110"></a>00110     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#7f5185039b03f0c875a12136b6b24862" title="Write a chunk of payload data at the specified offset.">write_data</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1BundlePayload.html" title="The representation of a bundle payload.">BundlePayload</a>&amp; <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>, <span class="keywordtype">size_t</span> src_offset,
<a name="l00111"></a>00111                     <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>, <span class="keywordtype">size_t</span> dst_offset);
<a name="l00112"></a>00112 
<a name="l00116"></a>00116     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#e7a1d894d64121fc15f7edd8ef85ba0b" title="Copy (or link) the payload to the given file client object.">copy_file</a>(oasys::FileIOClient* dst) <span class="keyword">const</span>;
<a name="l00117"></a>00117 
<a name="l00122"></a>00122     <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1BundlePayload.html#77a4deb96daa78ce4a806aed014999e4" title="Replace the underlying file with a hard link to the given path or a copy of the file...">replace_with_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* path);
<a name="l00123"></a>00123 
<a name="l00127"></a><a class="code" href="classdtn_1_1BundlePayload.html#75e7d409e7cd3e843c30bb5191f86f18">00127</a>     <span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1BundlePayload.html#75e7d409e7cd3e843c30bb5191f86f18" title="Return the filename.">filename</a>()<span class="keyword"> const</span>
<a name="l00128"></a>00128 <span class="keyword">    </span>{
<a name="l00129"></a>00129         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4" title="location of the data">location_</a> == <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e" title="in memory only (TempBundle)">DISK</a>);
<a name="l00130"></a>00130         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundlePayload.html#511b9308e6d6d7bedad49d900cd23093" title="file handle">file_</a>.path_str();
<a name="l00131"></a>00131     }
<a name="l00132"></a>00132     
<a name="l00136"></a><a class="code" href="classdtn_1_1BundlePayload.html#a491aec8978fb909d872aa1a7c883133">00136</a>     oasys::ScratchBuffer&lt;u_char*&gt;* <a class="code" href="classdtn_1_1BundlePayload.html#a491aec8978fb909d872aa1a7c883133" title="Get a pointer to the in-memory scratch buffer.">memory_buf</a>()
<a name="l00137"></a>00137     {
<a name="l00138"></a>00138         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4" title="location of the data">location_</a> == <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35251755f9b50eab4ee0e32bf01f38d7309">MEMORY</a>);
<a name="l00139"></a>00139         <span class="keywordflow">return</span> &amp;<a class="code" href="classdtn_1_1BundlePayload.html#e3e6c5e96b7f6bfb98b04da82e713bd5" title="payload data if in memory">data_</a>;
<a name="l00140"></a>00140     }
<a name="l00141"></a>00141 
<a name="l00145"></a><a class="code" href="classdtn_1_1BundlePayload.html#e2f65fa5697341e43a01790284a91f6d">00145</a>     <span class="keyword">const</span> oasys::ScratchBuffer&lt;u_char*&gt;* <a class="code" href="classdtn_1_1BundlePayload.html#a491aec8978fb909d872aa1a7c883133" title="Get a pointer to the in-memory scratch buffer.">memory_buf</a>()<span class="keyword"> const</span>
<a name="l00146"></a>00146 <span class="keyword">    </span>{
<a name="l00147"></a>00147         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4" title="location of the data">location_</a> == <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35251755f9b50eab4ee0e32bf01f38d7309">MEMORY</a>);
<a name="l00148"></a>00148         <span class="keywordflow">return</span> &amp;<a class="code" href="classdtn_1_1BundlePayload.html#e3e6c5e96b7f6bfb98b04da82e713bd5" title="payload data if in memory">data_</a>;
<a name="l00149"></a>00149     }
<a name="l00150"></a>00150 
<a name="l00155"></a>00155     <span class="keyword">const</span> u_char* <a class="code" href="classdtn_1_1BundlePayload.html#c4ce25f2d2d7ad54a9306ea2599731b4" title="Copy out a chunk of payload data into the supplied buffer.">read_data</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>, u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>);
<a name="l00156"></a>00156 
<a name="l00163"></a><a class="code" href="classdtn_1_1BundlePayload.html#1a004cbd3b8df28659dbd7d33d7c0ea2">00163</a>     <span class="keyword">const</span> u_char* <a class="code" href="classdtn_1_1BundlePayload.html#c4ce25f2d2d7ad54a9306ea2599731b4" title="Copy out a chunk of payload data into the supplied buffer.">read_data</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>, u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)<span class="keyword"> const</span>
<a name="l00164"></a>00164 <span class="keyword">    </span>{
<a name="l00165"></a>00165         <span class="keywordflow">return</span> <span class="keyword">const_cast&lt;</span><a class="code" href="classdtn_1_1BundlePayload.html" title="The representation of a bundle payload.">BundlePayload</a>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;
<a name="l00166"></a>00166             <a class="code" href="classdtn_1_1BundlePayload.html#c4ce25f2d2d7ad54a9306ea2599731b4" title="Copy out a chunk of payload data into the supplied buffer.">read_data</a>(offset, len, buf);
<a name="l00167"></a>00167     }
<a name="l00168"></a>00168      
<a name="l00172"></a>00172     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#e08a7791610755023cf33278caf575d8" title="Virtual from SerializableObject.">serialize</a>(oasys::SerializeAction* a);
<a name="l00173"></a>00173 
<a name="l00174"></a><a class="code" href="classdtn_1_1BundlePayload.html#a6a069c3d9678ae2ba08f24ab157544b">00174</a>     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1BundlePayload.html#a6a069c3d9678ae2ba08f24ab157544b" title="test: don&amp;#39;t rm payload files">test_no_remove_</a>;    
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="keyword">protected</span>:
<a name="l00177"></a>00177     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#825a4a03c08d8b16f0218b2b14751127">pin_file</a>() <span class="keyword">const</span>;
<a name="l00178"></a>00178     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#12bfd8c69a1dba6bd1c8549b7ed21e60">unpin_file</a>() <span class="keyword">const</span>;
<a name="l00179"></a>00179     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1BundlePayload.html#50f3b7708c881c1e82e6b8613d39551b">internal_write</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> offset, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00180"></a>00180 
<a name="l00181"></a><a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4">00181</a>     <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae352" title="Options for payload location state.">location_t</a> <a class="code" href="classdtn_1_1BundlePayload.html#d37754b4e0d886a478f5a265d943efd4" title="location of the data">location_</a>;       
<a name="l00182"></a><a class="code" href="classdtn_1_1BundlePayload.html#e3e6c5e96b7f6bfb98b04da82e713bd5">00182</a>     oasys::ScratchBuffer&lt;u_char*&gt; <a class="code" href="classdtn_1_1BundlePayload.html#e3e6c5e96b7f6bfb98b04da82e713bd5" title="payload data if in memory">data_</a>; 
<a name="l00183"></a><a class="code" href="classdtn_1_1BundlePayload.html#63caf4563b2b99f622ad74d927a2c284">00183</a>     <span class="keywordtype">size_t</span> <a class="code" href="classdtn_1_1BundlePayload.html#63caf4563b2b99f622ad74d927a2c284" title="the payload length">length_</a>;             
<a name="l00184"></a><a class="code" href="classdtn_1_1BundlePayload.html#511b9308e6d6d7bedad49d900cd23093">00184</a>     <span class="keyword">mutable</span> oasys::FileIOClient <a class="code" href="classdtn_1_1BundlePayload.html#511b9308e6d6d7bedad49d900cd23093" title="file handle">file_</a>;  
<a name="l00185"></a><a class="code" href="classdtn_1_1BundlePayload.html#5ae85b147a1bda87f79e8adafe474d11">00185</a>     <span class="keyword">mutable</span> <span class="keywordtype">size_t</span> <a class="code" href="classdtn_1_1BundlePayload.html#5ae85b147a1bda87f79e8adafe474d11" title="cache of current fd position">cur_offset_</a>; 
<a name="l00186"></a><a class="code" href="classdtn_1_1BundlePayload.html#946d784e2312a10a5d5d69ac0f306019">00186</a>     <span class="keywordtype">size_t</span> <a class="code" href="classdtn_1_1BundlePayload.html#946d784e2312a10a5d5d69ac0f306019" title="for fragments, offset into the file (todo)">base_offset_</a>;        
<a name="l00187"></a><a class="code" href="classdtn_1_1BundlePayload.html#0be54875feeddeb426badb6e25db4dde">00187</a>     oasys::SpinLock* <a class="code" href="classdtn_1_1BundlePayload.html#0be54875feeddeb426badb6e25db4dde" title="the lock for the given bundle">lock_</a>;     
<a name="l00188"></a>00188 };
<a name="l00189"></a>00189 
<a name="l00190"></a>00190 } <span class="comment">// namespace dtn</span>
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 <span class="preprocessor">#endif </span><span class="comment">/* _BUNDLE_PAYLOAD_H_ */</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:38 2008 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>