blob: 99a1469e4aeb22c26e9b9f4ede642b31ecd5b9ad [file] [log] [blame]
<HTML><HEAD><TITLE>Xalan-C++ API Documentation</TITLE></HEAD>
<BODY>
<h2 align="center">Xalan-C++ API Documentation</h2>
<h3 align="center">The Xalan C++ XSLT Processor Version 1.10</h3>
</BODY>
<!-- Generated by Doxygen 1.2.8.1 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>ArenaAllocator.hpp</h1><a href="ArenaAllocator_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>
00002 <font class="comment"> * Copyright 1999-2004 The Apache Software Foundation.</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</font>
00005 <font class="comment"> * you may not use this file except in compliance with the License.</font>
00006 <font class="comment"> * You may obtain a copy of the License at</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</font>
00009 <font class="comment"> *</font>
00010 <font class="comment"> * Unless required by applicable law or agreed to in writing, software</font>
00011 <font class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</font>
00012 <font class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</font>
00013 <font class="comment"> * See the License for the specific language governing permissions and</font>
00014 <font class="comment"> * limitations under the License.</font>
00015 <font class="comment"> */</font>
00016
00017 <font class="preprocessor">#if !defined(ARENAALLOCATOR_INCLUDE_GUARD_1357924680)</font>
<a name="l00018"></a><a class="code" href="ArenaAllocator_8hpp.html#a0">00018</a> <font class="preprocessor"></font><font class="preprocessor">#define ARENAALLOCATOR_INCLUDE_GUARD_1357924680</font>
00019 <font class="preprocessor"></font>
00020
00021
00022 <font class="preprocessor">#include &lt;algorithm&gt;</font>
00023
00024
00025
00026 <font class="preprocessor">#include &lt;<a class="code" href="STLHelper_8hpp.html">xalanc/Include/STLHelper.hpp</a>&gt;</font>
00027 <font class="preprocessor">#include &lt;<a class="code" href="XalanList_8hpp.html">xalanc/Include/XalanList.hpp</a>&gt;</font>
00028
00029
00030
00031 <font class="preprocessor">#include "<a class="code" href="ArenaBlock_8hpp.html">ArenaBlock.hpp</a>"</font>
00032
00033
00034
00035 XALAN_CPP_NAMESPACE_BEGIN
00036
00037
00038
00039 <font class="keyword">template</font>&lt;<font class="keyword">class </font><a class="code" href="classXalanSourceTreeAttr.html">ObjectType</a>,
00040 <font class="preprocessor">#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)</font>
00041 <font class="preprocessor"></font> <font class="keyword">class </font>ArenaBlockType&gt;
00042 <font class="preprocessor">#else</font>
00043 <font class="preprocessor"></font> <font class="keyword">class </font>ArenaBlockType = <a class="code" href="classArenaBlock.html">ArenaBlock</a>&lt;<a class="code" href="classXalanSourceTreeAttr.html">ObjectType</a>&gt; &gt;
00044 #endif
<a name="l00045"></a><a class="code" href="classArenaAllocator.html">00045</a> class <a class="code" href="classArenaAllocator.html">ArenaAllocator</a>
00046 {
00047 <font class="keyword">public</font>:
00048
<a name="l00049"></a><a class="code" href="classArenaAllocator.html#s0">00049</a> <font class="keyword">typedef</font> <a class="code" href="classArenaAllocator.html">ArenaAllocator&lt;ObjectType, ArenaBlockType&gt;</a> <a class="code" href="classXalanDeque.html">ThisType</a>;
00050
<a name="l00051"></a><a class="code" href="classArenaAllocator.html#s1">00051</a> <font class="keyword">typedef</font> <a class="code" href="classXalanList.html">XalanList&lt;ArenaBlockType*&gt;</a> <a class="code" href="classXalanList.html">ArenaBlockListType</a>;
00052
<a name="l00053"></a><a class="code" href="classArenaAllocator.html#s2">00053</a> <font class="keyword">typedef</font> <font class="keyword">typename</font> ArenaBlockType::size_type size_type;
00054
00055 <font class="comment">/*</font>
00056 <font class="comment"> * Construct an instance that will allocate blocks of the specified size.</font>
00057 <font class="comment"> *</font>
00058 <font class="comment"> * @param theBlockSize The block size.</font>
00059 <font class="comment"> */</font>
<a name="l00060"></a><a class="code" href="classArenaAllocator.html#a0">00060</a> <a class="code" href="classArenaAllocator.html#a0">ArenaAllocator</a>(
00061 MemoryManagerType&amp; theManager,
00062 size_type theBlockSize) :
00063 m_blockSize(theBlockSize),
00064 m_blocks(theManager)
00065 {
00066 }
00067
00068 <font class="keyword">virtual</font>
<a name="l00069"></a><a class="code" href="classArenaAllocator.html#a1">00069</a> <a class="code" href="classArenaAllocator.html#a1">~ArenaAllocator</a>()<font class="keyword"></font>
00070 <font class="keyword"> </font>{
00071 <a class="code" href="classArenaAllocator.html#a10">reset</a>();
00072 }
00073
00074 MemoryManagerType&amp;
<a name="l00075"></a><a class="code" href="classArenaAllocator.html#a2">00075</a> <a class="code" href="classArenaAllocator.html#a2">getMemoryManager</a>()<font class="keyword"></font>
00076 <font class="keyword"> </font>{
00077 <font class="keywordflow">return</font> m_blocks.<a class="code" href="classXalanList.html#a2">getMemoryManager</a>();
00078 }
00079
00080 <font class="keyword">const</font> MemoryManagerType&amp;
<a name="l00081"></a><a class="code" href="classArenaAllocator.html#a3">00081</a> <a class="code" href="classArenaAllocator.html#a2">getMemoryManager</a>()<font class="keyword"> const</font>
00082 <font class="keyword"> </font>{
00083 <font class="keywordflow">return</font> m_blocks.<a class="code" href="classXalanList.html#a2">getMemoryManager</a>();
00084 }
00085
00086 <font class="comment">/*</font>
00087 <font class="comment"> * Get size of an ArenaBlock, that is, the number</font>
00088 <font class="comment"> * of objects in each block.</font>
00089 <font class="comment"> *</font>
00090 <font class="comment"> * @return The size of the block</font>
00091 <font class="comment"> */</font>
00092 size_type
<a name="l00093"></a><a class="code" href="classArenaAllocator.html#a4">00093</a> <a class="code" href="classArenaAllocator.html#a4">getBlockSize</a>()<font class="keyword"> const</font>
00094 <font class="keyword"> </font>{
00095 <font class="keywordflow">return</font> m_blockSize;
00096 }
00097
00098 <font class="comment">/*</font>
00099 <font class="comment"> * Set size of an ArenaBlock, that is, the number</font>
00100 <font class="comment"> * of objects in each block. Only affects blocks</font>
00101 <font class="comment"> * allocated after the call.</font>
00102 <font class="comment"> *</font>
00103 <font class="comment"> * @param theSize The size of the block</font>
00104 <font class="comment"> */</font>
00105 <font class="keywordtype">void</font>
<a name="l00106"></a><a class="code" href="classArenaAllocator.html#a5">00106</a> <a class="code" href="classArenaAllocator.html#a5">setBlockSize</a>(size_type theSize)<font class="keyword"></font>
00107 <font class="keyword"> </font>{
00108 m_blockSize = theSize;
00109 }
00110
00111 <font class="comment">/*</font>
00112 <font class="comment"> * Get the number of ArenaBlocks currently allocated.</font>
00113 <font class="comment"> *</font>
00114 <font class="comment"> * @return The number of blocks.</font>
00115 <font class="comment"> */</font>
00116 size_type
<a name="l00117"></a><a class="code" href="classArenaAllocator.html#a6">00117</a> <a class="code" href="classArenaAllocator.html#a6">getBlockCount</a>()<font class="keyword"> const</font>
00118 <font class="keyword"> </font>{
00119 <font class="keywordflow">return</font> (size_type)m_blocks.<a class="code" href="classXalanList.html#a14">size</a>();
00120 }
00121
00122 <font class="comment">/*</font>
00123 <font class="comment"> * Allocate a block of the appropriate size for an</font>
00124 <font class="comment"> * object. Call commitAllocation() when after</font>
00125 <font class="comment"> * the object is successfully constructed.</font>
00126 <font class="comment"> *</font>
00127 <font class="comment"> * @return A pointer to a block of memory</font>
00128 <font class="comment"> */</font>
00129 <font class="keyword">virtual</font> <a class="code" href="classXalanSourceTreeAttr.html">ObjectType</a>*
<a name="l00130"></a><a class="code" href="classArenaAllocator.html#a7">00130</a> <a class="code" href="classArenaAllocator.html#a7">allocateBlock</a>()<font class="keyword"></font>
00131 <font class="keyword"> </font>{
00132 <font class="keywordflow">if</font> (m_blocks.<a class="code" href="classXalanList.html#a15">empty</a>() == <font class="keyword">true</font> ||
00133 m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;blockAvailable() == <font class="keyword">false</font>)
00134 {
00135 m_blocks.<a class="code" href="classXalanList.html#a16">push_back</a>(
00136 ArenaBlockType::create(
00137 <a class="code" href="classArenaAllocator.html#a2">getMemoryManager</a>(),
00138 m_blockSize));
00139 }
00140 assert(
00141 m_blocks.<a class="code" href="classXalanList.html#a15">empty</a>() == <font class="keyword">false</font> &amp;&amp;
00142 m_blocks.<a class="code" href="classXalanList.html#a13">back</a>() != 0 &amp;&amp;
00143 m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;blockAvailable() == <font class="keyword">true</font>);
00144
00145 <font class="keywordflow">return</font> m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;allocateBlock();
00146 }
00147
00148 <font class="comment">/*</font>
00149 <font class="comment"> * Commits the allocation of the previous</font>
00150 <font class="comment"> * allocateBlock() call.</font>
00151 <font class="comment"> *</font>
00152 <font class="comment"> * @param theObject A pointer to a block of memory</font>
00153 <font class="comment"> */</font>
00154 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00155"></a><a class="code" href="classArenaAllocator.html#a8">00155</a> <a class="code" href="classArenaAllocator.html#a8">commitAllocation</a>(<a class="code" href="classXalanSourceTreeAttr.html">ObjectType</a>* theObject)<font class="keyword"></font>
00156 <font class="keyword"> </font>{
00157 assert(
00158 m_blocks.<a class="code" href="classXalanList.html#a15">empty</a>() == <font class="keyword">false</font> &amp;&amp;
00159 m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;ownsBlock(theObject) == <font class="keyword">true</font>);
00160
00161 m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;commitAllocation(theObject);
00162
00163 assert(m_blocks.<a class="code" href="classXalanList.html#a13">back</a>()-&gt;ownsObject(theObject) == <font class="keyword">true</font>);
00164 }
00165
00166 <font class="keyword">virtual</font> <font class="keywordtype">bool</font>
<a name="l00167"></a><a class="code" href="classArenaAllocator.html#a9">00167</a> <a class="code" href="classArenaAllocator.html#a9">ownsObject</a>(<font class="keyword">const</font> <a class="code" href="classXalanSourceTreeAttr.html">ObjectType</a>* theObject)<font class="keyword"> const</font>
00168 <font class="keyword"> </font>{
00169 <font class="keywordtype">bool</font> fResult = <font class="keyword">false</font>;
00170
00171 <font class="keyword">typedef</font> <font class="keyword">typename</font> ArenaBlockListType::const_reverse_iterator const_reverse_iterator;
00172
00173 <font class="comment">// Search back for a block that may have allocated the object...</font>
00174 <font class="keyword">const</font> const_reverse_iterator theEnd = this-&gt;m_blocks.<a class="code" href="classXalanList.html#a10">rend</a>();
00175
00176 const_reverse_iterator i = this-&gt;m_blocks.<a class="code" href="classXalanList.html#a8">rbegin</a>();
00177
00178 <font class="keywordflow">while</font>(i != theEnd)
00179 {
00180 assert(*i != 0);
00181
00182 <font class="keywordflow">if</font> ((*i)-&gt;ownsObject(theObject) == <font class="keyword">true</font>)
00183 {
00184 fResult = <font class="keyword">true</font>;
00185
00186 <font class="keywordflow">break</font>;
00187 }
00188 <font class="keywordflow">else</font>
00189 {
00190 ++i;
00191 }
00192 }
00193
00194 <font class="keywordflow">return</font> fResult;
00195 }
00196
00197 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00198"></a><a class="code" href="classArenaAllocator.html#a10">00198</a> <a class="code" href="classArenaAllocator.html#a10">reset</a>()<font class="keyword"></font>
00199 <font class="keyword"> </font>{
00200 XALAN_STD_QUALIFIER for_each(
00201 m_blocks.<a class="code" href="classXalanList.html#a4">begin</a>(),
00202 m_blocks.<a class="code" href="classXalanList.html#a6">end</a>(),
00203 <a class="code" href="structDeleteFunctor.html">DeleteFunctor&lt;ArenaBlockType&gt;</a>(m_blocks.<a class="code" href="classXalanList.html#a2">getMemoryManager</a>()));
00204
00205 m_blocks.<a class="code" href="classXalanList.html#a24">clear</a>();
00206 }
00207
00208 <font class="keyword">protected</font>:
00209
00210 <font class="comment">// data members...</font>
<a name="l00211"></a><a class="code" href="classArenaAllocator.html#n0">00211</a> size_type m_blockSize;
00212
<a name="l00213"></a><a class="code" href="classArenaAllocator.html#n1">00213</a> <a class="code" href="classXalanList.html">ArenaBlockListType</a> m_blocks;
00214
00215 <font class="keyword">private</font>:
00216
00217 <font class="comment">// Not defined...</font>
00218 <a class="code" href="classArenaAllocator.html#a0">ArenaAllocator</a>(<font class="keyword">const</font> <a class="code" href="classArenaAllocator.html">ArenaAllocator&lt;ObjectType, ArenaBlockType&gt;</a>&amp;);
00219
00220 <a class="code" href="classArenaAllocator.html">ArenaAllocator&lt;ObjectType, ArenaBlockType&gt;</a>&amp;
00221 operator=(<font class="keyword">const</font> <a class="code" href="classArenaAllocator.html">ArenaAllocator&lt;ObjectType, ArenaBlockType&gt;</a>&amp;);
00222
00223 <font class="keywordtype">bool</font>
00224 <a class="code" href="ElemAttributeSet_8hpp.html#a1">operator==</a>(<font class="keyword">const</font> <a class="code" href="classArenaAllocator.html">ArenaAllocator&lt;ObjectType, ArenaBlockType&gt;</a>&amp;) <font class="keyword">const</font>;
00225 };
00226
00227
00228
00229 XALAN_CPP_NAMESPACE_END
00230
00231
00232
00233 <font class="preprocessor">#endif // !defined(ARENAALLOCATOR_INCLUDE_GUARD_1357924680)</font>
</font></pre></div><p align="center"><a href="diagramnotes.html">Interpreting class diagrams</a></p>
<p><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<i><A href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</A> and
<A href="http://www.research.att.com/sw/tools/graphviz/">GraphViz</A> are used to generate this API documentation from the Xalan-C header files.</I></FONT></p>
<TABLE border="0" cellpadding="0" cellspacing="0" width="820"><TR><TD bgcolor="#0086b2"><IMG height="1" src="../resources/dot.gif" width="1" alt="dot"></TD></TR></TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80%">
<TR>
<TD WIDTH="80%" VALIGN="TOP">
<P ALIGN="CENTER"><B>Xalan-C++ XSLT Processor Version 1.10</B><BR>
Copyright &copy; 1999-2004 The Apache Software Foundation. All Rights Reserved.</i></p>
</TD>
</TR>
<TR>
<TD WIDTH="100%">
<P ALIGN="CENTER"><IMG SRC="ApacheLogo.jpg" WIDTH="387" HEIGHT="100" ALIGN="BOTTOM" BORDER="0" ALT="Apache Logo">
</TD>
</TR>
</TABLE>