Sophie

Sophie

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

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: TcaControlBundle.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>TcaControlBundle.h</h1><a href="TcaControlBundle_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 2005-2006 University of Waterloo</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 
<a name="l00018"></a>00018 <span class="preprocessor">#ifndef _TCA_CONTROLBUNDLE_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define _TCA_CONTROLBUNDLE_H_</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="comment">// Warning: This file is included by both the dtnd and the tca_admin app.</span>
<a name="l00023"></a>00023 <span class="comment">// Any changes here must be okay for both apps.</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="keyword">namespace </span>dtn {
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="comment">// TODO: Make individual subclass for each TcaControlBundle type</span>
<a name="l00031"></a>00031 <span class="comment">// and add strong argument checking (number of args, syntax, even semantic</span>
<a name="l00032"></a>00032 <span class="comment">// correctness in some cases)</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="comment">// Note: args can be appended manually, using args_.push_back(arg)</span>
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="classdtn_1_1TcaControlBundle.html">00036</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038 <span class="keyword">public</span>:
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4">00040</a>     <span class="keyword">enum</span> <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4">TypeCode</a> {
<a name="l00041"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4fd4e3d3502853ae038f4db99300b7105">00041</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4fd4e3d3502853ae038f4db99300b7105">CB_NULL</a>,
<a name="l00042"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe48d9f3d18024e2507f45f9e22a1490aef">00042</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe48d9f3d18024e2507f45f9e22a1490aef">CB_ADV</a>,
<a name="l00043"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe45ae3872010a25d6bb564f9e5ebcd275a">00043</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe45ae3872010a25d6bb564f9e5ebcd275a">CB_ADV_SENT</a>,
<a name="l00044"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43185d178bf8db68c292c5df0f17430f9">00044</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43185d178bf8db68c292c5df0f17430f9">CB_ASK</a>,
<a name="l00045"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe48f29a6c82d5630d9f296dc16b86d04b9">00045</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe48f29a6c82d5630d9f296dc16b86d04b9">CB_ASK_RECEIVED</a>,
<a name="l00046"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43b57fb4ba85b73f6a4491be6303bdd7f">00046</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43b57fb4ba85b73f6a4491be6303bdd7f">CB_ASK_SENT</a>,
<a name="l00047"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe407a943afd0f699f994e5a638a4d90a6d">00047</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe407a943afd0f699f994e5a638a4d90a6d">CB_COA</a>,
<a name="l00048"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe469c013f24e51ab7142fef6119f44b4f3">00048</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe469c013f24e51ab7142fef6119f44b4f3">CB_COA_SENT</a>,
<a name="l00049"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4e39614b1b00e02215e46f015be9589c6">00049</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4e39614b1b00e02215e46f015be9589c6">CB_REG_RECEIVED</a>,
<a name="l00050"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43b29556bcd6dbf0d78385c3a13c22f13">00050</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe43b29556bcd6dbf0d78385c3a13c22f13">CB_ROUTES</a>,
<a name="l00051"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe49fd49d430e23818a1c87ddc8f61cba15">00051</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe49fd49d430e23818a1c87ddc8f61cba15">CB_UNB</a>,
<a name="l00052"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe45ae6f3b5df45282221b975c9c05a794f">00052</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe45ae6f3b5df45282221b975c9c05a794f">CB_LINK_ANNOUNCE</a>,
<a name="l00053"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4216761fd82961adfe30d0f4bef92c57a">00053</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4216761fd82961adfe30d0f4bef92c57a">CB_LINK_AVAILABLE</a>,
<a name="l00054"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe484608abba5d9582eb4d7dc8494e82b1e">00054</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe484608abba5d9582eb4d7dc8494e82b1e">CB_LINK_UNAVAILABLE</a>,
<a name="l00055"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe400ac8aa62642b349226777fbe902643b">00055</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe400ac8aa62642b349226777fbe902643b">CB_CONTACT_UP</a>,
<a name="l00056"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4757e1c7f7c6a1cf083d343c88662f981">00056</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4757e1c7f7c6a1cf083d343c88662f981">CB_CONTACT_DOWN</a>,
<a name="l00057"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe402aea7331d2e3d5ab77ced229c5854db">00057</a>         <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe402aea7331d2e3d5ab77ced229c5854db">CB_UNKNOWN</a>              <span class="comment">// error: unrecognized code</span>
<a name="l00058"></a>00058     };
<a name="l00059"></a>00059 
<a name="l00060"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#ef38f45e597543dac728bf5a2ad73c5e">00060</a>     <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4">TypeCode</a> <a class="code" href="classdtn_1_1TcaControlBundle.html#ef38f45e597543dac728bf5a2ad73c5e">type_</a>;
<a name="l00061"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">00061</a>     std::string <a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a>;
<a name="l00062"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">00062</a>     std::vector&lt;std::string&gt; <a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>;
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#0addcd28a1b03a1e4a203e18b2d9ed4d">00064</a>     <a class="code" href="classdtn_1_1TcaControlBundle.html#0addcd28a1b03a1e4a203e18b2d9ed4d">TcaControlBundle</a>() : <a class="code" href="classdtn_1_1TcaControlBundle.html#ef38f45e597543dac728bf5a2ad73c5e">type_</a>(<a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4fd4e3d3502853ae038f4db99300b7105">CB_NULL</a>), <a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a>(),  <a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>() { };
<a name="l00065"></a>00065 
<a name="l00066"></a>00066     <span class="comment">// construct from Bundle payload, parsing out code and args</span>
<a name="l00067"></a>00067     <span class="comment">// you can also just give a code here to construct an argless bundle</span>
<a name="l00068"></a>00068     <a class="code" href="classdtn_1_1TcaControlBundle.html#0addcd28a1b03a1e4a203e18b2d9ed4d">TcaControlBundle</a>(<span class="keyword">const</span> std::string&amp; payload);
<a name="l00069"></a>00069     
<a name="l00070"></a><a class="code" href="classdtn_1_1TcaControlBundle.html#86221e4863666b3216db29ffc3e5a119">00070</a>     <span class="keyword">virtual</span> <a class="code" href="classdtn_1_1TcaControlBundle.html#86221e4863666b3216db29ffc3e5a119">~TcaControlBundle</a>() { }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="comment">// retrieve as string (suitable for sending as bundle payload)</span>
<a name="l00073"></a>00073     <span class="keyword">virtual</span> std::string <a class="code" href="classdtn_1_1TcaControlBundle.html#1b2e25e28170e7aea10c86c4319b2b9a">str</a>() <span class="keyword">const</span>;
<a name="l00074"></a>00074 
<a name="l00075"></a>00075     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1TcaControlBundle.html#bec9817f536c4cc8ca49c263423c1186">dump</a>(<span class="keyword">const</span> std::string&amp; intro) <span class="keyword">const</span>;
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <span class="comment">// todo: remove this from public interface someday</span>
<a name="l00078"></a>00078     <span class="keyword">static</span> std::string <a class="code" href="classdtn_1_1TcaControlBundle.html#758726d5a592252a7d7140b9de3f8cb8">eat_to_tab</a>(std::string&amp; s);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 <span class="keyword">protected</span>:
<a name="l00081"></a>00081 
<a name="l00082"></a>00082     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1TcaControlBundle.html#5f878ef3ef3dce4c816953f812baad8f">parse_payload</a>(<span class="keyword">const</span> std::string&amp; payload,
<a name="l00083"></a>00083                               <a class="code" href="classdtn_1_1TcaControlBundle.html#89a0451e100501918940f6913a1e2fe4">TypeCode</a>&amp; type,
<a name="l00084"></a>00084                               std::string&amp; code, std::string&amp; body);
<a name="l00085"></a>00085 
<a name="l00086"></a>00086 };
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="comment">// A TcaWrappedBundle is a TcaControlBundle that includes a source and</span>
<a name="l00090"></a>00090 <span class="comment">// dest field as args_[0] and args_[1] respectively. This is useful for</span>
<a name="l00091"></a>00091 <span class="comment">// "tunnelling" regular addressed bundles over the control API, preserving</span>
<a name="l00092"></a>00092 <span class="comment">// their source and dest fields.</span>
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 
<a name="l00095"></a><a class="code" href="classdtn_1_1TcaWrappedBundle.html">00095</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1TcaWrappedBundle.html">TcaWrappedBundle</a> : <span class="keyword">public</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 <span class="keyword">public</span>:
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     <span class="comment">// construct directly from string</span>
<a name="l00100"></a><a class="code" href="classdtn_1_1TcaWrappedBundle.html#204ad802fecde7eb075e651a56e2006d">00100</a>     <a class="code" href="classdtn_1_1TcaWrappedBundle.html#204ad802fecde7eb075e651a56e2006d">TcaWrappedBundle</a>(<span class="keyword">const</span> std::string&amp; payload) : <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>(payload) {}
<a name="l00101"></a>00101     
<a name="l00102"></a>00102     <span class="comment">// construct from existing ControlBundle</span>
<a name="l00103"></a><a class="code" href="classdtn_1_1TcaWrappedBundle.html#7df9d46e5581930a52941184c1506217">00103</a>     <a class="code" href="classdtn_1_1TcaWrappedBundle.html#7df9d46e5581930a52941184c1506217">TcaWrappedBundle</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb) : <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>(cb) {}
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     <span class="comment">// construct empty but addressed bundle</span>
<a name="l00106"></a>00106     <a class="code" href="classdtn_1_1TcaWrappedBundle.html#204ad802fecde7eb075e651a56e2006d">TcaWrappedBundle</a>(<span class="keyword">const</span> std::string&amp; code,
<a name="l00107"></a>00107                      <span class="keyword">const</span> std::string&amp; <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>, <span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1TcaWrappedBundle.html#a7e7c44c3b0cec83cd9332d03d60d5de">dest</a>);
<a name="l00108"></a>00108 
<a name="l00109"></a>00109     <span class="keyword">const</span> std::string <a class="code" href="classdtn_1_1TcaWrappedBundle.html#81b5effa7c29ee0b8fff3251c6e7835f">source</a>() <span class="keyword">const</span>;
<a name="l00110"></a>00110     <span class="keyword">const</span> std::string <a class="code" href="classdtn_1_1TcaWrappedBundle.html#a7e7c44c3b0cec83cd9332d03d60d5de">dest</a>() <span class="keyword">const</span>;
<a name="l00111"></a>00111 
<a name="l00112"></a><a class="code" href="classdtn_1_1TcaWrappedBundle.html#0e16b6fd651bcee3e23a524a59074f0a">00112</a>     <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1TcaWrappedBundle.html#0e16b6fd651bcee3e23a524a59074f0a">append_arg</a>(<span class="keyword">const</span> std::string&amp; arg) { <a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>.push_back(arg); }
<a name="l00113"></a>00113 };
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 } <span class="comment">// namespace dtn</span>
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 <span class="preprocessor">#endif </span><span class="comment">/* _TCA_CONTROLBUNDLE_H_ */</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:58 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>