/usr/share/doc/libucommon-dev/a00199_source.html is in libucommon-doc 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | <!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"/>
<title>UCommon: ucommon/object.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.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>ucommon/object.h</h1><a href="a00199.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span>
<a name="l00017"></a>00017
<a name="l00029"></a>00029 <span class="preprocessor">#ifndef _UCOMMON_OBJECT_H_</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_OBJECT_H_</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>></span>
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#include <stdlib.h></span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 NAMESPACE_UCOMMON
<a name="l00039"></a>00039
<a name="l00047"></a><a class="code" href="a00093.html">00047</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a>
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049 <span class="keyword">public</span>:
<a name="l00053"></a>00053 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a2244792e0d86a1c615d44df3e14f24a5" title="Convenence function to access object retention.">retain</a>(<span class="keywordtype">void</span>);
<a name="l00054"></a>00054
<a name="l00058"></a>00058 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00059"></a>00059
<a name="l00063"></a>00063 <span class="keyword">virtual</span> ~<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a>();
<a name="l00064"></a>00064
<a name="l00068"></a>00068 <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec" title="Convenence function to access object copy.">copy</a>(<span class="keywordtype">void</span>);
<a name="l00069"></a>00069
<a name="l00073"></a><a class="code" href="a00093.html#a68315d647b20f213075fe85566664d60">00073</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator++(<span class="keywordtype">void</span>)
<a name="l00074"></a>00074 {<a class="code" href="a00214.html#a2244792e0d86a1c615d44df3e14f24a5" title="Convenence function to access object retention.">retain</a>();};
<a name="l00075"></a>00075
<a name="l00079"></a><a class="code" href="a00093.html#a1aee78510382e5609068a083f6c00fa0">00079</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator--(<span class="keywordtype">void</span>)
<a name="l00080"></a>00080 {<a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>();};
<a name="l00081"></a>00081 };
<a name="l00082"></a>00082
<a name="l00090"></a><a class="code" href="a00043.html">00090</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00043.html" title="A base class for reference counted objects.">CountedObject</a> : <span class="keyword">public</span> <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a>
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 <span class="keyword">private</span>:
<a name="l00093"></a>00093 <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> count;
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keyword">protected</span>:
<a name="l00099"></a>00099 <a class="code" href="a00043.html" title="A base class for reference counted objects.">CountedObject</a>();
<a name="l00100"></a>00100
<a name="l00107"></a>00107 <a class="code" href="a00043.html" title="A base class for reference counted objects.">CountedObject</a>(<span class="keyword">const</span> <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> &ref);
<a name="l00108"></a>00108
<a name="l00114"></a>00114 <span class="keyword">virtual</span> <span class="keywordtype">void</span> dealloc(<span class="keywordtype">void</span>);
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="keyword">public</span>:
<a name="l00122"></a><a class="code" href="a00043.html#a6713d16ac91ca4b2c1f40fd6e6a9b83f">00122</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isCopied(<span class="keywordtype">void</span>)
<a name="l00123"></a>00123 {<span class="keywordflow">return</span> count > 1;};
<a name="l00124"></a>00124
<a name="l00129"></a><a class="code" href="a00043.html#aa2f6d15eea437d5a8f7ed3d8d46f770e">00129</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isRetained(<span class="keywordtype">void</span>)
<a name="l00130"></a>00130 {<span class="keywordflow">return</span> count > 0;};
<a name="l00131"></a>00131
<a name="l00136"></a><a class="code" href="a00043.html#a9ef9b7893de764fe0fd4852448b55eda">00136</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> copied(<span class="keywordtype">void</span>)
<a name="l00137"></a>00137 {<span class="keywordflow">return</span> count;};
<a name="l00138"></a>00138
<a name="l00142"></a>00142 <span class="keywordtype">void</span> <a class="code" href="a00093.html#aa7f0e5e4c160c0f155266afdb6ecddc6" title="Method to retain (or increase retention) of an object.">retain</a>(<span class="keywordtype">void</span>);
<a name="l00143"></a>00143
<a name="l00148"></a>00148 <span class="keywordtype">void</span> <a class="code" href="a00093.html#abe05f81356bdc73e67df7fb8a0ec59d5" title="Method to release (or decrease retention) of an object.">release</a>(<span class="keywordtype">void</span>);
<a name="l00149"></a>00149 };
<a name="l00150"></a>00150
<a name="l00159"></a><a class="code" href="a00165.html">00159</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00165.html" title="Used as base class for temporary objects.">Temporary</a>
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161 <span class="keyword">protected</span>:
<a name="l00162"></a>00162 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00028.html" title="A helper class for the temporary object template.">auto_delete</a>;
<a name="l00163"></a>00163 <span class="keyword">virtual</span> ~<a class="code" href="a00165.html" title="Used as base class for temporary objects.">Temporary</a>();
<a name="l00164"></a>00164 };
<a name="l00165"></a>00165
<a name="l00174"></a><a class="code" href="a00028.html">00174</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00028.html" title="A helper class for the temporary object template.">auto_delete</a>
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176 <span class="keyword">protected</span>:
<a name="l00177"></a>00177 <a class="code" href="a00165.html" title="Used as base class for temporary objects.">Temporary</a> *object;
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <span class="keyword">public</span>:
<a name="l00180"></a>00180 ~<a class="code" href="a00028.html" title="A helper class for the temporary object template.">auto_delete</a>();
<a name="l00181"></a>00181 };
<a name="l00182"></a>00182
<a name="l00193"></a><a class="code" href="a00029.html">00193</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a>
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 <span class="keyword">protected</span>:
<a name="l00196"></a>00196 <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *object;
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a>();
<a name="l00199"></a>00199
<a name="l00200"></a>00200 <span class="keyword">public</span>:
<a name="l00205"></a>00205 <a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a>(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>);
<a name="l00206"></a>00206
<a name="l00212"></a>00212 <a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a>(<span class="keyword">const</span> <a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a> &<a class="code" href="a00015.html" title="Typed smart pointer class.">pointer</a>);
<a name="l00213"></a>00213
<a name="l00219"></a>00219 ~<a class="code" href="a00029.html" title="A general purpose smart pointer helper class.">auto_pointer</a>();
<a name="l00220"></a>00220
<a name="l00225"></a>00225 <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<span class="keywordtype">void</span>);
<a name="l00226"></a>00226
<a name="l00231"></a>00231 <span class="keywordtype">bool</span> operator!() <span class="keyword">const</span>;
<a name="l00232"></a>00232
<a name="l00237"></a>00237 operator bool() <span class="keyword">const</span>;
<a name="l00238"></a>00238
<a name="l00244"></a>00244 <span class="keywordtype">bool</span> operator==(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>) <span class="keyword">const</span>;
<a name="l00245"></a>00245
<a name="l00251"></a>00251 <span class="keywordtype">bool</span> operator!=(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>) <span class="keyword">const</span>;
<a name="l00252"></a>00252
<a name="l00259"></a>00259 <span class="keywordtype">void</span> operator=(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>);
<a name="l00260"></a>00260 };
<a name="l00261"></a>00261
<a name="l00273"></a><a class="code" href="a00153.html">00273</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00153.html" title="A sparse array of managed objects.">sparse_array</a>
<a name="l00274"></a>00274 {
<a name="l00275"></a>00275 <span class="keyword">private</span>:
<a name="l00276"></a>00276 <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> **vector;
<a name="l00277"></a>00277 <span class="keywordtype">unsigned</span> <a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05" title="Template for max value of a type.">max</a>;
<a name="l00278"></a>00278
<a name="l00279"></a>00279 <span class="keyword">protected</span>:
<a name="l00285"></a>00285 <span class="keyword">virtual</span> <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *create(<span class="keywordtype">void</span>) = 0;
<a name="l00286"></a>00286
<a name="l00290"></a>00290 <span class="keywordtype">void</span> purge(<span class="keywordtype">void</span>);
<a name="l00291"></a>00291
<a name="l00297"></a>00297 <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keyword">get</span>(<span class="keywordtype">unsigned</span> offset);
<a name="l00298"></a>00298
<a name="l00304"></a>00304 <a class="code" href="a00153.html" title="A sparse array of managed objects.">sparse_array</a>(<span class="keywordtype">unsigned</span> size);
<a name="l00305"></a>00305
<a name="l00306"></a>00306 <span class="keyword">public</span>:
<a name="l00310"></a>00310 <span class="keyword">virtual</span> ~sparse_array();
<a name="l00311"></a>00311
<a name="l00316"></a>00316 <span class="keywordtype">unsigned</span> count(<span class="keywordtype">void</span>);
<a name="l00317"></a>00317 };
<a name="l00318"></a>00318
<a name="l00328"></a>00328 <span class="keyword">template</span> <<span class="keyword">class</span> T>
<a name="l00329"></a><a class="code" href="a00118.html">00329</a> <span class="keyword">class </span><a class="code" href="a00118.html" title="Generate a typed sparse managed object array.">sarray</a> : <span class="keyword">public</span> <a class="code" href="a00153.html" title="A sparse array of managed objects.">sparse_array</a>
<a name="l00330"></a>00330 {
<a name="l00331"></a>00331 <span class="keyword">public</span>:
<a name="l00336"></a><a class="code" href="a00118.html#acce7a41b9051602580363aa38bcebc0f">00336</a> <span class="keyword">inline</span> <a class="code" href="a00118.html#acce7a41b9051602580363aa38bcebc0f" title="Generate a sparse typed array of specified size.">sarray</a>(<span class="keywordtype">unsigned</span> size) : <a class="code" href="a00153.html" title="A sparse array of managed objects.">sparse_array</a>(size) {};
<a name="l00337"></a>00337
<a name="l00344"></a><a class="code" href="a00118.html#a20586a8df1a4adfb36189b17bb0b4e5d">00344</a> <span class="keyword">inline</span> T *<span class="keyword">get</span>(<span class="keywordtype">unsigned</span> offset)
<a name="l00345"></a>00345 {<span class="keyword">static_cast<</span>T*<span class="keyword">></span>(sparse_array::get(offset));};
<a name="l00346"></a>00346
<a name="l00353"></a><a class="code" href="a00118.html#af404b56dd67cf4ab34c937b20e8cdbba">00353</a> <span class="keyword">inline</span> T *operator[](<span class="keywordtype">unsigned</span> offset)
<a name="l00354"></a>00354 {<span class="keywordflow">return</span> <span class="keyword">get</span>(offset);};
<a name="l00355"></a>00355
<a name="l00356"></a>00356 <span class="keyword">private</span>:
<a name="l00357"></a>00357 __LOCAL <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *create(<span class="keywordtype">void</span>)
<a name="l00358"></a>00358 {<span class="keywordflow">return</span> <span class="keyword">new</span> T;};
<a name="l00359"></a>00359 };
<a name="l00360"></a>00360
<a name="l00373"></a>00373 <span class="keyword">template</span> <<span class="keyword">class</span> T>
<a name="l00374"></a><a class="code" href="a00164.html">00374</a> <span class="keyword">class </span><a class="code" href="a00164.html" title="Manage temporary object stored on the heap.">temporary</a> : <span class="keyword">public</span> <a class="code" href="a00028.html" title="A helper class for the temporary object template.">auto_delete</a>
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376 <span class="keyword">public</span>:
<a name="l00380"></a><a class="code" href="a00164.html#a5e17cde106c415ab0c6184704e3b7010">00380</a> <span class="keyword">inline</span> <a class="code" href="a00164.html" title="Manage temporary object stored on the heap.">temporary</a>()
<a name="l00381"></a>00381 {<span class="keywordtype">object</span> = <span class="keyword">new</span> T;};
<a name="l00382"></a>00382
<a name="l00387"></a><a class="code" href="a00164.html#a92cad176a2a97d43e4f320cdde35f4dc">00387</a> <span class="keyword">inline</span> T& operator*()<span class="keyword"> const</span>
<a name="l00388"></a>00388 <span class="keyword"> </span>{<span class="keywordflow">return</span> *(<span class="keyword">static_cast<</span>T*<span class="keyword">></span>(object));};
<a name="l00389"></a>00389
<a name="l00394"></a><a class="code" href="a00164.html#a9535d86f3056888fa7745ff2fe23b7f8">00394</a> <span class="keyword">inline</span> T* operator->()<span class="keyword"> const</span>
<a name="l00395"></a>00395 <span class="keyword"> </span>{<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(object);};
<a name="l00396"></a>00396 };
<a name="l00397"></a>00397
<a name="l00407"></a>00407 <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">class</span> O = CountedObject>
<a name="l00408"></a><a class="code" href="a00094.html">00408</a> <span class="keyword">class </span><a class="code" href="a00094.html" title="Template for embedding a data structure into a reference counted object.">object_value</a> : <span class="keyword">public</span> O
<a name="l00409"></a>00409 {
<a name="l00410"></a>00410 <span class="keyword">protected</span>:
<a name="l00415"></a><a class="code" href="a00094.html#a2c82a2d616db68f7b471ab78b2b2c286">00415</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keyword">const</span> T& object)
<a name="l00416"></a><a class="code" href="a00094.html#ac2324e8526e0cbb9539145af27414fd1">00416</a> {value = object;};
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <span class="keyword">public</span>:
<a name="l00419"></a>00419 T value;
<a name="l00424"></a><a class="code" href="a00094.html#a8bbab09d5c0865cf3af0cacc7b33c3ff">00424</a> <span class="keyword">inline</span> <a class="code" href="a00094.html#a8bbab09d5c0865cf3af0cacc7b33c3ff" title="Construct composite value object.">object_value</a>() : O() {};
<a name="l00425"></a>00425
<a name="l00430"></a><a class="code" href="a00094.html#ae552b596eae1fe8861994f0771986b48">00430</a> <span class="keyword">inline</span> <a class="code" href="a00094.html" title="Template for embedding a data structure into a reference counted object.">object_value</a>(T& existing) : O()
<a name="l00431"></a>00431 {value = existing;};
<a name="l00432"></a>00432
<a name="l00437"></a><a class="code" href="a00094.html#a341c0932d7c1f10fd24265b77d9f998a">00437</a> <span class="keyword">inline</span> T& operator*()
<a name="l00438"></a>00438 {<span class="keywordflow">return</span> value;};
<a name="l00439"></a>00439
<a name="l00444"></a><a class="code" href="a00094.html#af6bcc17b006ab4445f1f823ee2889f1c">00444</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> T& data)
<a name="l00445"></a>00445 {value = data;};
<a name="l00446"></a>00446
<a name="l00451"></a><a class="code" href="a00094.html#a0f5a0e77f12d39dbcde58267a3fd7b21">00451</a> <span class="keyword">inline</span> operator T()
<a name="l00452"></a>00452 {<span class="keywordflow">return</span> value;};
<a name="l00453"></a>00453
<a name="l00458"></a><a class="code" href="a00094.html#a3fd287604ee325328aa9ccb6eb679296">00458</a> <span class="keyword">inline</span> T& operator()()
<a name="l00459"></a>00459 {<span class="keywordflow">return</span> value;};
<a name="l00460"></a>00460
<a name="l00465"></a><a class="code" href="a00094.html#a092f92867cb974155da4e6a21bd6e10a">00465</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator()(T& data)
<a name="l00466"></a>00466 {value = data;};
<a name="l00467"></a>00467 };
<a name="l00468"></a>00468
<a name="l00481"></a>00481 <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">class</span> P = auto_po<span class="keywordtype">int</span>er>
<a name="l00482"></a><a class="code" href="a00015.html">00482</a> <span class="keyword">class </span><a class="code" href="a00015.html" title="Typed smart pointer class.">pointer</a> : <span class="keyword">public</span> P
<a name="l00483"></a>00483 {
<a name="l00484"></a>00484 <span class="keyword">public</span>:
<a name="l00488"></a><a class="code" href="a00015.html#a04dfaf161b844e6a19357289b8f416a3">00488</a> <span class="keyword">inline</span> <a class="code" href="a00015.html#a04dfaf161b844e6a19357289b8f416a3" title="Create a pointer with no reference.">pointer</a>() : P() {};
<a name="l00489"></a>00489
<a name="l00494"></a><a class="code" href="a00015.html#a7df16336d7e8de8a01bd9a59393e57f4">00494</a> <span class="keyword">inline</span> <a class="code" href="a00015.html#a7df16336d7e8de8a01bd9a59393e57f4" title="Create a pointer with a reference to a heap object.">pointer</a>(T* <span class="keywordtype">object</span>) : P(object) {};
<a name="l00495"></a>00495
<a name="l00500"></a><a class="code" href="a00015.html#a75bd1224aee905d8b84e8e29de8751d3">00500</a> <span class="keyword">inline</span> T* operator*()<span class="keyword"> const</span>
<a name="l00501"></a>00501 <span class="keyword"> </span>{<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(P::object);};
<a name="l00502"></a>00502
<a name="l00507"></a><a class="code" href="a00015.html#ae92a0fdd8e1966f4cf06d65878615015">00507</a> <span class="keyword">inline</span> T& operator()()<span class="keyword"> const</span>
<a name="l00508"></a>00508 <span class="keyword"> </span>{<span class="keywordflow">return</span> *(<span class="keyword">static_cast<</span>T*<span class="keyword">></span>(P::object));};
<a name="l00509"></a>00509
<a name="l00514"></a><a class="code" href="a00015.html#a49652c02e12056be835402b28c757bdf">00514</a> <span class="keyword">inline</span> T* operator->()<span class="keyword"> const</span>
<a name="l00515"></a>00515 <span class="keyword"> </span>{<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(P::object);};
<a name="l00516"></a>00516
<a name="l00521"></a><a class="code" href="a00015.html#a3b1062c5c79bc12acb7c96e9a1c900de">00521</a> <span class="keyword">inline</span> T* <span class="keyword">get</span>(void) <span class="keyword">const</span>
<a name="l00522"></a>00522 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span>T*<span class="keyword">></span>(P::object);};
<a name="l00523"></a>00523
<a name="l00528"></a><a class="code" href="a00015.html#a81917b88caedaee68369e11f67cc4711">00528</a> <span class="keyword">inline</span> T* operator++()
<a name="l00529"></a>00529 {P::operator++(); <span class="keywordflow">return</span> <span class="keyword">get</span>();};
<a name="l00530"></a>00530
<a name="l00535"></a><a class="code" href="a00015.html#aedc19cc1c834bdf0f5e12ce3be569760">00535</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator--()
<a name="l00536"></a>00536 {P::operator--(); <span class="keywordflow">return</span> <span class="keyword">get</span>();};
<a name="l00537"></a>00537
<a name="l00542"></a><a class="code" href="a00015.html#aa47d83815e3857180912cdbe9d81b5f9">00542</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> operator=(T *typed)
<a name="l00543"></a>00543 {P::operator=((<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *)typed);};
<a name="l00544"></a>00544 };
<a name="l00545"></a>00545
<a name="l00550"></a><a class="code" href="a00214.html#a2244792e0d86a1c615d44df3e14f24a5">00550</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a2244792e0d86a1c615d44df3e14f24a5" title="Convenence function to access object retention.">retain</a>(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>)
<a name="l00551"></a>00551 {<span class="keywordtype">object</span>->retain();}
<a name="l00552"></a>00552
<a name="l00557"></a><a class="code" href="a00214.html#a5b351681e88e716e108065fcac0209b6">00557</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#ab7bef2898e731474a9c3dfa805a6f56d" title="Convenience function to unlock shared object through it&#39;s protocol.">release</a>(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>)
<a name="l00558"></a>00558 {<span class="keywordtype">object</span>->release();}
<a name="l00559"></a>00559
<a name="l00564"></a><a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec">00564</a> <span class="keyword">inline</span> <a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec" title="Convenence function to access object copy.">copy</a>(<a class="code" href="a00093.html" title="A common base class for all managed objects.">Object</a> *<span class="keywordtype">object</span>)
<a name="l00565"></a>00565 {<span class="keywordflow">return</span> <span class="keywordtype">object</span>-><a class="code" href="a00093.html#aa0d1f1e892c05c421a4216905a72553d" title="Retain (increase retention of) object when copying.">copy</a>();}
<a name="l00566"></a>00566
<a name="l00572"></a>00572 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00573"></a><a class="code" href="a00214.html#aa074f1a5a7f2741a51a01bc1607fb4a6">00573</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#aa074f1a5a7f2741a51a01bc1607fb4a6" title="Convenience function to validate object assuming it is castable to bool.">is</a>(T& <span class="keywordtype">object</span>)
<a name="l00574"></a>00574 {<span class="keywordflow">return</span> <span class="keywordtype">object</span>.operator bool();}
<a name="l00575"></a>00575
<a name="l00576"></a>00576
<a name="l00583"></a>00583 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00584"></a><a class="code" href="a00214.html#a010df95c64f3a1f0e761ca8850ce6466">00584</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#a010df95c64f3a1f0e761ca8850ce6466" title="Convenience function to test pointer object.">isnull</a>(T& <span class="keywordtype">object</span>)
<a name="l00585"></a>00585 {<span class="keywordflow">return</span> (<span class="keywordtype">bool</span>)(<span class="keywordtype">object</span>.operator*() == NULL);}
<a name="l00586"></a>00586
<a name="l00593"></a>00593 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00594"></a><a class="code" href="a00214.html#a0c0eee1c2066c9322b517b1035875a45">00594</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="a00214.html#a0c0eee1c2066c9322b517b1035875a45" title="Convenience function to test pointer-pointer object.">isnullp</a>(T *<span class="keywordtype">object</span>)
<a name="l00595"></a>00595 {<span class="keywordflow">return</span> (<span class="keywordtype">bool</span>)(<span class="keywordtype">object</span>->operator*() == NULL);}
<a name="l00596"></a>00596
<a name="l00602"></a>00602 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00603"></a><a class="code" href="a00214.html#a2771e465ec7aff905ba09b7225b532ef">00603</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#a2771e465ec7aff905ba09b7225b532ef" title="Convenience function to swap objects.">swap</a>(T& o1, T& o2)
<a name="l00604"></a>00604 {<a class="code" href="a00201.html#a4880da985609d497e8ddb71652ca1e33" title="Portable swap code.">cpr_memswap</a>(&o1, &o2, <span class="keyword">sizeof</span>(T));}
<a name="l00605"></a>00605
<a name="l00612"></a>00612 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00613"></a><a class="code" href="a00214.html#a319bc203d49cc5fb784bd191737e114f">00613</a> <span class="keyword">inline</span> T& (<a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05" title="Template for max value of a type.">max</a>)(T& o1, T& o2)
<a name="l00614"></a>00614 {
<a name="l00615"></a>00615 <span class="keywordflow">return</span> o1 > o2 ? o1 : o2;
<a name="l00616"></a>00616 }
<a name="l00617"></a>00617
<a name="l00624"></a>00624 <span class="keyword">template</span><<span class="keyword">class</span> T>
<a name="l00625"></a><a class="code" href="a00214.html#a8f1ee47121623fc28b666b71e4f0b2e6">00625</a> <span class="keyword">inline</span> T& (<a class="code" href="a00214.html#a12c25876ddd218e42a739cea9e7af3d1" title="Template for min value of a type.">min</a>)(T& o1, T& o2)
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627 <span class="keywordflow">return</span> o1 < o2 ? o1 : o2;
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629
<a name="l00630"></a>00630 END_NAMESPACE
<a name="l00631"></a>00631
<a name="l00632"></a>00632 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|