Sophie

Sophie

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

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: PointerList.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>PointerList.h</h1><a href="PointerList_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 2006 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_POINTER_LIST_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_POINTER_LIST_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="keyword">namespace </span>prophet
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024 
<a name="l00030"></a>00030 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00031"></a><a class="code" href="classprophet_1_1PointerList.html">00031</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList</a> : <span class="keyword">public</span> std::<a class="code" href="classstd_1_1vector.html">vector</a>&lt;T*&gt;
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 <span class="keyword">public</span>: 
<a name="l00034"></a><a class="code" href="classprophet_1_1PointerList.html#1656f505bcc89213823142b87c947324">00034</a>     <span class="keyword">typedef</span> std::vector&lt;T*&gt; <a class="code" href="classprophet_1_1PointerList.html#1656f505bcc89213823142b87c947324">List</a>;
<a name="l00035"></a><a class="code" href="classprophet_1_1PointerList.html#4592d269227296c2bd509fd8f4089589">00035</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;T*&gt;::iterator <a class="code" href="classprophet_1_1PointerList.html#4592d269227296c2bd509fd8f4089589">iterator</a>;
<a name="l00036"></a><a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">00036</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::vector&lt;T*&gt;::const_iterator <a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">const_iterator</a>;
<a name="l00037"></a>00037 
<a name="l00041"></a><a class="code" href="classprophet_1_1PointerList.html#6a64c5b8046175d03da9a104919c82ae">00041</a>     <a class="code" href="classprophet_1_1PointerList.html#6a64c5b8046175d03da9a104919c82ae" title="Default constructor.">PointerList</a>()
<a name="l00042"></a>00042         : std::<a class="code" href="classstd_1_1vector.html">vector</a>&lt;T*&gt;() {}
<a name="l00043"></a>00043 
<a name="l00047"></a><a class="code" href="classprophet_1_1PointerList.html#37ad5bd84e40fa81c0aee80705578d95">00047</a>     <a class="code" href="classprophet_1_1PointerList.html#6a64c5b8046175d03da9a104919c82ae" title="Default constructor.">PointerList</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList</a>&amp; a)
<a name="l00048"></a>00048         : std::<a class="code" href="classstd_1_1vector.html">vector</a>&lt;T*&gt;()
<a name="l00049"></a>00049     {
<a name="l00050"></a>00050         <a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>();
<a name="l00051"></a>00051         <a class="code" href="classprophet_1_1PointerList.html#e3f483fe1e42360293304ebd4f01c2b6" title="Utility function to perform deep copy from peer object.">copy_from</a>(a);
<a name="l00052"></a>00052     }
<a name="l00053"></a>00053 
<a name="l00057"></a><a class="code" href="classprophet_1_1PointerList.html#062a9045021fcbef4d3e0b468dac64de">00057</a>     <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1PointerList.html#062a9045021fcbef4d3e0b468dac64de" title="Destructor.">~PointerList</a>()
<a name="l00058"></a>00058     {
<a name="l00059"></a>00059         <a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>();
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061 
<a name="l00065"></a><a class="code" href="classprophet_1_1PointerList.html#c334960a01b34730720bc6b13d5bb0bb">00065</a>     <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList</a>&amp; <a class="code" href="classprophet_1_1PointerList.html#c334960a01b34730720bc6b13d5bb0bb" title="Assignment operator creates deep copy, not pointer copy.">operator= </a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList</a>&amp; a)
<a name="l00066"></a>00066     {
<a name="l00067"></a>00067         <a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>();
<a name="l00068"></a>00068         <a class="code" href="classprophet_1_1PointerList.html#e3f483fe1e42360293304ebd4f01c2b6" title="Utility function to perform deep copy from peer object.">copy_from</a>(a);
<a name="l00069"></a>00069         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00075"></a><a class="code" href="classprophet_1_1PointerList.html#6153b191deba1b5eef87771ceef60ea7">00075</a>     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1PointerList.html#6153b191deba1b5eef87771ceef60ea7" title="Deletes member pointed to by iterator, then removes pointer.">erase</a>(<a class="code" href="classprophet_1_1PointerList.html#4592d269227296c2bd509fd8f4089589">iterator</a> i)
<a name="l00076"></a>00076     {
<a name="l00077"></a>00077         <span class="keyword">delete</span> (*i);
<a name="l00078"></a>00078         <a class="code" href="classprophet_1_1PointerList.html#6153b191deba1b5eef87771ceef60ea7" title="Deletes member pointed to by iterator, then removes pointer.">List::erase</a>(i);
<a name="l00079"></a>00079     }
<a name="l00080"></a>00080 
<a name="l00085"></a><a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e">00085</a>     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">clear</a>()
<a name="l00086"></a>00086     {
<a name="l00087"></a>00087         <a class="code" href="classprophet_1_1PointerList.html#59a327922f0e3b124a0294cfac273c9a" title="Free memory pointed to by member variables.">free</a>();
<a name="l00088"></a>00088         <a class="code" href="classprophet_1_1PointerList.html#8e42a99a3be3314a5cc84b08ee80d69e" title="Delete all member variables, then remove pointers from container.">List::clear</a>();
<a name="l00089"></a>00089     }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="keyword">protected</span>:
<a name="l00095"></a><a class="code" href="classprophet_1_1PointerList.html#59a327922f0e3b124a0294cfac273c9a">00095</a>     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1PointerList.html#59a327922f0e3b124a0294cfac273c9a" title="Free memory pointed to by member variables.">free</a>()
<a name="l00096"></a>00096     {
<a name="l00097"></a>00097         <span class="keywordflow">for</span>(<a class="code" href="classprophet_1_1PointerList.html#4592d269227296c2bd509fd8f4089589">iterator</a> i = List::begin();
<a name="l00098"></a>00098             i != <a class="code" href="dtncat_8c.html#7ab59805f7a1819164bc301293db600d">List::end</a>();
<a name="l00099"></a>00099             i++)
<a name="l00100"></a>00100         {
<a name="l00101"></a>00101             <span class="keyword">delete</span> *i;
<a name="l00102"></a>00102         }
<a name="l00103"></a>00103     }
<a name="l00107"></a><a class="code" href="classprophet_1_1PointerList.html#e3f483fe1e42360293304ebd4f01c2b6">00107</a>     <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1PointerList.html#e3f483fe1e42360293304ebd4f01c2b6" title="Utility function to perform deep copy from peer object.">copy_from</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html" title="Auto deletes pointers in list destructor This object assumes ownership for member...">PointerList</a>&amp; a)
<a name="l00108"></a>00108     {
<a name="l00109"></a>00109         <span class="keywordflow">for</span>(<a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">const_iterator</a> i = a.begin();
<a name="l00110"></a>00110             i != a.end();
<a name="l00111"></a>00111             i++)
<a name="l00112"></a>00112         {
<a name="l00113"></a>00113             push_back(<span class="keyword">new</span> T(**i));
<a name="l00114"></a>00114         }
<a name="l00115"></a>00115     }
<a name="l00116"></a>00116 }; <span class="comment">// template PointerList&lt;T&gt;</span>
<a name="l00117"></a>00117 
<a name="l00118"></a>00118 }; <span class="comment">// namespace prophet</span>
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 <span class="preprocessor">#endif // _PROPHET_POINTER_LIST_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>