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
25#include <xercesc/framework/MemoryManager.hpp>
26#include <xercesc/util/StringPool.hpp>
27#include <xercesc/util/Mutexes.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
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.
39 class XMLUTIL_EXPORT XMLSynchronizedStringPool : public XMLStringPool
40{
41public :
42 // -----------------------------------------------------------------------
43 // Constructors and Destructor
44 // -----------------------------------------------------------------------
45 XMLSynchronizedStringPool
46 (
47 const XMLStringPool * constPool
48 , const unsigned int modulus = 109
49 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
50 );
51 virtual ~XMLSynchronizedStringPool();
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 // -----------------------------------------------------------------------
70 XMLSynchronizedStringPool(const XMLSynchronizedStringPool&);
71 XMLSynchronizedStringPool& operator=(const XMLSynchronizedStringPool&);
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
84 XERCES_CPP_NAMESPACE_END
85
86#endif
MemoryManager.hpp
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XMLUTIL_EXPORT
#define XMLUTIL_EXPORT
Definition XercesDefs.hpp:162
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLCh
uint16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
MemoryManager
Configurable memory manager.
Definition MemoryManager.hpp:40
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMLSynchronizedStringPool
Definition SynchronizedStringPool.hpp:40
XMLSynchronizedStringPool::flushAll
virtual void flushAll()
XMLSynchronizedStringPool::XMLSynchronizedStringPool
XMLSynchronizedStringPool(const XMLStringPool *constPool, const unsigned int modulus=109, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
XMLSynchronizedStringPool::getValueForId
virtual const XMLCh * getValueForId(const unsigned int id) const
XMLSynchronizedStringPool::getId
virtual unsigned int getId(const XMLCh *const toFind) const
XMLSynchronizedStringPool::exists
virtual bool exists(const XMLCh *const newString) const
XMLSynchronizedStringPool::~XMLSynchronizedStringPool
virtual ~XMLSynchronizedStringPool()
XMLSynchronizedStringPool::exists
virtual bool exists(const unsigned int id) const
XMLSynchronizedStringPool::getStringCount
virtual unsigned int getStringCount() const
XMLSynchronizedStringPool::addOrFind
virtual unsigned int addOrFind(const XMLCh *const newString)