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
40namespace XALAN_CPP_NAMESPACE {
41
42
43
45{
46public:
47
48 enum { eDefaultMaximumSize = 100u };
49
51
52 explicit
54 MemoryManager& theManager,
55 XalanSize_t theMaximumSize = eDefaultMaximumSize);
56
58
61 {
62 return m_maximumSize;
63 }
64
65 void
67 {
68 m_maximumSize = theSize;
69 }
70
72 get();
73
74 bool
76
77 /*
78 * Clear all of the strings in the cache. This
79 * destroys all of the strings.
80 *
81 */
82 void
84
85 /*
86 * Reset the cache so that all strings that are
87 * currently in use are available.
88 */
89 void
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
120private:
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
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
void setMaximumSize(XalanSize_t theSize)
XalanVector< XalanDOMString * > StringListType
bool release(XalanDOMString &theString)
XalanDOMStringCache(MemoryManager &theManager, XalanSize_t theMaximumSize=eDefaultMaximumSize)
XalanDOMString & get()
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)