<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.13"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>apt: apt-pkg/contrib/weakptr.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">apt  <span id="projectnumber">1.4.6</span> </div> <div id="projectbrief">commandline package manager</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.13 --> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> $(function() { initMenu('',false,false,'search.php','Search'); }); </script> <div id="main-nav"></div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_18f22d4be2ca84c350e120b6506056ca.xhtml">apt-pkg</a></li><li class="navelem"><a class="el" href="dir_c6ef23f15b074dcedf6810e24f2a7676.xhtml">contrib</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">weakptr.h</div> </div> </div><!--header--> <div class="contents"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/* weakptr.h - An object which supports weak pointers.</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> *</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> * Copyright (C) 2010 Julian Andres Klode <jak@debian.org></span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * </span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * This program is free software; you can redistribute it and/or modify</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * it under the terms of the GNU General Public License as published by</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * (at your option) any later version.</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> *</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * This program is distributed in the hope that it will be useful,</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * GNU General Public License for more details.</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> *</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * You should have received a copy of the GNU General Public License</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * along with this program; if not, write to the Free Software</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> * MA 02110-1301, USA.</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> */</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> </div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#ifndef WEAK_POINTER_H</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#define WEAK_POINTER_H</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> </div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include <set></span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include <stddef.h></span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classWeakPointable.xhtml"> 34</a></span> <span class="keyword">class </span><a class="code" href="classWeakPointable.xhtml">WeakPointable</a> {</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  std::set<WeakPointable**> pointers;</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> </div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div><div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="classWeakPointable.xhtml#ac9855cc66cd0e4d7425f4a6bbcfb5e80"> 43</a></span>  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classWeakPointable.xhtml#ac9855cc66cd0e4d7425f4a6bbcfb5e80">AddWeakPointer</a>(<a class="code" href="classWeakPointable.xhtml">WeakPointable</a>** weakptr) {</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  pointers.insert(weakptr);</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  }</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> </div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classWeakPointable.xhtml#ad2d7f814fc839c7ebdf677fb6f87ff5e"> 50</a></span>  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classWeakPointable.xhtml#ad2d7f814fc839c7ebdf677fb6f87ff5e">RemoveWeakPointer</a>(<a class="code" href="classWeakPointable.xhtml">WeakPointable</a> **weakptr) {</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  pointers.erase(weakptr);</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  }</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> </div><div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="classWeakPointable.xhtml#afec646ba51ad955392a42a9312061b56"> 57</a></span>  <a class="code" href="classWeakPointable.xhtml#afec646ba51ad955392a42a9312061b56">~WeakPointable</a>() {</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  std::set<WeakPointable**>::iterator iter = pointers.begin();</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keywordflow">while</span> (iter != pointers.end())</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  **(iter++) = 0;</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  }</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> };</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> </div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="preprocessor">#endif // WEAK_POINTER_H</span></div><div class="ttc" id="classWeakPointable_xhtml"><div class="ttname"><a href="classWeakPointable.xhtml">WeakPointable</a></div><div class="ttdef"><b>Definition:</b> weakptr.h:34</div></div> <div class="ttc" id="classWeakPointable_xhtml_afec646ba51ad955392a42a9312061b56"><div class="ttname"><a href="classWeakPointable.xhtml#afec646ba51ad955392a42a9312061b56">WeakPointable::~WeakPointable</a></div><div class="ttdeci">~WeakPointable()</div><div class="ttdef"><b>Definition:</b> weakptr.h:57</div></div> <div class="ttc" id="classWeakPointable_xhtml_ac9855cc66cd0e4d7425f4a6bbcfb5e80"><div class="ttname"><a href="classWeakPointable.xhtml#ac9855cc66cd0e4d7425f4a6bbcfb5e80">WeakPointable::AddWeakPointer</a></div><div class="ttdeci">void AddWeakPointer(WeakPointable **weakptr)</div><div class="ttdef"><b>Definition:</b> weakptr.h:43</div></div> <div class="ttc" id="classWeakPointable_xhtml_ad2d7f814fc839c7ebdf677fb6f87ff5e"><div class="ttname"><a href="classWeakPointable.xhtml#ad2d7f814fc839c7ebdf677fb6f87ff5e">WeakPointable::RemoveWeakPointer</a></div><div class="ttdeci">void RemoveWeakPointer(WeakPointable **weakptr)</div><div class="ttdef"><b>Definition:</b> weakptr.h:50</div></div> </div><!-- fragment --></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.13 </small></address> </body> </html>