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  

XalanDOMStringCache.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 #if !defined(XALAN_DOMSTRINGCACHE_HEADER_GUARD)
00017 #define XALAN_DOMSTRINGCACHE_HEADER_GUARD
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/Include/XalanVector.hpp>
00027 
00028 
00029 
00030 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00031 
00032 
00033 
00034 #include <xalanc/PlatformSupport/XalanDOMStringReusableAllocator.hpp>
00035 
00036 
00037 
00038 XALAN_CPP_NAMESPACE_BEGIN
00039 
00040 
00041 
00042 class XALAN_PLATFORMSUPPORT_EXPORT XalanDOMStringCache
00043 {
00044 public:
00045 
00046     enum { eDefaultMaximumSize = 100 };
00047 
00048     typedef XalanVector<XalanDOMString*>    StringListType;
00049 
00050     explicit
00051     XalanDOMStringCache(MemoryManagerType&     theManager,
00052                         unsigned int    theMaximumSize = eDefaultMaximumSize);
00053 
00054     ~XalanDOMStringCache();
00055 
00056     unsigned int
00057     getMaximumSize() const
00058     {
00059         return m_maximumSize;
00060     }
00061 
00062     void
00063     setMaximumSize(unsigned int     theSize)
00064     {
00065         m_maximumSize = theSize;
00066     }
00067 
00068     XalanDOMString&
00069     get();
00070 
00071     bool
00072     release(XalanDOMString&     theString);
00073 
00074     /*
00075      * Clear all of the strings in the cache.  This
00076      * destroys all of the strings.
00077      *
00078      */
00079     void
00080     clear();
00081 
00082     /*
00083      * Reset the cache so that all strings that are
00084      * currently in use are available.
00085      */
00086     void
00087     reset();
00088 
00089     class GetAndRelease
00090     {
00091     public:
00092 
00093         GetAndRelease(XalanDOMStringCache&  theCache) :
00094             m_cache(theCache),
00095             m_string(&theCache.get())
00096         {
00097         }
00098 
00099         ~GetAndRelease()
00100         {
00101             m_cache.release(*m_string);
00102         }
00103 
00104         XalanDOMString&
00105         get() const
00106         {
00107             return *m_string;
00108         }
00109 
00110     private:
00111 
00112         XalanDOMStringCache&    m_cache;
00113 
00114         XalanDOMString* const   m_string;
00115     };
00116 
00117 private:
00118 
00119     // not implemented
00120     XalanDOMStringCache(const XalanDOMStringCache&);
00121 
00122     bool
00123     operator==(const XalanDOMStringCache&) const;
00124 
00125     XalanDOMStringCache&
00126     operator=(const XalanDOMStringCache&);
00127 
00131     StringListType                      m_availableList;
00132 
00136     StringListType                      m_busyList;
00137 
00138     unsigned int                        m_maximumSize;
00139 
00140     XalanDOMStringReusableAllocator     m_allocator;
00141 };
00142 
00143 
00144 
00145 XALAN_CPP_NAMESPACE_END
00146 
00147 
00148 
00149 #endif  // XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD

Interpreting class diagrams

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

dot

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

Apache Logo