00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_DOMSTRINGCACHE_HEADER_GUARD) 00019 #define XALAN_DOMSTRINGCACHE_HEADER_GUARD 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanVector.hpp> 00029 00030 00031 00032 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00033 00034 00035 00036 #include <xalanc/PlatformSupport/XalanDOMStringReusableAllocator.hpp> 00037 00038 00039 00040 XALAN_CPP_NAMESPACE_BEGIN 00041 00042 00043 00044 class XALAN_PLATFORMSUPPORT_EXPORT XalanDOMStringCache 00045 { 00046 public: 00047 00048 enum { eDefaultMaximumSize = 100u }; 00049 00050 typedef XalanVector<XalanDOMString*> StringListType; 00051 00052 explicit 00053 XalanDOMStringCache( 00054 MemoryManager& theManager, 00055 XalanSize_t theMaximumSize = eDefaultMaximumSize); 00056 00057 ~XalanDOMStringCache(); 00058 00059 XalanSize_t 00060 getMaximumSize() const 00061 { 00062 return m_maximumSize; 00063 } 00064 00065 void 00066 setMaximumSize(XalanSize_t theSize) 00067 { 00068 m_maximumSize = theSize; 00069 } 00070 00071 XalanDOMString& 00072 get(); 00073 00074 bool 00075 release(XalanDOMString& theString); 00076 00077 /* 00078 * Clear all of the strings in the cache. This 00079 * destroys all of the strings. 00080 * 00081 */ 00082 void 00083 clear(); 00084 00085 /* 00086 * Reset the cache so that all strings that are 00087 * currently in use are available. 00088 */ 00089 void 00090 reset(); 00091 00092 class GetAndRelease 00093 { 00094 public: 00095 00096 GetAndRelease(XalanDOMStringCache& theCache) : 00097 m_cache(theCache), 00098 m_string(&theCache.get()) 00099 { 00100 } 00101 00102 ~GetAndRelease() 00103 { 00104 m_cache.release(*m_string); 00105 } 00106 00107 XalanDOMString& 00108 get() const 00109 { 00110 return *m_string; 00111 } 00112 00113 private: 00114 00115 XalanDOMStringCache& m_cache; 00116 00117 XalanDOMString* const m_string; 00118 }; 00119 00120 private: 00121 00122 // not implemented 00123 XalanDOMStringCache(const XalanDOMStringCache&); 00124 00125 bool 00126 operator==(const XalanDOMStringCache&) const; 00127 00128 XalanDOMStringCache& 00129 operator=(const XalanDOMStringCache&); 00130 00131 /** 00132 * A list to hold the strings that are available... 00133 */ 00134 StringListType m_availableList; 00135 00136 /** 00137 * A list to hold the strings that are busy... 00138 */ 00139 StringListType m_busyList; 00140 00141 XalanSize_t m_maximumSize; 00142 00143 XalanDOMStringReusableAllocator m_allocator; 00144 }; 00145 00146 00147 00148 XALAN_CPP_NAMESPACE_END 00149 00150 00151 00152 #endif // XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|