156 lines
12 KiB
HTML
156 lines
12 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.3.9.1 -->
|
|
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="examples.html">Examples</a></div>
|
|
<div class="nav">
|
|
<a class="el" href="dir_000000.html">include</a> / <a class="el" href="dir_000001.html">xqilla</a> / <a class="el" href="dir_000017.html">framework</a></div>
|
|
<h1>ReferenceCounted.hpp</h1><a href="ReferenceCounted_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
|
00002 <span class="comment"> * Copyright (c) 2001-2008</span>
|
|
00003 <span class="comment"> * DecisionSoft Limited. All rights reserved.</span>
|
|
00004 <span class="comment"> * Copyright (c) 2004-2008</span>
|
|
00005 <span class="comment"> * Oracle. All rights reserved.</span>
|
|
00006 <span class="comment"> *</span>
|
|
00007 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
|
|
00008 <span class="comment"> * you may not use this file except in compliance with the License.</span>
|
|
00009 <span class="comment"> * You may obtain a copy of the License at</span>
|
|
00010 <span class="comment"> *</span>
|
|
00011 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span>
|
|
00012 <span class="comment"> *</span>
|
|
00013 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
|
|
00014 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
|
|
00015 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
|
|
00016 <span class="comment"> * See the License for the specific language governing permissions and</span>
|
|
00017 <span class="comment"> * limitations under the License.</span>
|
|
00018 <span class="comment"> *</span>
|
|
00019 <span class="comment"> * $Id: ReferenceCounted.hpp 475 2008-01-08 18:47:44Z jpcs $</span>
|
|
00020 <span class="comment"> */</span>
|
|
00021
|
|
00022 <span class="preprocessor">#ifndef _REFERENCECOUNTED_HPP</span>
|
|
00023 <span class="preprocessor"></span><span class="preprocessor">#define _REFERENCECOUNTED_HPP</span>
|
|
00024 <span class="preprocessor"></span>
|
|
00025 <span class="preprocessor">#include <xqilla/framework/XQillaExport.hpp></span>
|
|
00026 <span class="preprocessor">#include <<a class="code" href="MemoryManager_8hpp.html">xercesc/framework/MemoryManager.hpp</a>></span>
|
|
00027
|
|
00028 <span class="comment">// for null RefCountPointer instances</span>
|
|
<a name="l00029"></a><a class="code" href="ReferenceCounted_8hpp.html#a0">00029</a> <span class="preprocessor">#define NULLRCP ((void *)0)</span>
|
|
00030 <span class="preprocessor"></span>
|
|
<a name="l00032"></a><a class="code" href="classReferenceCounted.html">00032</a> <span class="keyword">class </span>XQILLA_API ReferenceCounted
|
|
00033 {
|
|
00034 <span class="keyword">public</span>:
|
|
<a name="l00035"></a><a class="code" href="classReferenceCounted.html#a0">00035</a> <a class="code" href="classReferenceCounted.html#a0">ReferenceCounted</a>()
|
|
00036 : <a class="code" href="classReferenceCounted.html#p0">_ref_count</a>(0) {}
|
|
<a name="l00037"></a><a class="code" href="classReferenceCounted.html#a1">00037</a> <span class="keyword">virtual</span> <a class="code" href="classReferenceCounted.html#a1">~ReferenceCounted</a>() {}
|
|
00038
|
|
<a name="l00040"></a><a class="code" href="classReferenceCounted.html#a2">00040</a> <span class="keywordtype">void</span> <a class="code" href="classReferenceCounted.html#a2">incrementRefCount</a>()<span class="keyword"> const</span>
|
|
00041 <span class="keyword"> </span>{
|
|
00042 ++const_cast<unsigned int&>(_ref_count);
|
|
00043 }
|
|
00044
|
|
<a name="l00046"></a><a class="code" href="classReferenceCounted.html#a3">00046</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classReferenceCounted.html#a3">decrementRefCount</a>()<span class="keyword"> const</span>
|
|
00047 <span class="keyword"> </span>{
|
|
00048 <span class="keywordflow">if</span>(--const_cast<unsigned int&>(_ref_count) == 0) {
|
|
00049 <span class="keyword">delete</span> <span class="keyword">this</span>;
|
|
00050 }
|
|
00051 }
|
|
00052
|
|
00053 <span class="keyword">protected</span>:
|
|
<a name="l00054"></a><a class="code" href="classReferenceCounted.html#p0">00054</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> _ref_count; <span class="comment">// mutable</span>
|
|
00055 };
|
|
00056
|
|
<a name="l00058"></a><a class="code" href="classRefCountPointer.html">00058</a> <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">class </span><a class="code" href="classRefCountPointer.html">RefCountPointer</a>
|
|
00059 {
|
|
00060 <span class="keyword">public</span>:
|
|
<a name="l00061"></a><a class="code" href="classRefCountPointer.html#a0">00061</a> <a class="code" href="classRefCountPointer.html">RefCountPointer</a>(T *p = 0) : _p(p)
|
|
00062 {
|
|
00063 <span class="keywordflow">if</span>(_p != 0) _p->incrementRefCount();
|
|
00064 }
|
|
00065
|
|
<a name="l00066"></a><a class="code" href="classRefCountPointer.html#a1">00066</a> <span class="keyword">template</span><<span class="keyword">class</span> T2> <a class="code" href="classRefCountPointer.html">RefCountPointer</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T2></a> &o) : _p((T*)(T2*)o)
|
|
00067 {
|
|
00068 <span class="keywordflow">if</span>(_p != 0) _p->incrementRefCount();
|
|
00069 }
|
|
00070
|
|
<a name="l00071"></a><a class="code" href="classRefCountPointer.html#a2">00071</a> <a class="code" href="classRefCountPointer.html">RefCountPointer</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T></a> &o) : _p(o._p)
|
|
00072 {
|
|
00073 <span class="keywordflow">if</span>(_p != 0) _p->incrementRefCount();
|
|
00074 }
|
|
00075
|
|
<a name="l00076"></a><a class="code" href="classRefCountPointer.html#a3">00076</a> <a class="code" href="classRefCountPointer.html">RefCountPointer</a> &operator=(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T></a> &o)
|
|
00077 {
|
|
00078 <span class="keywordflow">if</span>(_p != o.<a class="code" href="classRefCountPointer.html#p0">_p</a>) {
|
|
00079 <span class="keywordflow">if</span>(_p != 0) _p->decrementRefCount();
|
|
00080 _p = o.<a class="code" href="classRefCountPointer.html#p0">_p</a>;
|
|
00081 <span class="keywordflow">if</span>(_p != 0) _p->incrementRefCount();
|
|
00082 }
|
|
00083 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
|
00084 }
|
|
00085
|
|
<a name="l00086"></a><a class="code" href="classRefCountPointer.html#a4">00086</a> ~<a class="code" href="classRefCountPointer.html">RefCountPointer</a>()
|
|
00087 {
|
|
00088 <span class="keywordflow">if</span>(_p != 0) _p->decrementRefCount();
|
|
00089 }
|
|
00090
|
|
<a name="l00091"></a><a class="code" href="classRefCountPointer.html#a5">00091</a> T *operator->()<span class="keyword"> const</span>
|
|
00092 <span class="keyword"> </span>{
|
|
00093 <span class="keywordflow">return</span> _p;
|
|
00094 }
|
|
00095
|
|
<a name="l00096"></a><a class="code" href="classRefCountPointer.html#a6">00096</a> operator T*()<span class="keyword"> const</span>
|
|
00097 <span class="keyword"> </span>{
|
|
00098 <span class="keywordflow">return</span> _p;
|
|
00099 }
|
|
00100
|
|
<a name="l00101"></a><a class="code" href="classRefCountPointer.html#a7">00101</a> T *get()<span class="keyword"> const</span>
|
|
00102 <span class="keyword"> </span>{
|
|
00103 <span class="keywordflow">return</span> _p;
|
|
00104 }
|
|
00105
|
|
<a name="l00106"></a><a class="code" href="classRefCountPointer.html#a8">00106</a> <span class="keywordtype">bool</span> isNull()<span class="keyword"> const</span>
|
|
00107 <span class="keyword"> </span>{
|
|
00108 <span class="keywordflow">return</span> (_p == 0);
|
|
00109 }
|
|
00110
|
|
<a name="l00111"></a><a class="code" href="classRefCountPointer.html#a9">00111</a> <span class="keywordtype">bool</span> notNull()<span class="keyword"> const</span>
|
|
00112 <span class="keyword"> </span>{
|
|
00113 <span class="keywordflow">return</span> (_p != 0);
|
|
00114 }
|
|
00115
|
|
00116 <span class="keyword">protected</span>:
|
|
<a name="l00117"></a><a class="code" href="classRefCountPointer.html#p0">00117</a> T *_p;
|
|
00118 };
|
|
00119
|
|
00120 <span class="keyword">template</span><<span class="keyword">class</span> T1, <span class="keyword">class</span> T2>
|
|
<a name="l00121"></a><a class="code" href="ReferenceCounted_8hpp.html#a1">00121</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a3">operator==</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T1></a> &a, <span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T2></a> &b)
|
|
00122 {
|
|
00123 <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)(T1*)a == (<span class="keywordtype">void</span>*)(T2*)b;
|
|
00124 }
|
|
00125
|
|
00126 <span class="keyword">template</span><<span class="keyword">class</span> T1, <span class="keyword">class</span> T2>
|
|
<a name="l00127"></a><a class="code" href="ReferenceCounted_8hpp.html#a2">00127</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a4">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T1></a> &a, <span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T2></a> &b)
|
|
00128 {
|
|
00129 <span class="keywordflow">return</span> (<span class="keywordtype">void</span>*)(T1*)a != (<span class="keywordtype">void</span>*)(T2*)b;
|
|
00130 }
|
|
00131
|
|
00132 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00133"></a><a class="code" href="ReferenceCounted_8hpp.html#a3">00133</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a3">operator==</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T></a> &a, <span class="keywordtype">void</span> *b)
|
|
00134 {
|
|
00135 <span class="keywordflow">return</span> (T*)a == (T*)b;
|
|
00136 }
|
|
00137
|
|
00138 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00139"></a><a class="code" href="ReferenceCounted_8hpp.html#a4">00139</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="ReferenceCounted_8hpp.html#a4">operator!=</a>(<span class="keyword">const</span> <a class="code" href="classRefCountPointer.html">RefCountPointer<T></a> &a, <span class="keywordtype">void</span> *b)
|
|
00140 {
|
|
00141 <span class="keywordflow">return</span> (T*)a != (T*)b;
|
|
00142 }
|
|
00143
|
|
00144 <span class="preprocessor">#endif</span>
|
|
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Sep 25 06:55:26 2009 for XQilla Simple API by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
|
|
</body>
|
|
</html>
|