173 lines
19 KiB
HTML
173 lines
19 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>XQilla Simple API Documentation</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
<link href="tabs.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<a style="float:right;" href="http://sourceforge.net/projects/xqilla"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=152021&type=2" border="0" alt="SourceForge.net Logo" /></a>
|
|
<!-- Generated by Doxygen 1.6.1 -->
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="index.html"><span>Main 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>
|
|
<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>File Members</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<h1>ReferenceCounted.hpp</h1><a href="ReferenceCounted_8hpp.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 (c) 2001, 2008,</span>
|
|
<a name="l00003"></a>00003 <span class="comment"> * DecisionSoft Limited. All rights reserved.</span>
|
|
<a name="l00004"></a>00004 <span class="comment"> * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.</span>
|
|
<a name="l00005"></a>00005 <span class="comment"> * </span>
|
|
<a name="l00006"></a>00006 <span class="comment"> *</span>
|
|
<a name="l00007"></a>00007 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
|
|
<a name="l00008"></a>00008 <span class="comment"> * you may not use this file except in compliance with the License.</span>
|
|
<a name="l00009"></a>00009 <span class="comment"> * You may obtain a copy of the License at</span>
|
|
<a name="l00010"></a>00010 <span class="comment"> *</span>
|
|
<a name="l00011"></a>00011 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span>
|
|
<a name="l00012"></a>00012 <span class="comment"> *</span>
|
|
<a name="l00013"></a>00013 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
|
|
<a name="l00014"></a>00014 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
|
|
<a name="l00015"></a>00015 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
|
|
<a name="l00016"></a>00016 <span class="comment"> * See the License for the specific language governing permissions and</span>
|
|
<a name="l00017"></a>00017 <span class="comment"> * limitations under the License.</span>
|
|
<a name="l00018"></a>00018 <span class="comment"> */</span>
|
|
<a name="l00019"></a>00019
|
|
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _REFERENCECOUNTED_HPP</span>
|
|
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _REFERENCECOUNTED_HPP</span>
|
|
<a name="l00022"></a>00022 <span class="preprocessor"></span>
|
|
<a name="l00023"></a>00023 <span class="preprocessor">#include <xqilla/framework/XQillaExport.hpp></span>
|
|
<a name="l00024"></a>00024 <span class="preprocessor">#include <<a class="code" href="MemoryManager_8hpp.html">xercesc/framework/MemoryManager.hpp</a>></span>
|
|
<a name="l00025"></a>00025
|
|
<a name="l00026"></a>00026 <span class="comment">// for null RefCountPointer instances</span>
|
|
<a name="l00027"></a><a class="code" href="ReferenceCounted_8hpp.html#a0b9d38d36c9739bb9e286ea387daea2b">00027</a> <span class="preprocessor">#define NULLRCP ((void *)0)</span>
|
|
<a name="l00028"></a>00028 <span class="preprocessor"></span>
|
|
<a name="l00030"></a><a class="code" href="classReferenceCounted.html">00030</a> <span class="keyword">class </span>XQILLA_API <a class="code" href="classReferenceCounted.html" title="Super class for reference counted classes.">ReferenceCounted</a>
|
|
<a name="l00031"></a>00031 {
|
|
<a name="l00032"></a>00032 <span class="keyword">public</span>:
|
|
<a name="l00033"></a><a class="code" href="classReferenceCounted.html#a5dc30ae895897b5008dc71ea26f175a1">00033</a> <a class="code" href="classReferenceCounted.html" title="Super class for reference counted classes.">ReferenceCounted</a>()
|
|
<a name="l00034"></a>00034 : _ref_count(0) {}
|
|
<a name="l00035"></a><a class="code" href="classReferenceCounted.html#a039b1f45b252a226c55598f31e3993cc">00035</a> <span class="keyword">virtual</span> <a class="code" href="classReferenceCounted.html#a039b1f45b252a226c55598f31e3993cc">~ReferenceCounted</a>() {}
|
|
<a name="l00036"></a>00036
|
|
<a name="l00038"></a><a class="code" href="classReferenceCounted.html#a386d6aab0473c14a32ce81226b939cb3">00038</a> <span class="keywordtype">void</span> incrementRefCount()<span class="keyword"> const</span>
|
|
<a name="l00039"></a>00039 <span class="keyword"> </span>{
|
|
<a name="l00040"></a>00040 ++<span class="keyword">const_cast<</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>&<span class="keyword">></span>(_ref_count);
|
|
<a name="l00041"></a>00041 }
|
|
<a name="l00042"></a>00042
|
|
<a name="l00044"></a><a class="code" href="classReferenceCounted.html#a426ce234c4797e7150f44a9bb50537b5">00044</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> decrementRefCount()<span class="keyword"> const</span>
|
|
<a name="l00045"></a>00045 <span class="keyword"> </span>{
|
|
<a name="l00046"></a>00046 <span class="keywordflow">if</span>(--const_cast<unsigned int&>(_ref_count) == 0) {
|
|
<a name="l00047"></a>00047 <span class="keyword">delete</span> <span class="keyword">this</span>;
|
|
<a name="l00048"></a>00048 }
|
|
<a name="l00049"></a>00049 }
|
|
<a name="l00050"></a>00050
|
|
<a name="l00051"></a><a class="code" href="classReferenceCounted.html#a462eca1b13abf41350ef3d969435db2c">00051</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getRefCount()<span class="keyword"> const</span>
|
|
<a name="l00052"></a>00052 <span class="keyword"> </span>{
|
|
<a name="l00053"></a>00053 <span class="keywordflow">return</span> _ref_count;
|
|
<a name="l00054"></a>00054 }
|
|
<a name="l00055"></a>00055
|
|
<a name="l00056"></a>00056 <span class="keyword">protected</span>:
|
|
<a name="l00057"></a><a class="code" href="classReferenceCounted.html#a09e5d033e5224cd8b94cdc061cb56fe0">00057</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> _ref_count; <span class="comment">// mutable</span>
|
|
<a name="l00058"></a>00058 };
|
|
<a name="l00059"></a>00059
|
|
<a name="l00061"></a><a class="code" href="classRefCountPointer.html">00061</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">class </span><a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer</a>
|
|
<a name="l00062"></a>00062 {
|
|
<a name="l00063"></a>00063 <span class="keyword">public</span>:
|
|
<a name="l00064"></a><a class="code" href="classRefCountPointer.html#a19e599ede99710afeca89ba65cdcb2a1">00064</a> <a class="code" href="classRefCountPointer.html#a19e599ede99710afeca89ba65cdcb2a1">RefCountPointer</a>(T *p = 0) : <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>(p)
|
|
<a name="l00065"></a>00065 {
|
|
<a name="l00066"></a>00066 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->incrementRefCount();
|
|
<a name="l00067"></a>00067 }
|
|
<a name="l00068"></a>00068
|
|
<a name="l00069"></a><a class="code" href="classRefCountPointer.html#a541717a9c467461b75ab8118ae6f9ed9">00069</a> <span class="keyword">template</span><<span class="keyword">class</span> T2> <a class="code" href="classRefCountPointer.html#a19e599ede99710afeca89ba65cdcb2a1">RefCountPointer</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T2></a> &o) : <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>((T*)(T2*)o)
|
|
<a name="l00070"></a>00070 {
|
|
<a name="l00071"></a>00071 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->incrementRefCount();
|
|
<a name="l00072"></a>00072 }
|
|
<a name="l00073"></a>00073
|
|
<a name="l00074"></a><a class="code" href="classRefCountPointer.html#adeb7f9624e9181b2b04950c38d4a8fce">00074</a> <a class="code" href="classRefCountPointer.html#a19e599ede99710afeca89ba65cdcb2a1">RefCountPointer</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T></a> &o) : <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>(o.<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>)
|
|
<a name="l00075"></a>00075 {
|
|
<a name="l00076"></a>00076 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->incrementRefCount();
|
|
<a name="l00077"></a>00077 }
|
|
<a name="l00078"></a>00078
|
|
<a name="l00079"></a><a class="code" href="classRefCountPointer.html#aaed4cb34420ba9a5190e142cdb3c786d">00079</a> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer</a> &<a class="code" href="classRefCountPointer.html#aaed4cb34420ba9a5190e142cdb3c786d">operator=</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T></a> &o)
|
|
<a name="l00080"></a>00080 {
|
|
<a name="l00081"></a>00081 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != o.<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>) {
|
|
<a name="l00082"></a>00082 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->decrementRefCount();
|
|
<a name="l00083"></a>00083 <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> = o.<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>;
|
|
<a name="l00084"></a>00084 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->incrementRefCount();
|
|
<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><a class="code" href="classRefCountPointer.html#a15aac5f85305a123c357bbddf5030ef3">00089</a> <a class="code" href="classRefCountPointer.html#a15aac5f85305a123c357bbddf5030ef3">~RefCountPointer</a>()
|
|
<a name="l00090"></a>00090 {
|
|
<a name="l00091"></a>00091 <span class="keywordflow">if</span>(<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0) <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>->decrementRefCount();
|
|
<a name="l00092"></a>00092 }
|
|
<a name="l00093"></a>00093
|
|
<a name="l00094"></a><a class="code" href="classRefCountPointer.html#a19c9fb1b8719f5b010c0943e3594296a">00094</a> T *<a class="code" href="classRefCountPointer.html#a19c9fb1b8719f5b010c0943e3594296a">operator-></a>()<span class="keyword"> const</span>
|
|
<a name="l00095"></a>00095 <span class="keyword"> </span>{
|
|
<a name="l00096"></a>00096 <span class="keywordflow">return</span> <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>;
|
|
<a name="l00097"></a>00097 }
|
|
<a name="l00098"></a>00098
|
|
<a name="l00099"></a><a class="code" href="classRefCountPointer.html#a6522f582ede5cc4a36fc990bf5165f7d">00099</a> <a class="code" href="classRefCountPointer.html#a6522f582ede5cc4a36fc990bf5165f7d">operator T*</a>()<span class="keyword"> const</span>
|
|
<a name="l00100"></a>00100 <span class="keyword"> </span>{
|
|
<a name="l00101"></a>00101 <span class="keywordflow">return</span> <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>;
|
|
<a name="l00102"></a>00102 }
|
|
<a name="l00103"></a>00103
|
|
<a name="l00104"></a><a class="code" href="classRefCountPointer.html#aad04c84082534aa246546bd0c3355848">00104</a> T *<span class="keyword">get</span>() <span class="keyword">const</span>
|
|
<a name="l00105"></a>00105 {
|
|
<a name="l00106"></a>00106 <span class="keywordflow">return</span> <a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>;
|
|
<a name="l00107"></a>00107 }
|
|
<a name="l00108"></a>00108
|
|
<a name="l00109"></a><a class="code" href="classRefCountPointer.html#a62f15012bafcbe02f0dcdbd2c0a749ee">00109</a> <span class="keywordtype">bool</span> <a class="code" href="classRefCountPointer.html#a62f15012bafcbe02f0dcdbd2c0a749ee">isNull</a>()<span class="keyword"> const</span>
|
|
<a name="l00110"></a>00110 <span class="keyword"> </span>{
|
|
<a name="l00111"></a>00111 <span class="keywordflow">return</span> (<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> == 0);
|
|
<a name="l00112"></a>00112 }
|
|
<a name="l00113"></a>00113
|
|
<a name="l00114"></a><a class="code" href="classRefCountPointer.html#a1de8e3bd6a0af6661047049983243e1c">00114</a> <span class="keywordtype">bool</span> <a class="code" href="classRefCountPointer.html#a1de8e3bd6a0af6661047049983243e1c">notNull</a>()<span class="keyword"> const</span>
|
|
<a name="l00115"></a>00115 <span class="keyword"> </span>{
|
|
<a name="l00116"></a>00116 <span class="keywordflow">return</span> (<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a> != 0);
|
|
<a name="l00117"></a>00117 }
|
|
<a name="l00118"></a>00118
|
|
<a name="l00119"></a>00119 <span class="keyword">protected</span>:
|
|
<a name="l00120"></a><a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">00120</a> T *<a class="code" href="classRefCountPointer.html#abdad2242b59d285fe75208c5fed5a90a">_p</a>;
|
|
<a name="l00121"></a>00121 };
|
|
<a name="l00122"></a>00122
|
|
<a name="l00123"></a>00123 <span class="keyword">template</span><<span class="keyword">class</span> T1, <span class="keyword">class</span> T2>
|
|
<a name="l00124"></a><a class="code" href="ReferenceCounted_8hpp.html#a579cc4195b4828fa122c6ba6871fbe43">00124</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a579cc4195b4828fa122c6ba6871fbe43">operator==</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T1></a> &a, <span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T2></a> &b)
|
|
<a name="l00125"></a>00125 {
|
|
<a name="l00126"></a>00126 <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)(T1*)a == (<span class="keywordtype">void</span>*)(T2*)b;
|
|
<a name="l00127"></a>00127 }
|
|
<a name="l00128"></a>00128
|
|
<a name="l00129"></a>00129 <span class="keyword">template</span><<span class="keyword">class</span> T1, <span class="keyword">class</span> T2>
|
|
<a name="l00130"></a><a class="code" href="ReferenceCounted_8hpp.html#aa9b8cf293c3af2483f499e2c1b2eb2f2">00130</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#aa9b8cf293c3af2483f499e2c1b2eb2f2">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T1></a> &a, <span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T2></a> &b)
|
|
<a name="l00131"></a>00131 {
|
|
<a name="l00132"></a>00132 <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)(T1*)a != (<span class="keywordtype">void</span>*)(T2*)b;
|
|
<a name="l00133"></a>00133 }
|
|
<a name="l00134"></a>00134
|
|
<a name="l00135"></a>00135 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00136"></a><a class="code" href="ReferenceCounted_8hpp.html#a88d1774a3c96b055a9321c8f40e11a66">00136</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a579cc4195b4828fa122c6ba6871fbe43">operator==</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T></a> &a, <span class="keywordtype">void</span> *b)
|
|
<a name="l00137"></a>00137 {
|
|
<a name="l00138"></a>00138 <span class="keywordflow">return</span> (T*)a == (T*)b;
|
|
<a name="l00139"></a>00139 }
|
|
<a name="l00140"></a>00140
|
|
<a name="l00141"></a>00141 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00142"></a><a class="code" href="ReferenceCounted_8hpp.html#a1982d9cc460432086a45091e2e8324c9">00142</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#aa9b8cf293c3af2483f499e2c1b2eb2f2">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html" title="Super class of all the reference counted wrappers for Items.">RefCountPointer<T></a> &a, <span class="keywordtype">void</span> *b)
|
|
<a name="l00143"></a>00143 {
|
|
<a name="l00144"></a>00144 <span class="keywordflow">return</span> (T*)a != (T*)b;
|
|
<a name="l00145"></a>00145 }
|
|
<a name="l00146"></a>00146
|
|
<a name="l00147"></a>00147 <span class="preprocessor">#endif</span>
|
|
</pre></div></div>
|
|
<hr size="1"/><address style="text-align: right;"><small>Generated on 18 May 2015 for XQilla Simple API by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
|
|
</body>
|
|
</html>
|