## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.10

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# ArenaBlock.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *     http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 #if !defined(ARENABLOCK_INCLUDE_GUARD_1357924680)
    00018 #define ARENABLOCK_INCLUDE_GUARD_1357924680
    00019
    00020
    00021
    00022 #include <xalanc/PlatformSupport/ArenaBlockBase.hpp>
    00023
    00024
    00025
    00026
    00027 XALAN_CPP_NAMESPACE_BEGIN
    00028
    00029
    00030 template<class ObjectType,
    00031 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
    00032          class SizeType>
    00033 #else
    00034          class SizeType = size_t>
    00035 #endif
    00036 class ArenaBlock : public ArenaBlockBase<ObjectType, SizeType>
    00037 {
    00038 public:
    00039
    00040     typedef ArenaBlockBase<ObjectType, SizeType>    BaseClassType;
    00041
    00042     typedef ArenaBlock<ObjectType, SizeType>        ThisType;
    00043
    00044     typedef typename BaseClassType::size_type       size_type;
    00045
    00046     /*
    00047      * Construct an ArenaBlock of the specified size
    00048      * of objects.
    00049      *
    00050      * @param theManager The memory manager instance for the block.
    00051      * @param theBlockSize The size of the block (the number of objects it can contain).
    00052      */
    00053     ArenaBlock(
    00054                 MemoryManagerType&  theManager,
    00055                 size_type           theBlockSize) :
    00056         BaseClassType(theManager, theBlockSize)
    00057     {
    00058     }
    00059
    00060     ~ArenaBlock()
    00061     {
    00062         assert( this->m_objectCount <= this->m_blockSize );
    00063
    00064         for ( size_type i = 0; i < this->m_objectCount  ; ++i )
    00065         {
    00066             XalanDestroy(this->m_objectBlock[i]);
    00067         }
    00068     }
    00069
    00070     static ThisType*
    00071     create(
    00072                 MemoryManagerType&  theManager,
    00073                 size_type           theBlockSize)
    00074     {
    00075         ThisType* theInstance;
    00076
    00077         return XalanConstruct(
    00078                     theManager,
    00079                     theInstance,
    00080                     theManager,
    00081                     theBlockSize);
    00082     }
    00083
    00084     /*
    00085      * Allocate a block.  Once the object is constructed, you must call
    00086      * commitAllocation().
    00087      *
    00088      * @return a pointer to the new block.
    00089      */
    00090     ObjectType*
    00091     allocateBlock()
    00092     {
    00093         // Any space left?
    00094         if (this->m_objectCount == this->m_blockSize)
    00095         {
    00096             return 0;
    00097         }
    00098         else
    00099         {
    00100             assert(this->m_objectBlock != 0);
    00101
    00102             return this->m_objectBlock + this->m_objectCount;
    00103         }
    00104     }
    00105
    00106     /*
    00107      * Commit the previous allocation.
    00108      *
    00109      * @param theBlock the address that was returned by allocateBlock()
    00110      */
    00111     void
    00112 #if defined (NDEBUG)
    00113     commitAllocation(ObjectType*    /* theBlock */)
    00114 #else
    00115     commitAllocation(ObjectType*    theBlock)
    00116 #endif
    00117     {
    00118         assert(theBlock == this->m_objectBlock + this->m_objectCount);
    00119         assert(this->m_objectCount < this->m_blockSize);
    00120
    00121         ++this->m_objectCount;
    00122     }
    00123
    00124     /*
    00125      * Determine if this block owns the specified object.  Note
    00126      * that even if the object address is within our block, this
    00127      * call will return false if no object currently occupies the
    00128      * block.  See also ownsBlock().
    00129      *
    00130      * @param theObject the address of the object.
    00131      * @return true if we own the object, false if not.
    00132      */
    00133     bool
    00134     ownsObject(const ObjectType*    theObject) const
    00135     {
    00136         return this->isInBorders(theObject, this->m_objectCount);
    00137     }
    00138
    00139 private:
    00140
    00141     // Not implemented...
    00142     ArenaBlock(const ArenaBlock<ObjectType, SizeType>&);
    00143
    00144     ArenaBlock<ObjectType, SizeType>&
    00145     operator=(const ArenaBlock<ObjectType, SizeType>&);
    00146
    00147     bool
    00148     operator==(const ArenaBlock<ObjectType, SizeType>&) const;
    00149 };
    00150
    00151
    00152
    00153 XALAN_CPP_NAMESPACE_END
    00154
    00155
    00156
    00157 #endif  // !defined(ARENABLOCK_INCLUDE_GUARD_1357924680)

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.