Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > by-pkgid > 5e43f5d92fadaa0a1cc4664249b615d0 > files > 485

xalan-c-doc-1.1-8mdk.i586.rpm

<HTML><HEAD><TITLE>Xalan-C++ API Documentation</TITLE></HEAD>
<BODY>
<h2 align="center">Xalan-C++ API Documentation</h2>
<h3 align="center">The Xalan C++ XSL Transformer Version 1.1</h3>
</BODY>
<!-- Generated by Doxygen 1.2.0 on Thu Feb 15 10:44:01 2001 -->
<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>ReusableArenaBlock.hpp</h1><a href="ReusableArenaBlock.hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*
</font>00002 <font class="comment"> * The Apache Software License, Version 1.1
</font>00003 <font class="comment"> *
</font>00004 <font class="comment"> *
</font>00005 <font class="comment"> * Copyright (c) 2000 The Apache Software Foundation.  All rights 
</font>00006 <font class="comment"> * reserved.
</font>00007 <font class="comment"> *
</font>00008 <font class="comment"> * Redistribution and use in source and binary forms, with or without
</font>00009 <font class="comment"> * modification, are permitted provided that the following conditions
</font>00010 <font class="comment"> * are met:
</font>00011 <font class="comment"> *
</font>00012 <font class="comment"> * 1. Redistributions of source code must retain the above copyright
</font>00013 <font class="comment"> *    notice, this list of conditions and the following disclaimer. 
</font>00014 <font class="comment"> *
</font>00015 <font class="comment"> * 2. Redistributions in binary form must reproduce the above copyright
</font>00016 <font class="comment"> *    notice, this list of conditions and the following disclaimer in
</font>00017 <font class="comment"> *    the documentation and/or other materials provided with the
</font>00018 <font class="comment"> *    distribution.
</font>00019 <font class="comment"> *
</font>00020 <font class="comment"> * 3. The end-user documentation included with the redistribution,
</font>00021 <font class="comment"> *    if any, must include the following acknowledgment:  
</font>00022 <font class="comment"> *       "This product includes software developed by the
</font>00023 <font class="comment"> *        Apache Software Foundation (http://www.apache.org/)."
</font>00024 <font class="comment"> *    Alternately, this acknowledgment may appear in the software itself,
</font>00025 <font class="comment"> *    if and wherever such third-party acknowledgments normally appear.
</font>00026 <font class="comment"> *
</font>00027 <font class="comment"> * 4. The names "Xalan" and "Apache Software Foundation" must
</font>00028 <font class="comment"> *    not be used to endorse or promote products derived from this
</font>00029 <font class="comment"> *    software without prior written permission. For written 
</font>00030 <font class="comment"> *    permission, please contact apache@apache.org.
</font>00031 <font class="comment"> *
</font>00032 <font class="comment"> * 5. Products derived from this software may not be called "Apache",
</font>00033 <font class="comment"> *    nor may "Apache" appear in their name, without prior written
</font>00034 <font class="comment"> *    permission of the Apache Software Foundation.
</font>00035 <font class="comment"> *
</font>00036 <font class="comment"> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
</font>00037 <font class="comment"> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
</font>00038 <font class="comment"> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
</font>00039 <font class="comment"> * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
</font>00040 <font class="comment"> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
</font>00041 <font class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
</font>00042 <font class="comment"> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
</font>00043 <font class="comment"> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
</font>00044 <font class="comment"> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
</font>00045 <font class="comment"> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
</font>00046 <font class="comment"> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
</font>00047 <font class="comment"> * SUCH DAMAGE.
</font>00048 <font class="comment"> * ====================================================================
</font>00049 <font class="comment"> *
</font>00050 <font class="comment"> * This software consists of voluntary contributions made by many
</font>00051 <font class="comment"> * individuals on behalf of the Apache Software Foundation and was
</font>00052 <font class="comment"> * originally based on software copyright (c) 1999, International
</font>00053 <font class="comment"> * Business Machines, Inc., http://www.ibm.com.  For more
</font>00054 <font class="comment"> * information on the Apache Software Foundation, please see
</font>00055 <font class="comment"> * &lt;http://www.apache.org/&gt;.
</font>00056 <font class="comment"> */</font>
00057 
00058 <font class="preprocessor">#if !defined(REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680)
</font><a name="l00059"></a><a class="code" href="ReusableArenaBlock.hpp.html#a0">00059</a> <font class="preprocessor"></font><font class="preprocessor">#define REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680
</font>00060 <font class="preprocessor"></font>
00061 
00062 
00063 <font class="preprocessor">#include &lt;<a class="code" href="XalanBitmap.hpp.html">PlatformSupport/XalanBitmap.hpp</a>&gt;</font>
00064 <font class="preprocessor">#include &lt;<a class="code" href="ArenaBlock.hpp.html">PlatformSupport/ArenaBlock.hpp</a>&gt;</font>
00065 
00066 
00067 
00068 
00069 <font class="keyword">template</font>&lt;<font class="keyword">class </font><a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;
<a name="l00070"></a><a class="code" href="class_reusablearenablock.html">00070</a> <font class="keyword">class </font><a class="code" href="class_reusablearenablock.html">ReusableArenaBlock</a> : <font class="keyword">public</font> <a class="code" href="class_arenablock.html">ArenaBlock</a>&lt;ObjectType&gt;
00071 {
00072 <font class="keyword">public</font>:
00073 
<a name="l00074"></a><a class="code" href="class_reusablearenablock.html#s0">00074</a>     <font class="keyword">typedef</font> <a class="code" href="class_arenablock.html">ArenaBlock</a>&lt;<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;              BaseClassType;
00075 
<a name="l00076"></a><a class="code" href="class_reusablearenablock.html#s1">00076</a>     <font class="keyword">typedef</font> <font class="keyword">typename</font> BaseClassType::size_type   size_type;
00077 
00078     <font class="comment">/*
</font>00079 <font class="comment">     * Construct an ArenaBlock of the specified size
</font>00080 <font class="comment">     * of objects.
</font>00081 <font class="comment">     *
</font>00082 <font class="comment">     * @param theBlockSize The size of the block (the number of objects it can contain).
</font>00083 <font class="comment">     */</font>
<a name="l00084"></a><a class="code" href="class_reusablearenablock.html#a0">00084</a>     <a class="code" href="class_reusablearenablock.html#a0">ReusableArenaBlock</a>(size_type    theBlockSize) :
00085         BaseClassType(theBlockSize),
00086         m_freeList(theBlockSize),
00087         m_freeBlockCount(0)
00088     {
00089     }
00090 
<a name="l00091"></a><a class="code" href="class_reusablearenablock.html#a1">00091</a>     <a class="code" href="class_reusablearenablock.html#a1">~ReusableArenaBlock</a>()<font class="keyword">
</font>00092 <font class="keyword">    </font>{
00093         <font class="comment">// Note that this-&gt; is required by template lookup rules.</font>
00094         this-&gt;<a class="code" href="class_arenablock.html#a9">destroyAll</a>();
00095     }
00096 
00097     <font class="comment">/*
</font>00098 <font class="comment">     * Allocate a block.  Once the object is constructed, you must call
</font>00099 <font class="comment">     * commitAllocation().
</font>00100 <font class="comment">     *
</font>00101 <font class="comment">     * @return a pointer to the new block.
</font>00102 <font class="comment">     */</font>
00103     <font class="keyword">virtual</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*
<a name="l00104"></a><a class="code" href="class_reusablearenablock.html#a2">00104</a>     <a class="code" href="class_arenablock.html#a2">allocateBlock</a>()<font class="keyword">
</font>00105 <font class="keyword">    </font>{
00106         <font class="keywordflow">if</font> (m_freeBlockCount == 0)
00107         {
00108             <font class="keywordflow">return</font> BaseClassType::allocateBlock();
00109         }
00110         <font class="keywordflow">else</font>
00111         {
00112             <font class="keywordflow">return</font> getNextFromFreeList();
00113         }
00114     }
00115 
00116     <font class="comment">/*
</font>00117 <font class="comment">     * Commit the previous allocation.
</font>00118 <font class="comment">     *
</font>00119 <font class="comment">     * @param theBlock the address that was returned by allocateBlock()
</font>00120 <font class="comment">     */</font>
00121     <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00122"></a><a class="code" href="class_reusablearenablock.html#a3">00122</a>     <a class="code" href="class_arenablock.html#a3">commitAllocation</a>(<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*    theBlock)<font class="keyword">
</font>00123 <font class="keyword">    </font>{
00124         assert(theBlock != 0);
00125         assert(m_freeBlockCount == 0 ||
00126                theBlock == getNextFromFreeList());
00127 
00128         <font class="keywordflow">if</font> (m_freeBlockCount == 0)
00129         {
00130             BaseClassType::commitAllocation(theBlock);
00131         }
00132         <font class="keywordflow">else</font>
00133         {
00134             removeFromFreeList(theBlock);
00135         }
00136     }
00137 
00138     <font class="comment">/*
</font>00139 <font class="comment">     * Find out if there is a block available.
</font>00140 <font class="comment">     *
</font>00141 <font class="comment">     * @return true if one is available, false if not.
</font>00142 <font class="comment">     */</font>
00143     <font class="keyword">virtual</font> <font class="keywordtype">bool</font>
<a name="l00144"></a><a class="code" href="class_reusablearenablock.html#a4">00144</a>     <a class="code" href="class_arenablock.html#a4">blockAvailable</a>()<font class="keyword"> const
</font>00145 <font class="keyword">    </font>{
00146         <font class="keywordflow">return</font> m_freeBlockCount != 0 ? <font class="keyword">true</font> : BaseClassType::blockAvailable();
00147     }
00148 
00149     <font class="comment">/*
</font>00150 <font class="comment">     * Get the number of objects currently allocated in the
</font>00151 <font class="comment">     * block.
</font>00152 <font class="comment">     *
</font>00153 <font class="comment">     * @return The number of objects allocated.
</font>00154 <font class="comment">     */</font>
00155     <font class="keyword">virtual</font> size_type
<a name="l00156"></a><a class="code" href="class_reusablearenablock.html#a5">00156</a>     <a class="code" href="class_arenablock.html#a5">getCountAllocated</a>()<font class="keyword"> const
</font>00157 <font class="keyword">    </font>{
00158         <font class="keywordflow">return</font> BaseClassType::getCountAllocated() - m_freeBlockCount;
00159     }
00160 
00161     <font class="comment">/*
</font>00162 <font class="comment">     * Determine if this block owns the specified object.  Note
</font>00163 <font class="comment">     * that even if the object address is within our block, this
</font>00164 <font class="comment">     * call will return false if no object currently occupies the
</font>00165 <font class="comment">     * block.  See also ownsBlock().
</font>00166 <font class="comment">     *
</font>00167 <font class="comment">     * @param theObject the address of the object.
</font>00168 <font class="comment">     * @return true if we own the object, false if not.
</font>00169 <font class="comment">     */</font>
00170     <font class="keyword">virtual</font> <font class="keywordtype">bool</font>
<a name="l00171"></a><a class="code" href="class_reusablearenablock.html#a6">00171</a>     <a class="code" href="class_arenablock.html#a7">ownsObject</a>(<font class="keyword">const</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*    theObject)<font class="keyword"> const
</font>00172 <font class="keyword">    </font>{
00173         <font class="keywordflow">return</font> BaseClassType::ownsObject(theObject) &amp;&amp; !isOnFreeList(theObject);
00174     }
00175 
00176     <font class="comment">/*
</font>00177 <font class="comment">     * Destroy the object, and return the block to the free list.
</font>00178 <font class="comment">     * The behavior is undefined if the object pointed to is not
</font>00179 <font class="comment">     * owned by the block.
</font>00180 <font class="comment">     *
</font>00181 <font class="comment">     * @param theObject the address of the object.
</font>00182 <font class="comment">     */</font>
00183     <font class="keywordtype">void</font>
<a name="l00184"></a><a class="code" href="class_reusablearenablock.html#a7">00184</a>     <a class="code" href="class_reusablearenablock.html#a7">destroyObject</a>(<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*   theObject)<font class="keyword">
</font>00185 <font class="keyword">    </font>{
00186         assert(<a class="code" href="class_arenablock.html#a7">ownsObject</a>(theObject) == <font class="keyword">true</font>);
00187 
00188         <a class="code" href="class_arenablock.html#n0">m_destroyFunction</a>(*theObject);
00189 
00190         addToFreeList(theObject);
00191     }
00192 
00193 <font class="keyword">protected</font>:
00194 
00195     <font class="comment">/*
</font>00196 <font class="comment">     * Determine if the block should be destroyed.  Returns true,
</font>00197 <font class="comment">     * unless the object is on the free list.  The behavior is
</font>00198 <font class="comment">     * undefined if the object pointed to is not owned by the
</font>00199 <font class="comment">     * block.
</font>00200 <font class="comment">     *
</font>00201 <font class="comment">     * @param theObject the address of the object
</font>00202 <font class="comment">     * @return true if block should be destroyed, false if not.
</font>00203 <font class="comment">     */</font>
00204     <font class="keyword">virtual</font> <font class="keywordtype">bool</font>
<a name="l00205"></a><a class="code" href="class_reusablearenablock.html#b0">00205</a>     <a class="code" href="class_arenablock.html#b0">shouldDestroyBlock</a>(<font class="keyword">const</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*    theObject)<font class="keyword"> const
</font>00206 <font class="keyword">    </font>{
00207         <font class="keywordflow">return</font> !isOnFreeList(theObject);
00208     }
00209 
00210 <font class="keyword">private</font>:
00211 
00212     <font class="comment">// Not implemented...</font>
00213     <a class="code" href="class_reusablearenablock.html#a0">ReusableArenaBlock</a>(<font class="keyword">const</font> <a class="code" href="class_reusablearenablock.html">ReusableArenaBlock</a>&lt;<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;&amp;);
00214 
00215     <a class="code" href="class_reusablearenablock.html">ReusableArenaBlock</a>&lt;<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;&amp;
00216     operator=(<font class="keyword">const</font> <a class="code" href="class_reusablearenablock.html">ReusableArenaBlock</a>&lt;<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;&amp;);
00217 
00218     <font class="keywordtype">bool</font>
00219     operator==(<font class="keyword">const</font> <a class="code" href="class_reusablearenablock.html">ReusableArenaBlock</a>&lt;<a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>&gt;&amp;) <font class="keyword">const</font>;
00220 
00221 
00222     <font class="comment">/*
</font>00223 <font class="comment">     * Determine if the block is on the free list.  The behavior is
</font>00224 <font class="comment">     * undefined if the object pointed to is not owned by the
</font>00225 <font class="comment">     * block.
</font>00226 <font class="comment">     *
</font>00227 <font class="comment">     * @param theObject the address of the object
</font>00228 <font class="comment">     * @return true if block is on the free list, false if not.
</font>00229 <font class="comment">     */</font>
00230     <font class="keywordtype">bool</font>
00231     isOnFreeList(<font class="keyword">const</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*  theObject)<font class="keyword"> const
</font>00232 <font class="keyword">    </font>{
00233         <font class="keywordflow">if</font> (m_freeBlockCount == 0)
00234         {
00235             <font class="keywordflow">return</font> <font class="keyword">false</font>;
00236         }
00237         <font class="keywordflow">else</font>
00238         {
00239             <font class="keyword">const</font> size_type     theOffset =
00240                     <a class="code" href="class_arenablock.html#b1">getBlockOffset</a>(theObject);
00241 
00242             <font class="keywordflow">return</font> m_freeList.<a class="code" href="class_xalanbitmap.html#a2">isSet</a>(theOffset);
00243         }
00244     }
00245 
00246     <font class="comment">/*
</font>00247 <font class="comment">     * Add a block to the free list.  The behavior is
</font>00248 <font class="comment">     * undefined if the object pointed to is not owned by the
</font>00249 <font class="comment">     * block.
</font>00250 <font class="comment">     *
</font>00251 <font class="comment">     * @param theObject the address of the object
</font>00252 <font class="comment">     */</font>
00253     <font class="keywordtype">void</font>
00254     addToFreeList(<font class="keyword">const</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*     theObject)<font class="keyword">
</font>00255 <font class="keyword">    </font>{
00256         <font class="keyword">const</font> size_type     theOffset =
00257                 <a class="code" href="class_arenablock.html#b1">getBlockOffset</a>(theObject);
00258 
00259         m_freeList.<a class="code" href="class_xalanbitmap.html#a3">set</a>(theOffset);
00260 
00261         ++m_freeBlockCount;
00262     }
00263 
00264     <font class="comment">/*
</font>00265 <font class="comment">     * Remove a block from the free list.  The behavior is
</font>00266 <font class="comment">     * undefined if the object pointed to is not owned by the
</font>00267 <font class="comment">     * block.
</font>00268 <font class="comment">     *
</font>00269 <font class="comment">     * @param theObject the address of the object
</font>00270 <font class="comment">     */</font>
00271     <font class="keywordtype">void</font>
00272     removeFromFreeList(<font class="keyword">const</font> <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*    theObject)<font class="keyword">
</font>00273 <font class="keyword">    </font>{
00274         <font class="keyword">const</font> size_type     theOffset =
00275                 <a class="code" href="class_arenablock.html#b1">getBlockOffset</a>(theObject);
00276 
00277         m_freeList.<a class="code" href="class_xalanbitmap.html#a4">clear</a>(theOffset);
00278 
00279         --m_freeBlockCount;
00280     }
00281 
00282     <font class="comment">/*
</font>00283 <font class="comment">     * Get the next block from the free list.  Returns 0 if
</font>00284 <font class="comment">     * the free list is empty.
</font>00285 <font class="comment">     *
</font>00286 <font class="comment">     * @return the address of the block
</font>00287 <font class="comment">     */</font>
00288     <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*
00289     getNextFromFreeList()<font class="keyword">
</font>00290 <font class="keyword">    </font>{
00291         <a class="code" href="class_xalansourcetreeattr.html">ObjectType</a>*     theResult = 0;
00292 
00293         <font class="keywordflow">if</font> (m_freeBlockCount &gt; 0)
00294         {
00295             <font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> theFreeListSize = m_freeList.<a class="code" href="class_xalanbitmap.html#a7">getSize</a>();
00296 
00297             <font class="keywordflow">for</font>(<font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> i = 0; i &lt; theFreeListSize; ++i)
00298             {
00299                 <font class="keywordflow">if</font> (m_freeList.<a class="code" href="class_xalanbitmap.html#a2">isSet</a>(i) == <font class="keyword">true</font>)
00300                 {
00301                     <font class="comment">// Note that this-&gt; is required by template lookup rules.</font>
00302                     theResult = this-&gt;<a class="code" href="class_arenablock.html#b2">getBlockAddress</a>(i);
00303 
00304                     <font class="keywordflow">break</font>;
00305                 }
00306             }
00307         }
00308 
00309         <font class="keywordflow">return</font> theResult;
00310     }
00311 
00312     <font class="comment">// Bitmap which tracks which blocks are not in use</font>
00313     <font class="comment">// and that should not be destroyed.</font>
00314     <a class="code" href="class_xalanbitmap.html">XalanBitmap</a>     m_freeList;
00315 
00316     <font class="comment">// The number of blocks on the free list.)</font>
00317     <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font>   m_freeBlockCount;
00318 };
00319 
00320 
00321 
00322 <font class="preprocessor">#endif  // !defined(REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680)
</font></div></pre><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="images/dot.gif" width="1"></TD></TR></TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80%">
	<TR>
		<TD WIDTH="80%" VALIGN="TOP">
			<P ALIGN="CENTER"><B>Xalan-C++ XSL Transformer Version 1.1</B><BR>
			Copyright &copy; 2000, 2001 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">
		</TD>
	</TR>
</TABLE>