Xerces-C++ 3.2.5
SynchronizedStringPool.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP)
23#define XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP
24
26#include <xercesc/util/StringPool.hpp>
27#include <xercesc/util/Mutexes.hpp>
28
30
31//
32// This class provides a synchronized string pool implementation.
33// This will necessarily be slower than the regular XMLStringPool, so it
34// should only be used when updates need to be made in a thread-safe
35// way. Updates will be made on datastructures local to this object;
36// all queries that don't involve mutation will first be directed at
37// the XMLStringPool implementation with which this object is
38// constructed.
39class XMLUTIL_EXPORT XMLSynchronizedStringPool : public XMLStringPool
40{
41public :
42 // -----------------------------------------------------------------------
43 // Constructors and Destructor
44 // -----------------------------------------------------------------------
46 (
47 const XMLStringPool * constPool
48 , const unsigned int modulus = 109
50 );
52
53
54 // -----------------------------------------------------------------------
55 // Pool management methods
56 // -----------------------------------------------------------------------
57 virtual unsigned int addOrFind(const XMLCh* const newString);
58 virtual bool exists(const XMLCh* const newString) const;
59 virtual bool exists(const unsigned int id) const;
60 virtual void flushAll();
61 virtual unsigned int getId(const XMLCh* const toFind) const;
62 virtual const XMLCh* getValueForId(const unsigned int id) const;
63 virtual unsigned int getStringCount() const;
64
65
66private :
67 // -----------------------------------------------------------------------
68 // Unimplemented constructors and operators
69 // -----------------------------------------------------------------------
72
73
74 // -----------------------------------------------------------------------
75 // private data members
76 // fConstPool
77 // the pool whose immutability we're protecting
78 // fMutex
79 // mutex to permit synchronous updates of our StringPool
80 const XMLStringPool* fConstPool;
81 XMLMutex fMutex;
82};
83
85
86#endif
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XMLUTIL_EXPORT
Definition XercesDefs.hpp:162
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
uint16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Configurable memory manager.
Definition MemoryManager.hpp:40
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
Definition SynchronizedStringPool.hpp:40
XMLSynchronizedStringPool(const XMLStringPool *constPool, const unsigned int modulus=109, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
virtual const XMLCh * getValueForId(const unsigned int id) const
virtual unsigned int getId(const XMLCh *const toFind) const
virtual bool exists(const XMLCh *const newString) const
virtual ~XMLSynchronizedStringPool()
virtual bool exists(const unsigned int id) const
virtual unsigned int getStringCount() const
virtual unsigned int addOrFind(const XMLCh *const newString)