Xalan-C++ API Reference  1.12.0
XalanDOMStringCache.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XALAN_DOMSTRINGCACHE_HEADER_GUARD)
19 #define XALAN_DOMSTRINGCACHE_HEADER_GUARD
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
37 
38 
39 
40 namespace XALAN_CPP_NAMESPACE {
41 
42 
43 
45 {
46 public:
47 
48  enum { eDefaultMaximumSize = 100u };
49 
51 
52  explicit
54  MemoryManager& theManager,
55  XalanSize_t theMaximumSize = eDefaultMaximumSize);
56 
58 
59  XalanSize_t
61  {
62  return m_maximumSize;
63  }
64 
65  void
66  setMaximumSize(XalanSize_t theSize)
67  {
68  m_maximumSize = theSize;
69  }
70 
72  get();
73 
74  bool
75  release(XalanDOMString& theString);
76 
77  /*
78  * Clear all of the strings in the cache. This
79  * destroys all of the strings.
80  *
81  */
82  void
83  clear();
84 
85  /*
86  * Reset the cache so that all strings that are
87  * currently in use are available.
88  */
89  void
90  reset();
91 
93  {
94  public:
95 
97  m_cache(theCache),
98  m_string(&theCache.get())
99  {
100  }
101 
103  {
104  m_cache.release(*m_string);
105  }
106 
108  get() const
109  {
110  return *m_string;
111  }
112 
113  private:
114 
115  XalanDOMStringCache& m_cache;
116 
117  XalanDOMString* const m_string;
118  };
119 
120 private:
121 
122  // not implemented
124 
125  bool
126  operator==(const XalanDOMStringCache&) const;
127 
129  operator=(const XalanDOMStringCache&);
130 
131  /**
132  * A list to hold the strings that are available...
133  */
134  StringListType m_availableList;
135 
136  /**
137  * A list to hold the strings that are busy...
138  */
139  StringListType m_busyList;
140 
141  XalanSize_t m_maximumSize;
142 
144 };
145 
146 
147 
148 }
149 
150 
151 
152 #endif // XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::clear
void clear(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2475
XalanDOMStringReusableAllocator.hpp
XalanDOMString.hpp
xalanc::XalanVector< XalanDOMString * >
xalanc::XalanDOMStringReusableAllocator
Definition: XalanDOMStringReusableAllocator.hpp:41
XalanVector.hpp
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
xalanc::XalanDOMStringCache
Definition: XalanDOMStringCache.hpp:44
XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:35
PlatformSupportDefinitions.hpp
xalanc::XalanDOMStringCache::GetAndRelease::~GetAndRelease
~GetAndRelease()
Definition: XalanDOMStringCache.hpp:102
xalanc::XalanDOMStringCache::GetAndRelease
Definition: XalanDOMStringCache.hpp:92
xalanc::XalanDOMStringCache::getMaximumSize
XalanSize_t getMaximumSize() const
Definition: XalanDOMStringCache.hpp:60
xalanc::XalanDOMStringCache::GetAndRelease::get
XalanDOMString & get() const
Definition: XalanDOMStringCache.hpp:108
xalanc::XalanDOMStringCache::StringListType
XalanVector< XalanDOMString * > StringListType
Definition: XalanDOMStringCache.hpp:50
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanDOMStringCache::GetAndRelease::GetAndRelease
GetAndRelease(XalanDOMStringCache &theCache)
Definition: XalanDOMStringCache.hpp:96
xalanc::XalanDOMStringCache::setMaximumSize
void setMaximumSize(XalanSize_t theSize)
Definition: XalanDOMStringCache.hpp:66