Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > ed1483a4d9709d82850bb84cf25535e7 > files > 102

sfml-1.5-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="tabs.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="logo">
            <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" />
        </div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.htm"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.htm"><span>Namespaces</span></a></li>
      <li><a href="annotated.htm"><span>Classes</span></a></li>
      <li class="current"><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.htm"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>ResourcePtr.inl</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// SFML - Simple and Fast Multimedia Library</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span>
<a name="l00007"></a>00007 <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00010"></a>00010 <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span>
<a name="l00011"></a>00011 <span class="comment">// subject to the following restrictions:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// 1. The origin of this software must not be misrepresented;</span>
<a name="l00014"></a>00014 <span class="comment">//    you must not claim that you wrote the original software.</span>
<a name="l00015"></a>00015 <span class="comment">//    If you use this software in a product, an acknowledgment</span>
<a name="l00016"></a>00016 <span class="comment">//    in the product documentation would be appreciated but is not required.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// 2. Altered source versions must be plainly marked as such,</span>
<a name="l00019"></a>00019 <span class="comment">//    and must not be misrepresented as being the original software.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00022"></a>00022 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00025"></a>00025 
<a name="l00029"></a>00029 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00030"></a>00030 ResourcePtr&lt;T&gt;::ResourcePtr() :
<a name="l00031"></a>00031 myResource(NULL)
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 
<a name="l00040"></a>00040 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00041"></a>00041 <a class="code" href="classsf_1_1ResourcePtr.htm#48ddcd15ed75e9ee3ea88e4d29402140" title="Default constructor.">ResourcePtr&lt;T&gt;::ResourcePtr</a>(<span class="keyword">const</span> T* Resource) :
<a name="l00042"></a>00042 myResource(Resource)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044     <span class="keywordflow">if</span> (myResource)
<a name="l00045"></a>00045         myResource-&gt;Connect(*<span class="keyword">this</span>);
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 
<a name="l00052"></a>00052 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00053"></a>00053 <a class="code" href="classsf_1_1ResourcePtr.htm#48ddcd15ed75e9ee3ea88e4d29402140" title="Default constructor.">ResourcePtr&lt;T&gt;::ResourcePtr</a>(<span class="keyword">const</span> ResourcePtr&lt;T&gt;&amp; Copy) :
<a name="l00054"></a>00054 myResource(Copy.myResource)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056     <span class="keywordflow">if</span> (myResource)
<a name="l00057"></a>00057         myResource-&gt;Connect(*<span class="keyword">this</span>);
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 
<a name="l00064"></a>00064 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00065"></a>00065 <a class="code" href="classsf_1_1ResourcePtr.htm#0ec69fdecccd1240030b24385f6884dd" title="Destructor.">ResourcePtr&lt;T&gt;::~ResourcePtr</a>()
<a name="l00066"></a>00066 {
<a name="l00067"></a>00067     <span class="keywordflow">if</span> (myResource)
<a name="l00068"></a>00068         myResource-&gt;Disconnect(*<span class="keyword">this</span>);
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 
<a name="l00075"></a>00075 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00076"></a>00076 ResourcePtr&lt;T&gt;&amp; <a class="code" href="classsf_1_1ResourcePtr.htm#efd17640cfe8d96934435fb8f2b40574" title="Assignment operator from another ResourcePtr.">ResourcePtr&lt;T&gt;::operator =</a>(<span class="keyword">const</span> ResourcePtr&lt;T&gt;&amp; Other)
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078     <span class="keywordflow">if</span> (myResource)
<a name="l00079"></a>00079         myResource-&gt;Disconnect(*<span class="keyword">this</span>);
<a name="l00080"></a>00080 
<a name="l00081"></a>00081     myResource = Other.myResource;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <span class="keywordflow">if</span> (myResource)
<a name="l00084"></a>00084         myResource-&gt;Connect(*<span class="keyword">this</span>);
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 
<a name="l00093"></a>00093 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00094"></a>00094 ResourcePtr&lt;T&gt;&amp; <a class="code" href="classsf_1_1ResourcePtr.htm#efd17640cfe8d96934435fb8f2b40574" title="Assignment operator from another ResourcePtr.">ResourcePtr&lt;T&gt;::operator =</a>(<span class="keyword">const</span> T* Resource)
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096     <span class="keywordflow">if</span> (myResource)
<a name="l00097"></a>00097         myResource-&gt;Disconnect(*<span class="keyword">this</span>);
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     myResource = Resource;
<a name="l00100"></a>00100 
<a name="l00101"></a>00101     <span class="keywordflow">if</span> (myResource)
<a name="l00102"></a>00102         myResource-&gt;Connect(*<span class="keyword">this</span>);
<a name="l00103"></a>00103 
<a name="l00104"></a>00104     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 
<a name="l00114"></a>00114 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00115"></a>00115 <a class="code" href="classsf_1_1ResourcePtr.htm#7af0f407f121bff6e4dcf71c7c7955de" title="Cast operator to implicitely convert the resource pointer to its raw pointer type...">ResourcePtr&lt;T&gt;::operator const T*</a>()<span class="keyword"> const</span>
<a name="l00116"></a>00116 <span class="keyword"></span>{
<a name="l00117"></a>00117     <span class="keywordflow">return</span> myResource;
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00124"></a>00124 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00125"></a>00125 <span class="keyword">const</span> T&amp; <a class="code" href="classsf_1_1ResourcePtr.htm#4e5401c5a07347a35cc3b9192e11b071" title="Operator * overload to return a reference to the actual resource.">ResourcePtr&lt;T&gt;::operator *</a>()<span class="keyword"> const</span>
<a name="l00126"></a>00126 <span class="keyword"></span>{
<a name="l00127"></a>00127     <span class="keywordflow">return</span> *myResource;
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 
<a name="l00134"></a>00134 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00135"></a>00135 <span class="keyword">const</span> T* <a class="code" href="classsf_1_1ResourcePtr.htm#e58ea517eee0a97a778c3c59e4c3fe3a" title="Operator -&amp;gt; overload to return a pointer to the actual resource.">ResourcePtr&lt;T&gt;::operator -&gt;</a>()<span class="keyword"> const</span>
<a name="l00136"></a>00136 <span class="keyword"></span>{
<a name="l00137"></a>00137     <span class="keywordflow">return</span> myResource;
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 
<a name="l00145"></a>00145 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00146"></a>00146 <span class="keywordtype">void</span> <a class="code" href="classsf_1_1ResourcePtr.htm#e7e9d9ed819db0f541a7c22f5a28abf9" title="Function called when the observed resource is about to be destroyed.">ResourcePtr&lt;T&gt;::OnResourceDestroyed</a>()
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148     myResource = NULL;
<a name="l00149"></a>00149 }
</pre></div></div>

        <p id="footer">
            &nbsp;::&nbsp; Copyright &copy; 2007-2008 Laurent Gomila, all rights reserved &nbsp;::&nbsp;
            Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> &nbsp;::&nbsp;
        </p>

    </body>
</html>